2015-12-18 80 views
0

這是我用在Visual Studio 2015年社會打開一個視頻文件的代碼來打開Visual Studio中的視頻。我在調試它時遇到錯誤。打開的視頻屏幕在幾分之一秒內打開後立即關閉。無法使用OpenCV的

#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

沒有一個是錯誤的。您的文件未打開,程序返回-1並退出。 – drescherjm

+0

這是一個有效的路徑:*** 「d:\\ \\項目可視化嘗試次數\\ \\ OpenCV_try \\ OpenCV_try Dinner.avi」 *** – drescherjm

+0

你真的路徑中有2 OpenCV_try? – drescherjm

回答

0

這些都是沒有錯誤。 exited with code -1表示它在某處返回-1。看看這是什麼:你的程序確實在if(!vid.read(frame))上返回-1。

一個system("pause");return 0之前,請讀那些輸出