首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Qt创建器在尝试运行OpenCV程序时崩溃。[ntdll.dll崩溃]

Qt创建器在尝试运行OpenCV程序时崩溃。[ntdll.dll崩溃]
EN

Stack Overflow用户
提问于 2014-11-17 07:30:32
回答 1查看 861关注 0票数 0

我有QT Creator 3.2.2 for windows。我使用mingw-x64和gcc/g++ - 4.9.1作为我的编译器/调试器。我使用Cmake来构建这些库。

目前,我正在尝试运行以下代码:

代码语言:javascript
运行
复制
#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);    
}

但是程序崩溃,并显示“Critical error detected c0000374”。据我所知,这个错误表明堆上存在内存泄漏。

另外,下面是堆栈崩溃时的情况:

代码语言:javascript
运行
复制
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  

我不知道为什么会发生内存泄漏。但我猜这与OpenCV使用windows API来显示窗口有关。

编辑:图像不是空的。我正在检查代码中是否有空图像。

EN

回答 1

Stack Overflow用户

发布于 2014-11-17 07:35:43

由于缺乏信息,我只能猜测这是cv::imread()返回空cv::Mat的明显情况。当它无法找到/打开文件时,就会发生这种情况:

代码语言:javascript
运行
复制
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),否则窗口将立即关闭,您将无法看到它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26963351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档