OpenCV findContours会导致Debug Assertion在返回时失败 [英] OpenCV findContours causes Debug Assertion Failed at return
问题描述
这是我的代码
#define _CRT_SECURE_NO_WARNINGS
#include< cv.h> ;
#include< highgui.h>
int main(int argc,char * argv [])
{
cv :: Mat image = cv :: imread(argv [1],0);
image = image> 100;
std :: vector< std :: vector< cv :: Point> >轮廓;
cv :: findContours(图像,轮廓,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
return 0;
}
一切都在发布模式下确定,我不明白为什么在调试模式下正常工作。它导致调试断言失败在 return 0;
(表达式:_pFirstBlock ==
我想像轮廓有些错误。
感谢您的帮助。
在属性> C ++>代码生成>运行时语言:
如果MSVC运行时库设置为多线程调试DLL(/ MDd),那么这没有问题(它可以正常工作)。
如果MSVC运行时库设置为Multi -threaded Debug(/ MTd),那么它会抛出这个错误,这可以用以下指示来修复。
I am programming on Visual Studio 2013, using OpenCV v 2.4.8. Here is my code
#define _CRT_SECURE_NO_WARNINGS
#include <cv.h>
#include <highgui.h>
int main(int argc, char* argv[])
{
cv::Mat image = cv::imread(argv[1], 0);
image = image > 100;
std::vector<std::vector<cv::Point> > contours;
cv::findContours(image, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
return 0;
}
Everything is Ok in release mode, and I can't understand why it doesn't work normal in debug mode. It causes debug assertion failed at return 0;
(Expression : _pFirstBlock == pHead).
I suppose something is wrong with contours.
Many thanks in assistance.
Under Property > C++ > code generation > Runtime libarary:
If the MSVC Runtime library is set to Multi-threaded Debug DLL (/MDd), then this is no problem (it works fine).
If the MSVC Runtime library is set to Multi-threaded Debug (/MTd), then it will throw this error, which can be fixed with the following instructions.
这篇关于OpenCV findContours会导致Debug Assertion在返回时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!