554325746@qq.com
2019-07-12 52e16245aae4c717478c5c95f59580a72139c0a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
}