-215
opencv
assertion_error
ai_generated
true
cv::error: (-215:断言失败) group_threshold > 0 在函数 'groupRectangles' 中
cv::error: (-215:Assertion failed) group_threshold > 0 in function 'groupRectangles'
ID: opencv/group-rectangles-empty
90%修复率
85%置信度
1证据数
2023-06-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.2 | active | — | — | — |
| 4.7.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
根因分析
传递给 cv::groupRectangles 的 group_threshold 参数必须为正数;非正数值会导致函数拒绝输入。
English
The group_threshold parameter passed to cv::groupRectangles must be positive; a non-positive value causes the function to reject the input.
官方文档
https://docs.opencv.org/4.x/d5/d54/group__objdetect.html#ga3d6b9e7b8c0f5a1b9e8f1f0a5b7c3e1f解决方案
-
将 group_threshold 设置为 1 或更高:cv::groupRectangles(rectList, weights, 1, 0.2);
-
如果不需要分组,使用单独的 NMS(例如 cv::dnn::NMSBoxes)代替 groupRectangles。
无效尝试
常见但无效的做法:
-
100% 失败
The function explicitly requires group_threshold > 0; zero or negative values trigger the assertion error. Use cv::partition or manual merging instead.
-
80% 失败
The assertion checks group_threshold, not the rectangle list; an empty list may cause a different error, but the threshold check still fails first.