zhangmeng
2019-12-13 2d25b62b60da018412ed164b6fd29470498cea17
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package sdk
 
import (
    "analysis/work"
    "context"
)
 
// EFExtract engine face extract
type EFExtract struct {
    threads int
}
 
// NewEFExtract new
func NewEFExtract(thread int) *EFExtract {
    return &EFExtract{thread}
}
 
// Init impl interface
func (e *EFExtract) Init() bool {
    // i := gogpu.IdleGPU(100)
    // if i < 0 {
    //     logo.Errorln("there is no gpu resource to run faceextract")
    //     return false
    // }
    // gosdk.InitFaceExtractor(10, -1) // i not work
 
    return true
}
 
// Run impl interface
func (e *EFExtract) Run(ctx context.Context, in <-chan work.MsgRS, out chan<- work.MsgRS, typ string) {
 
    // if typ == work.FCompare {
    //     runCompare(ctx, in, out, typ)
    //     return
    // }
loop:
    for {
        select {
        case <-ctx.Done():
            break loop
        default:
            rMsg := <-in
            // if !validRemoteMessage(rMsg, typ) {
            //     continue
            // }
            // i := unpackImage(rMsg, typ)
            // if i == nil {
            //     continue
            // }
 
            // var dataF []byte
            // for _, v := range rMsg.Msg.Tasklab.Sdkinfos {
            //     if v.Sdktype == work.FDetect {
            //         dataF = v.Sdkdata
            //         break
            //     }
            // }
            // if dataF == nil {
            //     continue
            // }
            // var err error
            // // 反序列化数据得到sdk入参
            // param := protomsg.ParamFacePos{}
            // // dataF := rMsg.Msg.Tasklab.Sdkinfos[rMsg.Msg.Tasklab.Index].Sdkdata
            // err = proto.Unmarshal(dataF, &param)
            // if err != nil {
            //     ejectResult(nil, rMsg, out)
            //     continue
            // }
 
            // var data []byte
            // if param.Faces != nil {
            //     var extComp []*protomsg.ResultFaceExtCom
            //     for _, v := range param.Faces {
            //         feat := v.Feats
 
            //         var res []byte
            //         res = cache.Getdbpersonmsg(string(feat), true)
            //         f := &protomsg.ResultFaceExtCom{Feats: feat, Comp: res, Pos: v}
            //         extComp = append(extComp, f)
            //     }
 
            //     faceExtComp := protomsg.ParamFaceFeature{ExtComp: extComp}
            //     data, err = proto.Marshal(&faceExtComp)
            //     if err != nil {
            //         logo.Errorln("fextract marshal proto face extract error", err)
            //         continue
            //     }
            // }
 
            ejectResult(nil, rMsg, out)
        }
    }
}