-215 opencv assertion_error ai_generated true

cv::error: (-215:Assertion failed) group_threshold > 0 in function 'groupRectangles'

ID: opencv/group-rectangles-empty

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2023-06-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4.5.2 active
4.7.0 active
4.9.0 active

Root Cause

The group_threshold parameter passed to cv::groupRectangles must be positive; a non-positive value causes the function to reject the input.

generic

中文

传递给 cv::groupRectangles 的 group_threshold 参数必须为正数;非正数值会导致函数拒绝输入。

Official Documentation

https://docs.opencv.org/4.x/d5/d54/group__objdetect.html#ga3d6b9e7b8c0f5a1b9e8f1f0a5b7c3e1f

Workarounds

  1. 100% success Set group_threshold to 1 or higher: cv::groupRectangles(rectList, weights, 1, 0.2);
    Set group_threshold to 1 or higher: cv::groupRectangles(rectList, weights, 1, 0.2);
  2. 95% success If grouping is not needed, use NMS separately (e.g., cv::dnn::NMSBoxes) instead of groupRectangles.
    If grouping is not needed, use NMS separately (e.g., cv::dnn::NMSBoxes) instead of groupRectangles.

中文步骤

  1. 将 group_threshold 设置为 1 或更高:cv::groupRectangles(rectList, weights, 1, 0.2);
  2. 如果不需要分组,使用单独的 NMS(例如 cv::dnn::NMSBoxes)代替 groupRectangles。

Dead Ends

Common approaches that don't work:

  1. 100% fail

    The function explicitly requires group_threshold > 0; zero or negative values trigger the assertion error. Use cv::partition or manual merging instead.

  2. 80% fail

    The assertion checks group_threshold, not the rectangle list; an empty list may cause a different error, but the threshold check still fails first.