From 8ebcf229a1fb6fc95fea3cc7277925df76d476c3 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Wed, 27 May 2026 17:52:11 +0200 Subject: [PATCH] Make sure Truco is launched on non-empty and CV_8UC1 only. This is checked in the function: https://github.com/opencv/opencv/blob/3bb68212dac2e1c42e7910de9daf3a0766eaead8/modules/imgproc/src/contours_truco.cpp#L621 --- modules/imgproc/src/contours_new.cpp | 2 +- modules/imgproc/src/contours_truco.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/contours_new.cpp b/modules/imgproc/src/contours_new.cpp index 67bc7aa2dd..ed48f1e1ff 100644 --- a/modules/imgproc/src/contours_new.cpp +++ b/modules/imgproc/src/contours_new.cpp @@ -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) diff --git a/modules/imgproc/src/contours_truco.cpp b/modules/imgproc/src/contours_truco.cpp index a4d3c0cce0..94f1f332f6 100644 --- a/modules/imgproc/src/contours_truco.cpp +++ b/modules/imgproc/src/contours_truco.cpp @@ -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;