package sdkcompare import ( "basic.com/valib/gosdk.git" "encoding/base64" "encoding/json" "basic.com/pubsub/cache.git" "fmt" ) //根据传入的多个tableId,上传的特征值和比对阈值获取返回结构体数组 func GetComparePersonBaseInfo(tableid []string, teststring []byte, compareThreshold int) []byte { totalmap := make(map[string]float32) if teststring == nil { return nil } if tableid == nil { //对比全部 for _, val := range cache.Cmap.Cam { tmpmap := val.Walk(Printest, teststring) for key, sec := range tmpmap { if sec > 70*0.01 { totalmap[key] = sec } } } } else { for _, tid := range tableid { shardins, ok := cache.Cmap.Cam[tid] fmt.Println(ok) if !ok { fmt.Println("get shad error by id", shardins) continue } tmpmap := shardins.Walk(Printest, teststring) for key, sec := range tmpmap { if sec > 70*0.01 { totalmap[key] = sec } } } } fmt.Println(totalmap) buf, err := json.Marshal(totalmap) if err != nil { fmt.Println("map to json error!", err) return nil } return buf } func Printest(ci []byte, co string) float32 { co_d, err := base64.StdEncoding.DecodeString(co) if err != nil { fmt.Println("co_d : error : ", err) return -1 } sec := gosdk.FaceCompare(ci, co_d) return sec }