这是我用于在Visual Studio 2015社区中打开视频文件的代码。我调试它时遇到错误。打开的视频屏幕在几分之一秒后立即关闭。
#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;
}
它完美编译但是当我调试它时..它显示以下错误:
'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).
有人可以帮我解决错误吗?
答案 0 :(得分:0)
这些都没有错误。 exited with code -1
表示它在某处返回-1。看看它的位置:你的程序确实在if(!vid.read(frame))
上返回-1。
在system("pause");
之前设置return 0
并阅读输出