2012-03-26 48 views
1

我的代碼編譯正常,但當我調試,這是我所得到的:C++和OpenCV在Visual Studio中退出,代碼爲-1(0xffffffff的)錯誤

'Proj_OpenCV.exe': Loaded 'C:\Users\Saher\Documents\Visual Studio 2008\Projects\Proj_OpenCV\Debug\Proj_OpenCV.exe', Symbols loaded. 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Users\Saher\Downloads\OpenCV2.3\build\x86\vc9\bin\opencv_core230.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcp90.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Users\Saher\Downloads\OpenCV2.3\build\x86\vc9\bin\opencv_highgui230.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\user32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\avifil32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\msacm32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\msvfw32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\avicap32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\version.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcp90d.dll', Symbols loaded. 
'Proj_OpenCV.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded. 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll' 
'Proj_OpenCV.exe': Loaded 'C:\Program Files (x86)\McAfee\SiteAdvisor\sahook.dll' 
The program '[5748] Proj_OpenCV.exe: Native' has exited with code -1 (0xffffffff). 

我的代碼是從OpenCV tutorial page

如下
#include <opencv2/core/core.hpp> 
#include <opencv2/highgui/highgui.hpp> 
#include <iostream> 

using namespace cv; 
using namespace std; 

int main(int argc, char** argv) 
{ 



    if(argc != 2) 
    { 
    cout <<" Usage: display_image ImageToLoadAndDisplay" << endl; 
    return -1; 
    } 

    Mat image; 
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file 

    if(! image.data)        // Check for invalid input 
    { 
     cout << "Could not open or find the image" << std::endl ; 
     return -1; 
    } 

    namedWindow("Display window", CV_WINDOW_AUTOSIZE);// Create a window for display. 
    imshow("Display window", image);     // Show our image inside it. 

    waitKey(0);           // Wait for a keystroke in the window 


    return 0; 
} 

任何與此錯誤的幫助以及如何解決它將不勝感激。

+0

你可以說它在哪一行退出? – Alex 2012-03-26 07:52:40

+0

它沒有說明具體的行。這似乎是一個命令參數問題。 – 2012-03-26 18:45:30

回答

2
  • 應用程序應該從CMD線
  • 您需要通過形象的名稱在cmd行參數,當你啓動這個應用程序來執行:display_image.exe test.jpg

或者,如果你正在從Visual Studio執行它,請確保你設置的圖像文件名爲:

Project Properties > Configuration Properties > Debugging > Command Arguments 
+0

我已將項目屬性設置爲C:\ Users \ Saher \ Documents \ Visual Studio 2008 \ Projects \ Proj_OpenCV \ mypic.jpg但我仍然收到相同的錯誤。可能是什麼問題? – 2012-03-26 18:49:30

+0

如果我想嘗試命令行,編譯後如何才能到達exe文件? – 2012-03-26 18:50:14

+0

沒關係它的工作,我不得不只是在命令參數中的圖像名稱,並正確設置工作目錄。 – 2012-03-26 18:55:36

相關問題