liuxiaolong
2019-07-26 914cf7bf26c100b5af62c55b00c58884fee4cbd0
service/FaceSdkService.go
@@ -15,7 +15,7 @@
type FaceSdkService struct {
   File []byte
   Id string
   Id int64
   Result []*protomsg.ResultFaceDetect
   DeadTime time.Duration
}
@@ -24,6 +24,7 @@
   Ipc_Push_Ext       = "_2.ipc"
   Ipc_Pull_Ext       = "_1.ipc"
   Ipc_Url_Pre        = "ipc:///tmp///"
   faceExtractWebCID = "virtual-face-extract-web-camera-id"
   Virtual_FaceTaskId = "92496BDF-2BFA-98F2-62E8-96DD9866ABD2"
   Virtual_FaceSdkId  = "virtual-faceextract-sdk-pull"
   Url_Service_PUSH   = Ipc_Url_Pre + Virtual_FaceSdkId + Ipc_Push_Ext
@@ -54,7 +55,7 @@
func NewFaceSdkService(fileBytes []byte, deadTime time.Duration) FaceSdkService{
   return FaceSdkService{
      File:fileBytes,
      Id:uuid.NewV4().String(),
      Id:time.Now().UnixNano(),
      DeadTime:deadTime,
   }
}
@@ -108,8 +109,8 @@
      Height: height,
      Timestamp: formatTimeStr,
      Data: data,
      Id: timeUnix,
      Cid:s.Id,
      Id: s.Id,
      Cid: faceExtractWebCID,
   },nil
}
@@ -195,17 +196,17 @@
}
type FeaResult struct {
   FaceM map[string][]*protomsg.ResultFaceDetect
   FaceM map[int64][]*protomsg.ResultFaceDetect
   Lock sync.Mutex
}
func (f *FeaResult) Write(id string,faceDetectResult []*protomsg.ResultFaceDetect){
func (f *FeaResult) Write(id int64,faceDetectResult []*protomsg.ResultFaceDetect){
   f.Lock.Lock()
   defer f.Lock.Unlock()
   f.FaceM[id] = faceDetectResult
}
func (f *FeaResult) Get(id string) ([]*protomsg.ResultFaceDetect,bool){
func (f *FeaResult) Get(id int64) ([]*protomsg.ResultFaceDetect,bool){
   f.Lock.Lock()
   defer f.Lock.Unlock()
   coms,ok := f.FaceM[id]
@@ -223,7 +224,7 @@
func InitService() {
   logger.Debug("service init!")
   imgPushChan = make(chan []byte)
   resultMap.FaceM = make(map[string][]*protomsg.ResultFaceDetect,0)
   resultMap.FaceM = make(map[int64][]*protomsg.ResultFaceDetect,0)
   client_push = deliver.NewClient(deliver.PushPull, Url_Service_PUSH)
   client_pull = deliver.NewClient(deliver.PushPull, Url_Service_PULL)
   defer func() {
@@ -260,7 +261,12 @@
      rMsg := protomsg.SdkMessage{}
      if err := proto.Unmarshal(resultBytes, &rMsg); err == nil {
         logger.Debug("received MSG:", rMsg.Cid)
         perId := rMsg.Cid //数据id
         i := protomsg.Image{}
         err := proto.Unmarshal(rMsg.Data, &i)
         if err !=nil {
            continue
         }
         perId := i.Id //数据id
         if rMsg.Tasklab != nil && rMsg.Tasklab.Taskid == Virtual_FaceTaskId {
            sdkInfos := rMsg.Tasklab.Sdkinfos