Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assertion failure within findContours / _OutputArray::create

I am currently trying to use the findContours function as presented in the tutorials.

However, it fails on the assertion..

CV_Assert( i < 0 );

..on row 1422 of matrix.cpp (based on release 248, corresponds to rows 2133 and onwards in current master branch), within the function

_OutputArray::create(int, const int *, int, int, bool, int)

There are several of the same assertion querying i to be negative, even if i is not used where the program flows if I move the debug pointer beyond the assertion each time.

In contours.cpp, function cv::findContours(InputOutputArray, OutputArrayOfArrays, OutputArray, int, int, Point) there is a for-loop on lines 1722 to 1730 which calls..

_contours.create((int)c->total, 1, CV_32SC2, i, true);

..each iteration. i goes from 0 to total (amount of found contours?), triggering said assertion each time because the requested matrix-type demands it or something. allowTransposed is set to true and i is 0 or positive, making it call the specific/default constructor mentioned above. k or kind value is also set to MAT (65536)

Even if I move the debug flow to skip that assertion it will fail on an assertion later on within the following line in cv::findContours:

Mat ci = _contours.getMat(i);

I am guessing this means that the matrices are not created properly/as intended to be used by the findContours function.

Are there any further prerequisites for the input image, or what else could be the problem? I have managed to get several other filters to work with little to no trouble compared to this (Canny, cornerHarris, threshold, etc).

Assertion failure within findContours / _OutputArray::create

I am currently trying to use the findContours function as presented in the tutorials.

However, it fails on the assertion..

CV_Assert( i < 0 );

..on row 1422 of matrix.cpp (based on release 248, corresponds to rows 2133 and onwards in current master branch), within the function

_OutputArray::create(int, const int *, int, int, bool, int)

There are several of the same assertion querying i to be negative, even if i is not used where the program flows if I move the debug pointer beyond the assertion each time.

In contours.cpp, function cv::findContours(InputOutputArray, OutputArrayOfArrays, OutputArray, int, int, Point) there is a for-loop on lines 1722 to 1730 which calls..

_contours.create((int)c->total, 1, CV_32SC2, i, true);

..each iteration. i goes from 0 to total (amount of found contours?), triggering said assertion each time because the requested matrix-type demands it or something. allowTransposed is set to true and i is 0 or positive, making it call the specific/default constructor mentioned above. k or kind value is also set to MAT (65536)

Even if I move the debug flow to skip that assertion it will fail on an assertion later on within the following line in cv::findContours:

Mat ci = _contours.getMat(i);

I am guessing this means that the matrices are not created properly/as intended to be used by the findContours function.

Are there any further prerequisites for the input image, or what else could be the problem? I have managed to get several other filters to work with little to no trouble compared to this (Canny, cornerHarris, threshold, etc).

Input image is single-channel 1 byte per pixel (type CV_8UC1).

Assertion failure within findContours / _OutputArray::create

I am currently trying to use the findContours function as presented in the tutorials.

However, it fails on the assertion..

CV_Assert( i < 0 );

..on row 1422 of matrix.cpp (based on release 248, corresponds to rows 2133 and onwards in current master branch), within the function

_OutputArray::create(int, const int *, int, int, bool, int)

There are several of the same assertion querying i to be negative, even if i is not used where the program flows if I move the debug pointer beyond the assertion each time.

In contours.cpp, function cv::findContours(InputOutputArray, OutputArrayOfArrays, OutputArray, int, int, Point) there is a for-loop on lines 1722 to 1730 which calls..

_contours.create((int)c->total, 1, CV_32SC2, i, true);

..each iteration. i goes from 0 to total (amount of found contours?), triggering said assertion each time because the requested matrix-type demands it or something. allowTransposed is set to true and i is 0 or positive, making it call the specific/default constructor mentioned above. k or kind value is also set to MAT (65536)

Even if I move the debug flow to skip that assertion it will fail on an assertion later on within the following line in cv::findContours:

Mat ci = _contours.getMat(i);

I am guessing this means that the matrices are not created properly/as intended to be used by the findContours function.

Are there any further prerequisites for the input image, or what else could be the problem? I have managed to get several other filters to work with little to no trouble compared to this (Canny, cornerHarris, threshold, etc).

Input image is single-channel 1 byte per pixel (type CV_8UC1).