25 October 2007

OpenCV Problem with offset into video files.

OpenCV is unable to open into video files with offset. Guess we have to do it ourselves. The code which should take care of the offset is

/****************************************************************************/
#include
#include

int main()
{
CvCapture *video;
IplImage *im;
double wait;

cvNamedWindow("Video",1);
cvMoveWindow("Video",200,200);

video = cvCaptureFromFile("/home/sysad/Misc/Snatch.avi");
if(video==NULL)
{
abort();
}
cvSetCaptureProperty(video,CV_CAP_PROP_POS_AVI_RATIO,(double)0.75); // DOES NOT WORK CURRENTLY
im = cvQueryFrame(video);
wait = 1000.0/cvGetCaptureProperty(video,CV_CAP_PROP_FPS);

while(im!=NULL)
{
cvShowImage("Video",im);
cvWaitKey((int)wait);
im = cvQueryFrame(video);
}
cvReleaseCapture(&video);

return 0;
}

/************************************************************************/

Simplest workaround is to skip frames till one reaches the frame of interest!

No comments: