c++ - OpenCv Visual C++ 2010 Express 问题

标签 c++ visual-studio-2010 opencv

您好,我正在尝试运行下面的代码,但 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 并更改平台工具集配置设置。执行此操作后,出现以下错误。任何帮助将非常感激。

enter image description here

最佳答案

我打赌 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/

相关文章:

c++ - 将派生对象添加到(抽象)基指针数组中

.net - NuGet 将 DLL 文件放在哪里?

python - 模块 'cv2.ml' 没有属性 'dtree_create'

java - 如何在Java OpenCV中将Blob转换为Mat?

c++ - 何时为多态类初始化 vptr(指向 vtable)?

c++ - 添加两个号码。无需任何运算符(operator)

c++ - C++ 简明检查元素是否属于临时集

c# - 我如何使用 Profilebase 类?

c++ - 使遗留代码 x64 兼容时出现非法读/写错误

c++ - QLabel 不显示视频