Make sure Truco is launched on non-empty and CV_8UC1 only.

This is checked in the function:
3bb68212da/modules/imgproc/src/contours_truco.cpp (L621)
This commit is contained in:
Vincent Rabaud
2026-05-27 17:52:11 +02:00
parent 3bb68212da
commit 8ebcf229a1
2 changed files with 2 additions and 2 deletions

View File

@@ -649,7 +649,7 @@ void cv::findContours(InputArray _image,
}
// Fast path: RETR_LIST without hierarchy → findTRUContours (parallel contour extraction)
if (mode == RETR_LIST && !_hierarchy.needed())
if (mode == RETR_LIST && !_hierarchy.needed() && _image.type() == CV_8UC1)
{
// findTRUContours requires FOREGROUND=255; binarize=true thresholds the padded
// image in-place, avoiding an extra allocation (findContours accepts any non-zero value)

View File

@@ -618,7 +618,7 @@ void findTRUContours(InputArray _src, OutputArrayOfArrays _contours, int minSize
{
CV_INSTRUMENT_REGION();
Mat src = _src.getMat();
CV_Assert(!src.empty() && src.type() == CV_8UC1);
CV_Assert(src.type() == CV_8UC1);
// Buffer handling
cv::Mat padded;