Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenCV VideoCapture在Visual Studio之外不工作_C++_Visual Studio 2008_Video_Opencv - Fatal编程技术网

C++ OpenCV VideoCapture在Visual Studio之外不工作

C++ OpenCV VideoCapture在Visual Studio之外不工作,c++,visual-studio-2008,video,opencv,C++,Visual Studio 2008,Video,Opencv,我使用的是VideoCapture(文件名)从文件加载视频。当我在VisualStudio(发布模式)中运行该程序时,它工作正常,可以像我预期的那样加载视频。当我在visual studio之外运行时(通过双击资源管理器目录中的图标),无法找到视频,捕获设备返回null,即使它是相同的文件,并且路径是硬编码和绝对的 有什么想法吗 更新:还尝试使用旧的CvCapture*和相同的错误 更新6/19: 下面是一些示例代码 #include "opencv2/highgui/highgui.hpp"

我使用的是
VideoCapture(文件名)
从文件加载视频。当我在VisualStudio(发布模式)中运行该程序时,它工作正常,可以像我预期的那样加载视频。当我在visual studio之外运行时(通过双击资源管理器目录中的图标),无法找到视频,捕获设备返回null,即使它是相同的文件,并且路径是硬编码和绝对的

有什么想法吗

更新:还尝试使用旧的CvCapture*和相同的错误

更新6/19:

下面是一些示例代码

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char** args)
{
    const char* filename = "c:/testvideo.wmv";

    //Check to see if we can see the file
    FILE* myFile = fopen(filename, "r");
    if (myFile)
        cout<<"0: Found file"<<endl;
    else
        cout<<"0: File not found"<<endl;

    //First use the openCV new way of doing it
    VideoCapture capture1(filename);

    if (capture1.isOpened())
        cout<<"1: Opened the video successfully"<<endl;
    else
        cout<<"1: Could not open the video"<<endl;

    //Second, try the old way
    CvCapture* capture2 = cvCaptureFromFile(filename);
    if (capture2)
        cout<<"2: Opened the video successfully"<<endl;
    else
        cout<<"2: Could not open the video"<<endl;

    //Pause
    char c;
    cin>>c;

    return 0;
}
从文件系统中的exe运行(双击)我得到:

我只编译了一次,所以目录中只有一个exe。。。
我还尝试过在Visual Studio中显示帧,因此我知道它认为视频已打开时实际上正在读取视频。

检查所需的所有DLL是否与您的exe(或路径)位于同一文件夹中。

确保使用绝对视频路径(如果没有,请尝试将视频复制到exe路径)如果您使用的是释放模式,则所有DLL都必须处于释放模式。如果你给我发一个小项目,也许我会解决这个问题。

我不是说我不相信你,而是说路径是硬编码和绝对的?硬编码的,比如不作为运行时参数传递,而是在编译时写入exe。绝对值,如从驱动器开始,而不是相对于正在运行的目录;std::coutLol我知道这些术语的意思,我的意思是,如果您忽略了某些内容,可能会显示一些代码或更好地描述任何运行时错误。一个猜测是检查编译器输出,以查看您是否正在运行最新的exe,而不是来自其他地方的旧版本。将所有OpenCV DLL复制到与exe相同的目录中。不走运。
0: File Found
1: Opened the video successfully
2: Opened the video successfully
0: File Found
1: Could not open the video
2: Could not open the video