使用C API(不是C ++),如何逐帧读取简单的视频文件,并将此帧(作为CvMat *)关闭以进行处理?
答案 0 :(得分:1)
如下所示:
CvCapture* cap = cvCreateFileCapture(MyVideoFile);
if (!cap) { /* handle error */ }
for(;;) {
IplImage* frame = cvQueryFrame(cap);
if (!frame) { /* EOF */ break; }
CvMat tempMat;
CvMat* myMat = cvGetMat( frame, &tempMat, 0, 0);
// use myMat
// Note: Don't free the frame returned by cvQueryFrame!
}
cvReleaseCapture(&cap);