opencv
assertion_error
ai_generated
true
cv::error: (-215:断言失败) !nms_iou_threshold.empty() && nms_iou_threshold > 0 && nms_iou_threshold <= 1 在函数 'NMSBoxes' 中
cv::error: (-215:Assertion failed) !nms_iou_threshold.empty() && nms_iou_threshold > 0 && nms_iou_threshold <= 1 in function 'NMSBoxes'
ID: opencv/dnn-softnms-parameter-error
88%修复率
85%置信度
1证据数
2023-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.6.0 | active | — | — | — |
| 4.7.0 | active | — | — | — |
| 4.8.1 | active | — | — | — |
| 4.9.0 | active | — | — | — |
根因分析
非极大值抑制 (NMS) 调用时使用了无效或超出范围的 IoU 阈值参数。
English
Non-maximum suppression (NMS) called with an invalid or out-of-range IoU threshold parameter.
官方文档
https://docs.opencv.org/4.x/d6/d0f/group__dnn.html解决方案
-
Ensure nms_iou_threshold is a float between 0.01 and 1.0, e.g., cv::NMSBoxes(boxes, scores, 0.5, 0.4) where 0.4 is the IoU threshold.
-
Validate the parameter before calling NMSBoxes: if (iou_threshold <= 0.0 || iou_threshold > 1.0) { iou_threshold = 0.5; }
无效尝试
常见但无效的做法:
-
Setting nms_iou_threshold to 0 to disable NMS
95% 失败
IoU threshold must be strictly greater than 0; 0 triggers the assertion.
-
Using a negative value like -0.5 for aggressive suppression
100% 失败
Negative values fail the '> 0' check in the assertion.
-
Passing a string or list instead of a float
80% 失败
The empty() check on a non-scalar type passes, but the comparison fails with type error.