| | |
| | | "sync" |
| | | "encoding/base64" |
| | | |
| | | "test/cache/esutil" |
| | | "test/cache/shardmap" |
| | | // "basic.com/pubsub/cache.git/esutil" |
| | | // "basic.com/pubsub/cache.git/shardmap" |
| | | // "basic.com/pubsub/protomsg.git" |
| | | "encoding/json" |
| | | |
| | | "basic.com/pubsub/cache.git/esutil" |
| | | "basic.com/pubsub/cache.git/shardmap" |
| | | |
| | | "basic.com/valib/gosdk.git" |
| | | ) |
| | |
| | | |
| | | type CmapItem struct { |
| | | sync.Mutex |
| | | cam map[string]*shardmap.ShardMap |
| | | Cam map[string]*shardmap.ShardMap |
| | | } |
| | | |
| | | var Cmap *CmapItem |
| | |
| | | gosdk.InitFaceExtractor(16, 0) |
| | | |
| | | Cmap = &CmapItem{ |
| | | cam: make(map[string]*shardmap.ShardMap), |
| | | Cam: make(map[string]*shardmap.ShardMap), |
| | | } |
| | | |
| | | temptime := time.Now() |
| | |
| | | Cmap.Lock() |
| | | |
| | | for _, value := range escache{ |
| | | if _, ok :=Cmap.cam[value.Tableid]; !ok { |
| | | Cmap.cam[value.Tableid]=shardmap.New(uint8(*threadnum)) |
| | | if _, ok :=Cmap.Cam[value.Tableid]; !ok { |
| | | Cmap.Cam[value.Tableid]=shardmap.New(uint8(*threadnum)) |
| | | } |
| | | |
| | | Cmap.cam[value.Tableid].Set(value.Id,value.FaceFeature) |
| | | Cmap.Cam[value.Tableid].Set(value.Id,value.FaceFeature) |
| | | } |
| | | |
| | | Cmap.Unlock() |
| | |
| | | fmt.Println() |
| | | } |
| | | |
| | | //func main(){ |
| | | // Init() |
| | | // Getdbpersonmsg("") |
| | | //} |
| | | func Getdbpersonmsg(tableid string, teststring []byte, IsCompare bool) ([]byte) { |
| | | |
| | | func Getdbpersonmsg(tableid, teststring string, IsCompare bool) ([]byte) { |
| | | totalmap := make(map[string]float32) |
| | | |
| | | var buf []byte |
| | | if !IsCompare { |
| | | return nil |
| | | } |
| | | |
| | | if teststring == "" { |
| | | return nil |
| | | if teststring == nil { |
| | | return nil |
| | | } |
| | | |
| | | for id, value := range Cmap.cam{ |
| | | if id == tableid{ |
| | | fmt.Println(id) |
| | | buf =value.Walk(Printest, teststring) |
| | | if tableid == "" { |
| | | for id, val := range Cmap.Cam{ |
| | | fmt.Println("the id is: ", id) |
| | | tmpmap := val.Walk(Printest, teststring) |
| | | for key, sec := range tmpmap { |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | | |
| | | fmt.Println() |
| | | fmt.Println() |
| | | |
| | | firsttime := time.Now() |
| | | fmt.Println(time.Since(firsttime)) |
| | | return buf |
| | | |
| | | buf, err := json.Marshal(totalmap) |
| | | if err != nil { |
| | | fmt.Println("map to json error!", err) |
| | | return nil |
| | | } |
| | | return buf |
| | | } |
| | | |
| | | func Printest(ci, co string ) (float32){ |
| | | |
| | | //ci_d, err := base64.StdEncoding.DecodeString(ci) |
| | | //if err != nil { |
| | | // fmt.Println("ci_d : error : ", err) |
| | | // return -1 |
| | | //} |
| | | func Printest(ci []byte, co string ) (float32){ |
| | | |
| | | co_d, err := base64.StdEncoding.DecodeString(co) |
| | | if err != nil { |
| | |
| | | return -1 |
| | | } |
| | | |
| | | sec := gosdk.FaceCompare([]byte(ci), co_d) |
| | | sec := gosdk.FaceCompare(ci, co_d) |
| | | return sec |
| | | } |