This commit is contained in:
2026-09-01 17:47:03 +08:00
parent ed6bfdc460
commit 046ce2f1ab
10 changed files with 185 additions and 67 deletions
+19
View File
@@ -30,6 +30,25 @@ void main() {
expect(result[0].score, greaterThan(0.5));
});
test('bigBox_containsSmallBox_deduped', () {
// 同目标一大一小两框:标准 IoU = 0.04/0.13 ≈ 0.31 < 0.45 会漏,
// minIoU = inter/小框 = 1 必须去重(2026-09-01 用户实测:单模型也有重叠框)
final a = box(0.3, 0.3, 0.5, 0.5, 0.8); // 小框 0.2x0.2
final b = box(0.25, 0.25, 0.55, 0.55, 0.6); // 大框 0.3x0.3 套住小框
final result = nms([a, b], 0.45);
expect(result.length, 1);
expect(result[0].score, 0.8);
});
test('partiallyOverlapping_sameTarget_deduped', () {
// 标准 IoU = 0.075/0.195 ≈ 0.385 < 0.45 会漏;minIoU = 0.075/0.09 ≈ 0.83
final a = box(0.1, 0.1, 0.4, 0.4, 0.9); // 0.3x0.3
final b = box(0.15, 0.1, 0.55, 0.4, 0.5); // 0.4x0.3,与 a 重叠 0.25x0.3
final result = nms([a, b], 0.45);
expect(result.length, 1);
expect(result[0].score, 0.9);
});
test('iou_nonOverlapping_isZero', () {
final a = box(0.0, 0.0, 0.2, 0.2, 1);
final b = box(0.8, 0.8, 1.0, 1.0, 1);