# cv::error: (-215:断言失败) !nms_iou_threshold.empty() && nms_iou_threshold > 0 && nms_iou_threshold <= 1 在函数 'NMSBoxes' 中

- **ID:** `opencv/dnn-softnms-parameter-error`
- **领域:** opencv
- **类别:** assertion_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

非极大值抑制 (NMS) 调用时使用了无效或超出范围的 IoU 阈值参数。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.1 | active | — | — |
| 4.9.0 | active | — | — |

## 解决方案

1. ```
   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.
   ```
2. ```
   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** — IoU threshold must be strictly greater than 0; 0 triggers the assertion. (95% 失败率)
- **Using a negative value like -0.5 for aggressive suppression** — Negative values fail the '> 0' check in the assertion. (100% 失败率)
- **Passing a string or list instead of a float** — The empty() check on a non-scalar type passes, but the comparison fails with type error. (80% 失败率)
