OpenCV findContours会导致Debug Assertion在返回时失败 [英] OpenCV findContours causes Debug Assertion Failed at return

查看:1440
本文介绍了OpenCV findContours会导致Debug Assertion在返回时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2013上编程,使用OpenCV v 2.4.8。
这是我的代码

  #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屋!

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