skap
skap

Reputation: 330

OpenCV findContours causes Debug Assertion Failed at return

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.

Upvotes: 1

Views: 2931

Answers (1)

Surinder ツ
Surinder ツ

Reputation: 1788

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.

Upvotes: 1

Related Questions