To open the video from camera or from the avi file, you may use the following two functions:
CvCapture *cap = cvCaptureFromCAM(0);
CvCapture *cap = cvCaptureFromAVI("test.avi");
IplImage *img = 0;
if (!cvGrabFrame(cap))
{
printf("cannot grab\n");
exit(0);
}
img = cvRetrieveFrame(cap);
You may also use the followings to capture one frame:
IplImage *img = 0;Use 'cvReleaseCapture(&cap);' in the end.
img = cvQueryFrame(cap);
if (!img)
{
printf("cannot grab\n");
exit(0);
}
No comments:
Post a Comment