简体   繁体   English

使用 Visual Studio 2015 运行 OpenCV 时无法打开视频文件

[英]OpenCV cannot open video file when run with Visual Studio 2015

I want to open a video file in my OpenCV C++ application with我想在我的 OpenCV C++ 应用程序中打开一个视频文件

cap.open("../../data/Example.MP4");

but somehow when I run the application in Visual Studio 2015 (I've tried both Debug & Release mode), it cannot find the file.但不知何故,当我在 Visual Studio 2015 中运行应用程序时(我已经尝试了调试和发布模式),它找不到该文件。

Surprisingly if I run the application by just double clicking the .exe in Windows Explorer, everything works fine and the video file opens as desired.令人惊讶的是,如果我通过双击 Windows 资源管理器中的 .exe 来运行应用程序,一切正常,视频文件会根据需要打开。

Does somebody know why Visual Studio cannot find the file?有人知道为什么 Visual Studio 找不到文件吗?

Thanks a lot!非常感谢!

The problem is related to the Project's Working directory, on Visual Studio.该问题与 Visual Studio 上项目的工作目录有关。 From inside it, it isn't finding the file...从里面,它没有找到文件......

Go to Project Properties, Debugging.转到项目属性,调试。 There you will see, by default, that the Working directory is your project directory.在那里你会看到,默认情况下,工作目录是你的项目目录。 Change it to $(OutDir) and your path should be fixed.将其更改为$(OutDir)并且您的路径应该是固定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM