OpenCV崩溃 [英] OpenCV Crashes

查看:515
本文介绍了OpenCV崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2010下有一个多线程Qt程序,其中一个线程运行图像处理算法.

I have a multithread Qt program under VS2010 where one of the threads run an image processing algorithm.

我知道我的算法有效,因为我可以在控制台应用程序中很好地运行它,然后将其复制并粘贴到项目中.所有这些奇怪的错误.

I know my algorithm works because I run it fine in a console applicaiton, and I just copy and paste it in the project....then I get  all this weird errors.

代码是:

//...some stuff

leftMat = imread("M:/Desktop/PsEyeRight1.jpg",CV_LOAD_IMAGE_COLOR); cvtColor(leftMat,leftMat,CV_RGB2GRAY);      高斯模糊(leftMat,leftMat,Size(3,3),0,0,4);          阈值(leftMat,leftMat,150,255,THRESH_BINARY); outlinesLeft.clear();           architectureLeft.clear();                                                            垫轮廓图像= leftMat.clone();          findContours(contourImage,contoursLeft,hierarchyLeft,CV_RETR_LIST,CV_CHAIN_APPROX_NONE,Point(0,0));

leftMat = imread("M:/Desktop/PsEyeRight1.jpg", CV_LOAD_IMAGE_COLOR); cvtColor(leftMat, leftMat, CV_RGB2GRAY);       GaussianBlur(leftMat, leftMat, Size(3, 3), 0, 0, 4);                     threshold(leftMat, leftMat, 150, 255, THRESH_BINARY); contoursLeft.clear();            hierarchyLeft.clear();                        Mat contourImage = leftMat.clone();           findContours(contourImage, contoursLeft, hierarchyLeft, CV_RETR_LIST, CV_CHAIN_APPROX_NONE, Point(0, 0));

//...某些东西

//...some stuff

当执行命中findContours()时,我在SARA.exe中的"0x100a9985(opencv_core246d.dll)处未处理的异常"为"未处理的异常:0xC00000FD:堆栈溢出.".

When the execution hits findContours(), I get a StackOverflow as "Unhandled exception at 0x100a9985 (opencv_core246d.dll) in SARA.exe: 0xC00000FD: Stack overflow."

所以我要配置属性>连结器>系统>堆叠储备大小,并将其更改为" 100000000 " (100MB)

So I to Configuration Properties > Linker > System > Stack Reserve Size and change it to "100000000" (100MB)

这次错误更改... cvtColor()崩溃,错误为< SARA.exe中0x774fc41f处未处理的异常:Microsoft C ++异常:内存位置0x1f63ad64处的并发:: scheduler_resource_allocation_error. " 在concrt.h上,如果我删除cvtColor,则Threshold()会以相同的方式崩溃.

This time the error changes... cvtColor() crashes with the error "Unhandled exception at 0x774fc41f in SARA.exe: Microsoft C++ exception: Concurrency::scheduler_resource_allocation_error at memory location 0x1f63ad64.." at concrt.h and if I remove cvtColor, Threshold() crashes the same way.

我将其编译为/MDd(多线程调试DLL),并且还在OpenCV上运行CMake以清除选项" BUILD_WITH_STATIC_CRT ",然后再次编译了openCV,并且我看到的所有项目都有/MDd 也是

I am compiling it as /MDd (Multi-Threaded Debug DLL) and I have also run CMake on OpenCV to clear the option "BUILD_WITH_STATIC_CRT", and I compiled openCV again, and the projects that I saw all had the /MDd  as well.

有人猜到发生了什么事吗?

Does anyone has a guess about what is going on?



推荐答案

Ad_Matay

Hi Ad_Matay,

在大多数情况下,堆栈溢出表示代码中的错误,而扩展堆栈保留大小将无法解决这些错误.它只会隐藏问题,或将一个错误换成另一个. scheduler_resource_allocation_error可能是由许多不同的原因引起的 并且表示系统无法分配CriticalSection/Event/等资源.就像stack_over_flow一样,除非代码有问题,否则它不应正常发生.您可能想捕获此异常,然后 调用get_error_code()从Windows API获取错误代码.

In most of the cases, stack over flow indicates bugs in the code, which won't be solved by expanding stack reserve size. It will only hide the problem, or trade one error to another. scheduler_resource_allocation_error can be caused by many different reasons and it indicates that system fails to allocate resources like CriticalSection / Event / etc. It, just like stack_over_flow, should not happen normally, unless there is something wrong with the code . You may want to catch this exception and call get_error_code() to get the error code from windows API.


这篇关于OpenCV崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆