Please tell me how a video file is played in Opencv. I tried using cvCapture. here is the following code I used.
int main() { cvWaitKey(100);
CvCapture* capture = cvCreateFileCapture("C:\\Users\\sbv\\Documents\\MyVideo.avi");
IplImage* frame = NULL;
if (!capture)
{
printf("Video Not Opened\n");
return -1;
}
int width = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
int height = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int frame_count = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
printf("Video Size = %d x %d\n", width, height);
printf("FPS = %f\nTotal Frames = %d\n", fps, frame_count);
while (1)
{
frame = cvQueryFrame(capture);
if (!frame)
{
printf("Capture Finished\n");
break;
}
cvShowImage("video", frame);
cvWaitKey(10);
}
cvReleaseCapture(&capture);
return 0;
}