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, ¶m)
|
// 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)
|
}
|
}
|
}
|