int main() {
VideoCapture cap(1); // open the video file for reading
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the video file" << endl;
return -1;
}
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE);
while(1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video or cap >> frame;
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}
//Do Image processing here
imshow("MyVideo", frame); //show the frame in "MyVideo" window
if(waitKey(300) == 27) //wait for 'esc' key press for 300 ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
cap.release();
return 0;
}
Note: the reason I set large delay is that the processing I'am Doing take more than 300ms
Thanks all in advance :) and sorry for my bad English