zhangzengfei
2024-05-07 5572a775f44cefed8c8c14da29ecef11c5d3593e
修复以图搜图出现多个相同目标的bug
1个文件已修改
30 ■■■■■ 已修改文件
compare/compare.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 添加小区外的关联关系, 下次优先比对
        }
    }