From 5572a775f44cefed8c8c14da29ecef11c5d3593e Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 07 五月 2024 16:52:11 +0800
Subject: [PATCH] 修复以图搜图出现多个相同目标的bug

---
 compare/compare.go |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/compare/compare.go b/compare/compare.go
index ae83818..59f989a 100644
--- a/compare/compare.go
+++ b/compare/compare.go
@@ -40,7 +40,19 @@
 			if _, ok := cache.CacheMap.Area[id]; ok {
 				targets := cache.CacheMap.Area[id].Walk(DoSdkCompare, floatFeat, baseScore)
 				if len(targets) > 0 {
-					scResult.CompareResult = append(scResult.CompareResult, targets...)
+					// 姣斿缁撴灉鍘婚噸, 鍚屼竴涓汉鍒拌杩囧涓皬鍖�, 缂撳瓨鏁版嵁鍐呬細鏈夊鏉¤褰�
+					for idx, t := range targets {
+						var isRepeat bool
+						for _, r := range scResult.CompareResult {
+							if t.Id == r.Id {
+								isRepeat = true
+								break
+							}
+						}
+						if !isRepeat {
+							scResult.CompareResult = append(scResult.CompareResult, targets[idx])
+						}
+					}
 				}
 
 				walkedArea[id] = struct{}{}
@@ -64,7 +76,21 @@
 
 		targets := val.Walk(DoSdkCompare, floatFeat, baseScore)
 		if len(targets) > 0 {
-			scResult.CompareResult = append(scResult.CompareResult, targets...)
+			if len(targets) > 0 {
+				// 姣斿缁撴灉鍘婚噸, 鍚屼竴涓汉鍒拌杩囧涓皬鍖�, 缂撳瓨鏁版嵁鍐呬細鏈夊鏉¤褰�
+				for idx, t := range targets {
+					var isRepeat bool
+					for _, r := range scResult.CompareResult {
+						if t.Id == r.Id {
+							isRepeat = true
+							break
+						}
+					}
+					if !isRepeat {
+						scResult.CompareResult = append(scResult.CompareResult, targets[idx])
+					}
+				}
+			}
 			// todo 娣诲姞灏忓尯澶栫殑鍏宠仈鍏崇郴, 涓嬫浼樺厛姣斿
 		}
 	}

--
Gitblit v1.8.0