| | |
| | | |
| | | import ( |
| | | "basic.com/pubsub/protomsg.git" |
| | | "sdkCompare/db" |
| | | "sync" |
| | | //"encoding/json" |
| | | //"fmt" |
| | |
| | | value interface{} |
| | | } |
| | | |
| | | func (s *ShardMap) Walk(wf wfOp, sourceFea []byte, baseScore float32, isWebComp bool, target string) (targets []*protomsg.SdkCompareEach) { |
| | | func (s *ShardMap) Walk(wf wfOp, sourceFea []byte, baseScore float32) (targets []*protomsg.SdkCompareEach) { |
| | | var wg sync.WaitGroup |
| | | var lock sync.Mutex |
| | | for _, si := range s.shards { |
| | |
| | | |
| | | wg.Add(1) |
| | | |
| | | go func(st *shardItem, fw wfOp, sf []byte, baseSec float32, isWeb bool) { |
| | | go func(st *shardItem, fw wfOp, sf []byte, baseSec float32) { |
| | | defer wg.Done() |
| | | for _, feature := range st.data { |
| | | if eif, ok := feature.(*protomsg.Esinfo); ok { |
| | | if !isWeb { //不会比对抓拍库,只比对有效的人 |
| | | if eif.Enable == 1 { |
| | | score := float32(0) |
| | | if target == "car" { |
| | | if eif.CarNo != "" { |
| | | score = strComp(sf, eif.CarNo) |
| | | } else { |
| | | continue |
| | | } |
| | | } else { |
| | | score = fw(sf, eif.FaceFeature) |
| | | } |
| | | if score > 0 && score >= baseScore { |
| | | lock.Lock() |
| | | targets = append(targets, &protomsg.SdkCompareEach{ |
| | | Id: eif.Id, |
| | | CompareScore: score, |
| | | Tableid: eif.Tableid, |
| | | }) |
| | | lock.Unlock() |
| | | } |
| | | } |
| | | } else { //来源是web,会比对抓拍库,不管是否有效都需要比对 |
| | | score := float32(0) |
| | | if target == "car" { |
| | | if eif.CarNo != "" { |
| | | score = strComp(sf, eif.CarNo) |
| | | } else { |
| | | continue |
| | | } |
| | | } else { |
| | | score = fw(sf, eif.FaceFeature) |
| | | } |
| | | if score > 0 && score >= baseScore { |
| | | lock.Lock() |
| | | targets = append(targets, &protomsg.SdkCompareEach{ |
| | | Id: eif.Id, |
| | | CompareScore: score, |
| | | Tableid: eif.Tableid, |
| | | }) |
| | | lock.Unlock() |
| | | } |
| | | if eif, ok := feature.(*db.FeatureCacheBase); ok { |
| | | score := float32(0) |
| | | score = fw(sf, eif.FaceFeature) |
| | | if score > 0 && score >= baseScore { |
| | | lock.Lock() |
| | | targets = append(targets, &protomsg.SdkCompareEach{ |
| | | Id: eif.Id, |
| | | CompareScore: score, |
| | | Tableid: eif.TableId, |
| | | }) |
| | | lock.Unlock() |
| | | } |
| | | } |
| | | } |
| | | |
| | | }(&tempsi, wf, sourceFea, baseScore, isWebComp) |
| | | }(&tempsi, wf, sourceFea, baseScore) |
| | | } |
| | | |
| | | wg.Wait() |