sunty
2019-07-17 a298411166eb97edcce21ae42b1aeb763af8a8f0
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,7 +41,7 @@
        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
@@ -49,12 +49,21 @@
            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 == nil{
                    tableidstring="capturetable"
                }else{
                    tableidstring = value.Tableid
                }
                
                Cmap.Cam[value.Tableid].Set(value.Id,value.FaceFeature)
                if _, ok :=Cmap.Cam[tableidstring]; !ok {
                   Cmap.Cam[tableidstring]=shardmap.New(uint8(*threadnum))
                }
                Cmap.Cam[tableidstring].Set(value.Id,value.FaceFeature)
           }
            Cmap.Unlock()
@@ -66,42 +75,50 @@
    fmt.Println()
}
func Getdbpersonmsg(tableid string, teststring []byte, IsCompare bool) ([]byte) {
func GetComparePersonBaseInfo(tableid []string, faceFeature []byte, compareThreshold int) []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 cache.Cmap.Cam {
            tmpmap := val.Walk(Printest, faceFeature)
            for key, sec := range tmpmap {
                if sec > 70*0.01 {
                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 _, 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, faceFeature)
                for key, sec := range tmpmap {
                if compareThreshold > 70{
                    if sec > compareThreshold {
                    totalmap[key]= sec
                }
                break
            }
                }else {
                    if sec > 70*0.01 {
                        totalmap[key] = sec
       }
    }
            }
    firsttime := time.Now()
    fmt.Println(time.Since(firsttime))
        }
    }
    fmt.Println(totalmap)
    buf, err := json.Marshal(totalmap)
    if err != nil {