I have a video engine2.avi that I want to read and show with openCV. Here\'s my code:
#include
#include
If you are just looking out for displaying the video, here's the code that worked for me, Please check if it helps you in any way.
#include
#include
int main(){
CvCapture *camera=cvCaptureFromFile("C:\\test.avi");
if (camera==NULL)
printf("camera is null\n");
else
printf("camera is not null");
cvNamedWindow("img");
while (cvWaitKey(10)!=atoi("q")){
double t1=(double)cvGetTickCount();
IplImage *img=cvQueryFrame(camera);
/*if(img){
cvSaveImage("C:/opencv.jpg",img);
}*/
double t2=(double)cvGetTickCount();
printf("time: %gms fps: %.2g\n",(t2-t1)/(cvGetTickFrequency()*1000.), 1000./((t2-t1)/(cvGetTickFrequency()*1000.)));
cvShowImage("img",img);
}
cvReleaseCapture(&camera);
}
Hope this helps you.