2014-11-16 197 views
0

我有用於Windows的QT Creator 3.2.2。我正在使用mingw-x64和gcc/g ++ - 4.9.1作爲我的編譯器/調試器。 我用Cmake來構建庫。嘗試運行OpenCV程序時,Qt Creator崩潰。 [ntdll.dll崩潰]

目前,正在嘗試運行這段代碼:

#include <core/cvstd.hpp> 
#include <core/mat.hpp> 
#include <core/types.hpp> 
#include <core.hpp> 
#include <cstdlib> 
#include <highgui.hpp> 
#include <imgproc.hpp> 
#include <iostream> 
#include <sys/types.h> 
#include <vector> 
#include <video/background_segm.hpp> 

using namespace cv; 

int main(int argc, char *argv[]) 
{ 
    Mat image = imread("C:\\Users\\John\\Desktop\\Random\\QtTrySimple\\Try\\bgm.jpeg"); 
    namedWindow("LOL"); 
    imshow("LOL", image);  
} 

但程序崩潰了「嚴重錯誤檢測c0000374」。據我所知,這個錯誤表明堆上的內存泄漏。

而且,這裏是堆棧崩潰時:

0 ntdll!RtlUnhandledExceptionFilter C:\Windows\SYSTEM32\ntdll.dll  0x775b40d0 
1 ntdll!EtwEnumerateProcessRegGuids C:\Windows\SYSTEM32\ntdll.dll  0x775b4746 
2 ntdll!RtlQueryProcessLockInformation C:\Windows\SYSTEM32\ntdll.dll  0x775b5952 
3 ntdll!RtlLogStackBackTrace C:\Windows\SYSTEM32\ntdll.dll  0x775b7604 
4 ntdll!RtlIsDosDeviceName_U C:\Windows\SYSTEM32\ntdll.dll  0x7755dc47 

我不知道爲什麼內存泄漏發生。但是我猜測這與使用Windows API的OpenCV顯示一個顯示窗口有關。

編輯:圖像不是空的。我正在檢查代碼中的空白圖像。

回答

1

由於缺乏信息,我只能猜測這是cv::imread()返回一個空的cv::Mat的明顯情況。這是由於它無法找到/打開文件:

Mat image = imread("C:\\Users\\John\\Desktop\\Random\\QtTrySimple\\Try\\bgm.jpeg"); 
if (image.empty()) 
{ 
    std::cout << "!!! Failed to open image" << std::endl; 
    return -1;  
} 

imshow("LOL", image);  
waitKey(0); 

在這種情況下,飛機墜毀是因爲imshow()被調用,以顯示...什麼都沒有。

不要忘了在最後打電話waitKey(0),否則窗口會立即關閉,您將無法看到它。

+0

圖像不是空的,那是我在程序崩潰時嘗試的第一件事。另外如果圖像是空的,你仍然嘗試顯示它,OpenCV通常會拋出一個斷言錯誤。 –

+0

然後這可能是與應用程序鏈接的庫有關的問題。但那是我無法幫助你的(由於缺乏信息)。我很肯定你可以在這個網站上搜索找到答案。這裏有很多類似的問題。 – karlphillip