在OpenCV_core310.dll中使用findContours函数时,OpenCV引发未处理的异常
OpenCV throwing Unhandled Exception when using the findContours function in opencv_core310.dll
我正在编写一个函数,该函数可以查找并返回给系统的任何图像的中心(它们大多是圆形对象(
当使用OpenCV3.10运行findContours方法时,该函数会在向量类中引发错误。这是我的代码:
cv::Mat image = next_image(cam);
cv::Mat gray; cv::Mat thresh; cv::Mat conv;
cv::Mat canny_output; cv::Mat nImg;
std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> hierarchy;
//threshold and contour the image
cv::cvtColor(image, conv, cv::COLOR_GRAY2RGB);
cv::cvtColor(conv, gray, CV_BGR2GRAY);
cv::blur(gray, gray, cv::Size(5, 5));
cv::threshold(gray, thresh, 60, 355, cv::THRESH_BINARY);
cv::findContours(thresh, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
当Visual Studio命中findContours(特别是在它使用的矢量文件中(时,抛出Exception Unhandled,消息显示
Laser_Tracking.exe中0x5825AF78(opencv_core310.dll(处未处理的异常:0xC0000005:读取位置0xDDDDDDD9的访问冲突。
我目前正在使用Visual Studios 2019运行OpenCV。
我测试并发现了您的问题。这似乎是OpenCV配置的一个问题。我的环境也是VS2019和OpenCV 3.1.0
在Linker的配置中,我添加了opencv.world310.lib和opencv_world310d.lib。也就是说,我添加的是该库的发布和调试版本,并且我是在调试模式下运行的,这可能对其他函数没有影响,但findContours((函数不同,所以我更改了这两个库的顺序,或者我们可以删除其中一个库,这取决于您自己的模式。
这是配置Visual Studio时留下的问题。由于没有错误报告,因此没有发现问题。在这种情况下,我们需要养成良好的配置习惯。
我真的不知道发生了什么,但在我的情况下,我只是将函数进一步移动了几行,未处理的异常已经消失,当我返回时,错误再次发生。
相关文章:
- 在c++中实现LinkedList时,应出现未处理的错误
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- 在信号处理程序中捕获C++未处理的异常并恢复应用程序
- 在C++程序中使用的迭代器中未处理的异常
- 在 ******.exe 中0x00000000772CA267 (ntdll.dll) 处未处理的异常:0xC0000
- 在OpenCV_core310.dll中使用findContours函数时,OpenCV引发未处理的异常
- opencv中项目出现未处理的异常
- c++ OpenCV approxPolyDP 导致未处理的异常
- OpenCV 写入文件时未处理的异常
- OpenCV 拼接,C++ - 未处理的异常
- OpenCV未处理的异常错误
- 在opencv 3.1中运行示例代码时出现未处理的异常
- 未处理的 OpenCV - cvReleaseCapture 和 cvReleaseImage - C++
- opencv帧差异未处理的异常
- 使用opencv检索视频帧-未处理的异常
- 使用OpenCV库的c++中未处理的异常
- OpenCV 代码中'System.Runtime.InteropServices.SEHException'未处理的异常
- 未处理的异常绘图不使用 OpenCV 2.4.3 C++接口中的 fillPoly 凸多边形
- OpenCv 2.4.8 VideoCapture 上未处理的异常
- OpenCV addweighted函数在第4次循环后给出一个未处理的异常