Ask Your Question

Revision history [back]

Basically what you are doing wrong looking at the code above is opening your capture but not reading any frame from it. Try the following code in stead of yours.

Mat frame;
VideoCapture capture(0);
while(true){ //infinite loop
   cap >> frame; //retrieve a single frame
   imshow("window", frame);
   int key = waitKey(0); //wait until key is pressed and give window time to call paint functionality
   if (key == 30){
       break; //if pressedkey is ESC, then exit the loop
   }
}