zhangmeng
2019-12-17 c8215ae1ce2825dca6a003c27fc721e86ae85e38
work/sdk/humantrack.go
@@ -5,7 +5,6 @@
   "analysis/work"
   "context"
   "plugin"
   "time"
   "github.com/gogo/protobuf/proto"
@@ -19,6 +18,8 @@
   gpu       int
   batchSize int
   flag      int
   list *LockList
   handle       interface{}
   fnInit       func(int, int, int, func(...interface{})) interface{}
@@ -83,26 +84,11 @@
   return true
}
// Run impl
func (t *HumanTracker) Run(ctx context.Context, in <-chan work.MsgRS, out chan<- work.MsgRS, typ string) {
   tm := time.Now()
   sc := 0
   for {
      select {
      case <-ctx.Done():
         return
      default:
         rMsg := <-in
         if !validRemoteMessage(rMsg, typ) {
            ejectResult(nil, rMsg, out)
            continue
         }
func (t *HumanTracker) track(rMsg work.MsgRS, out chan<- work.MsgRS, typ string) {
         i := unpackImage(rMsg, typ)
         if i == nil || i.Data == nil || i.Width <= 0 || i.Height <= 0 {
            ejectResult(nil, rMsg, out)
            continue
      return
         }
         imgW, imgH := int(i.Width), int(i.Height)
@@ -118,7 +104,7 @@
         res := t.fnRun(t.handle, i.Data, imgW, imgH, 3)
         if res != nil {
            ejectResult(nil, rMsg, out)
            continue
      return
         }
         hr := convert2ProtoHumanTrackResult(res)
@@ -129,23 +115,19 @@
            data = nil
         }
         ejectResult(data, rMsg, out)
         /////////////////////////////////////
         sc++
         if sc == 25 {
            logo.Infoln("HUMAN TRACKER RUN 25 FRAME USE TIME: ", time.Since(tm))
            sc = 0
            tm = time.Now()
   var id, name string
   if rMsg.Msg.Tasklab != nil {
      id, name = rMsg.Msg.Tasklab.Taskid, rMsg.Msg.Tasklab.Taskname
         }
         if time.Since(tm) > time.Second {
            logo.Infof("HUMAN TRACKER RUN %d FRAME USE TIME: %v", sc, time.Since(tm))
            sc = 0
            tm = time.Now()
         }
   logo.Infoln("CAMERAID: ", rMsg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " DETECT YOLO COUNT: ", len(hr[0]))
      }
   }
// Run impl
func (t *HumanTracker) Run(ctx context.Context, in <-chan work.MsgRS, out chan<- work.MsgRS, typ string) {
   FlowSimple(ctx, in, out, typ, t.list.Push, t.list.Pop, t.track, func() { t.fnFree(t.handle) })
}
// message HumanTrack {