您好,我正在尝试运行下面的代码,但 cvCreateFileCapture 函数有问题。
#include "stdafx.h"
#include <iostream>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
using namespace std;
int main( int argc, char** argv ) {
cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
// CvCapture* capture = cvCaptureFromAVI( argv[1] ); // either one will work
CvCapture* capture = cvCreateFileCapture( "test.avi");
IplImage* frame;
while(1) {
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "Example2", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "Example2" );
最初我收到有关缺少 msvcr90d.dll 文件的错误。我必须下载 vs 2008 并更改平台工具集配置设置。执行此操作后,出现以下错误。任何帮助将非常感激。
最佳答案
我打赌 cvCreateFileCapture()
失败是因为它没有找到文件。您只是不知道,因为您没有检查函数的返回值。
如果无法加载视频文件,则返回NULL
。
CvCapture* capture = cvCreateFileCapture("test.avi");
if (capture == NULL)
{
std::cout << "!!! cvCreateFileCapture failed !!!" << std::endl;
exit(0);
}
关于c++ - OpenCv Visual C++ 2010 Express 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6701704/