Windows中的VideoCapture OpenCV 2.4.2错误 [英] VideoCapture OpenCV 2.4.2 error in windows

查看:144
本文介绍了Windows中的VideoCapture OpenCV 2.4.2错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows XP 32位下将VideoCapture类与OpenCV 2.4.2一起使用时遇到问题. 它不会打开任何文件或相机,并且解决它很麻烦. 我使用的是Visual Studio 2010,但我也在QTcreator中尝试了相同的结果.

I have a problem using VideoCapture class with OpenCV 2.4.2 under windows XP 32bits. It doesn't open any file or camera and fixing it's being a pain. Im using visual studio 2010 but i have also tried the code in QTcreator with the same result.

测试代码如下:

#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>
#include <string> 
#include <iomanip> 
#include <sstream> 

using namespace cv;
using namespace std;

int main()
{
    const char* videoPath = "C:/video/";
    string videoName = string(videoPath) + "avi.avi";
    VideoCapture cap(videoName);

    if(!cap.isOpened()) 
    {
        std::cout<<"Fail"<<std::endl;
        return -3;
    }
    return 0; 
}

输出始终为"-3". Qt Creator显示了一个 警告:打开文件时出错(../../modules/highgui/src/cap_ffmpeg_impl.hpp:361)

The output is always '-3'. Qt Creator shows a warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:361)

我调试了它,问题出现在以下内容的第一行:

I debugged it and the problem appears in the first line of:

CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
{
    CvCapture_FFMPEG_proxy* result = new CvCapture_FFMPEG_proxy;
    if( result->open( filename ))
        return result;
    delete result;
#if defined WIN32 || defined _WIN32
    return cvCreateFileCapture_VFW(filename);
#else
    return 0;
#endif
}

在cap_ffmpeg.cpp内部文件中.

in the cap_ffmpeg.cpp internal file.

我已经在雪豹下的Mac中测试了相同的代码,并且可以正常工作.毫无疑问,因为这一定是图书馆的问题. 我已经使用c函数cvCapture轻松快速地打开了具有相同路径路由的avi文件. 我得到了'C:\ opencv \ opencv \ build \ x86 \ vc10 \ bin'的所有dll 包含在mi调试文件中.我也得到了tbb.dll和所有的'C:\ opencv \ opencv \ 3rdparty \ ffmpeg'内容.

I have tested the same code in a mac under snow leopard and it works. No surprises here since it must be a library issue. I have opened the avi file with the same path route using the c-function cvCapture easy and fast. I got all the dlls of 'C:\opencv\opencv\build\x86\vc10\bin' included in mi debug file. I got the tbb.dll and all the 'C:\opencv\opencv\3rdparty\ffmpeg' content included too.

这让我发疯,所以我们将不胜感激.

This is drving me crazy so any help would be appreciated.

谢谢.

推荐答案

就我而言,删除C:\Windows\System32中的所有opencv_***.dll文件后,解决了相同的问题.因此,我仅通过"%PATH%;C: \Program Files \OpenCV2.4.2\build\x86\vc10/bin"之类的路径使用dll文件.请尝试一下.

In my case, the same problem was resolved after deleting all opencv_***.dll files in C:\Windows\System32. So, I use the dll files just through the path like "%PATH%;C: \Program Files \OpenCV2.4.2\build\x86\vc10/bin". Please try it.

这篇关于Windows中的VideoCapture OpenCV 2.4.2错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆