OpenCV findContours 导致调试断言在返回时失败

OpenCV findContours causes Debug Assertion Failed at return

本文关键字:返回 失败 断言 调试 findContours OpenCV      更新时间:2023-10-16

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

#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;
}

在发布模式下一切都正常,我不明白为什么它在调试模式下不能正常工作。它会导致调试断言在return 0;失败

(表达式 : _pFirstBlock == pHead)。

我想轮廓有问题。

非常感谢您的帮助。

在"

属性"下> C++>"运行时">代码生成:
如果 MSVC 运行时库设置为多线程调试 DLL (/MDd),则这没有问题(它工作正常)。

如果 MSVC 运行时库设置为多线程调试 (/MTd),则它将引发此错误,可以通过以下说明修复此错误。