C++ 无法使用openCV在Visual Studio中打开视频
这是我用来在Visual Studio 2015社区中打开视频文件的代码。我调试它们时会出错。打开的视频屏幕在几秒钟内打开后立即关闭C++ 无法使用openCV在Visual Studio中打开视频,c++,opencv,C++,Opencv,这是我用来在Visual Studio 2015社区中打开视频文件的代码。我调试它们时会出错。打开的视频屏幕在几秒钟内打开后立即关闭 #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc_c.h>
//#include "opencv2/contrib/contrib.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace cv;
using namespace std;
int main(int argc, char **argv)
{
Mat frame;
VideoCapture vid("D:\\Projects\\Visual Tries\\OpenCV_try\\OpenCV_try\\Dinner.avi");
if (!vid.isOpened())
return -1;
int fps = (int)vid.get(CAP_PROP_FPS);
namedWindow("Showing Film");
while (1)
{
if (!vid.read(frame))
break;
imshow("Showing Film", frame);
if (waitKey(1000 / fps) >= 0)
break;
}
waitKey();
return 0;
}
有人能帮我解决这个错误吗?这些都不是错误<代码>与代码-1一起退出意味着它在某处返回了-1。看看它在哪里:如果(!vid.read(frame)),程序确实会在
上返回-1
制作一个系统(“暂停”)在返回0
并读取输出之前这些都不是错误。您的文件未打开,因此程序返回-1并退出。这是一个有效的路径:“D:\\Projects\\Visual Tries\\OpenCV\u try\\OpenCV\u try\\Dinner.avi”路径中是否确实有2个OpenCV\u try?您的程序是否有权访问ooencb\u ffmpeg dll文件?例如,但它位于工作目录或path变量中。您可以尝试使用不同编解码器的不同视频文件和/或为我们上载视频文件吗?
'OpenCV_try.exe' (Win32): Loaded 'C:\opencv\build\x64\vc12\bin\opencv_ffmpeg300_64.dll'. Module was built without symbols.
The thread 0x2dc0 has exited with code -1 (0xffffffff).
The thread 0x514 has exited with code -1 (0xffffffff).
The thread 0x2184 has exited with code -1 (0xffffffff).
The program '[1616] OpenCV_try.exe' has exited with code -1 (0xffffffff).