From 6a413e1d7d485f506e81c669bc692868c29cefb9 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期四, 18 七月 2019 17:37:25 +0800 Subject: [PATCH] fix sdkcompare --- dbpersoninfo.go | 85 ++++++++++++++++++++++++++---------------- 1 files changed, 53 insertions(+), 32 deletions(-) diff --git a/dbpersoninfo.go b/dbpersoninfo.go index 5832070..a16d34c 100644 --- a/dbpersoninfo.go +++ b/dbpersoninfo.go @@ -25,7 +25,7 @@ var Cmap *CmapItem -func Init(){ +func Init(indexName string, serverIp string, serverPort string, analyServerId string){ flag.Parse() gosdk.InitFaceExtractor(16, 0) @@ -41,20 +41,29 @@ wg.Add(1) go func(qs int){ defer wg.Done() - escache, err := esutil.DbPersoninfos(qs, *querynum) + escache, err := esutil.Personinfos(qs, *querynum, indexName, serverIp, serverPort, analyServerId) if err != nil { fmt.Println(err) return } - Cmap.Lock() + Cmap.Lock() + var tableidstring string for _, value := range escache{ - if _, ok :=Cmap.Cam[value.Tableid]; !ok { - Cmap.Cam[value.Tableid]=shardmap.New(uint8(*threadnum)) + + // 濡傛灉娌℃湁tableid 鍒� tableidstring = capturetable + if value.Tableid == ""{ + tableidstring="capturetable" + }else{ + tableidstring = value.Tableid + } + + if _, ok :=Cmap.Cam[tableidstring]; !ok { + Cmap.Cam[tableidstring]=shardmap.New(uint8(*threadnum)) } - Cmap.Cam[value.Tableid].Set(value.Id,value.FaceFeature) + Cmap.Cam[tableidstring].Set(value.Id,value.FaceFeature) } Cmap.Unlock() @@ -66,49 +75,60 @@ fmt.Println() } -func Getdbpersonmsg(tableid string, teststring []byte, IsCompare bool) ([]byte) { +func GetComparePersonBaseInfo(tableid []string, faceFeature []byte, compareThreshold float32) []byte { totalmap := make(map[string]float32) - if !IsCompare { + if faceFeature == nil { return nil } - if teststring == nil { - return nil - } - - if tableid == "" { - for id, val := range Cmap.Cam{ - fmt.Println("the id is: ", id) - tmpmap := val.Walk(Printest, teststring) + if tableid == nil { + //瀵规瘮鍏ㄩ儴 + for _, val := range Cmap.Cam { + tmpmap := val.Walk(Printest, faceFeature) for key, sec := range tmpmap { - totalmap[key] = sec + if sec > 50*0.01 { + fmt.Println("map涓�",totalmap[key],sec) + totalmap[key] = sec + } } } - }else{ - for id, value := range Cmap.Cam{ - if id == tableid{ - fmt.Println("the id is: ", id) - tmpmap :=value.Walk(Printest, teststring) - for key, sec := range tmpmap { - totalmap[key]= sec - } - break + } else { + for _, tid := range tableid { + shardins, ok := Cmap.Cam[tid] + fmt.Println(ok) + if !ok { + fmt.Println("get shad error by id", shardins) + continue } - } + tmpmap := shardins.Walk(Printest, faceFeature) + for key, sec := range tmpmap { + if compareThreshold > 50*0.01{ + if sec > compareThreshold { + fmt.Println("map涓�",totalmap[key],sec) + totalmap[key] = sec + } + }else { + if sec > 50*0.01 { + fmt.Println("map涓�",totalmap[key],sec) + totalmap[key] = sec + } + } + + } + + } } - - firsttime := time.Now() - fmt.Println(time.Since(firsttime)) + fmt.Println(totalmap) buf, err := json.Marshal(totalmap) if err != nil { fmt.Println("map to json error!", err) - return nil + return nil } - return buf + return buf } func Printest(ci []byte, co string ) (float32){ @@ -120,5 +140,6 @@ } sec := gosdk.FaceCompare(ci, co_d) + fmt.Println("姣斿寰楀垎涓猴細",sec) return sec } -- Gitblit v1.8.0