Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

waitKey() contains the whole message loop for the window.

when you do a imshow(), only a Mat header is copied, the actual blitting / drawing gets triggered later in the waitKey(). (that's why imshow() is so fast and waitKey() is so slow in your measurement above)

also, when your os is doing something heavy, and stalls your main thread for a moment, it will show up in this place.

calling it just 'waitKey()' might be a bit iof a misnomer ...

waitKey() contains the whole message loop for the window.

when you do a imshow(), only a Mat header is copied, the actual blitting / drawing gets triggered later in the waitKey(). (that's why imshow() is so fast and waitKey() is so slow in your measurement above)

also, when your os is doing something heavy, and stalls your main thread for a moment, it will show up in this place.

calling it just 'waitKey()' might be a bit iof a misnomer ...

still, you don not have to draw the image each time in the loop, and don't have toacall waitKey() each time:

int frameCounter=0;
while(1){
        frame = camera->GetLatestFrame();   
        if(frame){                      
            frame->Rasterize(cameraWidth, cameraHeight, imageCV.step, BITSPERPIXEL, imageCV.data);
        }
        if (++frameCounter % 10 ==0)  {
            imshow("V120", imageCV); 
            waitKey(1);                     
        }
        frame->Release();                   
    }
click to hide/show revision 3
Suggested edit

waitKey() contains the whole message loop for the window.

when When you do a imshow(), only a Mat header is copied, the actual blitting / drawing gets triggered later in the waitKey(). (that's why imshow() is so fast and waitKey() is so slow in your measurement above)

also, Also, when your os is doing something heavy, and stalls your main thread for a moment, it will show up in this place.

calling Calling it just 'waitKey()' might be a bit iof of a misnomer ...

still, Still, you don do not have to draw the image each time in the loop, and don't have toacall to call waitKey() each time:

int frameCounter=0;
while(1){
        frame = camera->GetLatestFrame();   
        if(frame){                      
            frame->Rasterize(cameraWidth, cameraHeight, imageCV.step, BITSPERPIXEL, imageCV.data);
        }
        if (++frameCounter % 10 ==0)  {
            imshow("V120", imageCV); 
            waitKey(1);                     
        }
        frame->Release();                   
    }