opencv
assertion_error
ai_generated
true
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%Fix Rate
85%Confidence
1Evidence
2023-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.6.0 | active | — | — | — |
| 4.7.0 | active | — | — | — |
| 4.8.1 | active | — | — | — |
| 4.9.0 | active | — | — | — |
Root Cause
Non-maximum suppression (NMS) called with an invalid or out-of-range IoU threshold parameter.
generic中文
非极大值抑制 (NMS) 调用时使用了无效或超出范围的 IoU 阈值参数。
Official Documentation
https://docs.opencv.org/4.x/d6/d0f/group__dnn.htmlWorkarounds
-
95% success 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.
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.
-
90% success Validate the parameter before calling NMSBoxes: if (iou_threshold <= 0.0 || iou_threshold > 1.0) { iou_threshold = 0.5; }
Validate the parameter before calling NMSBoxes: if (iou_threshold <= 0.0 || iou_threshold > 1.0) { iou_threshold = 0.5; }
中文步骤
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; }
Dead Ends
Common approaches that don't work:
-
Setting nms_iou_threshold to 0 to disable NMS
95% fail
IoU threshold must be strictly greater than 0; 0 triggers the assertion.
-
Using a negative value like -0.5 for aggressive suppression
100% fail
Negative values fail the '> 0' check in the assertion.
-
Passing a string or list instead of a float
80% fail
The empty() check on a non-scalar type passes, but the comparison fails with type error.