zhangmeng
2019-12-17 d78b0016f7b96f486fd4af84e889d541c3dba0eb
work/sdk/humantrack.go
@@ -4,7 +4,6 @@
   "analysis/logo"
   "analysis/work"
   "context"
   "time"
   "github.com/gogo/protobuf/proto"
@@ -20,6 +19,7 @@
   gpu       int
   batchSize int
   flag      int
   list      *LockList
}
// NewHumanTracker new
@@ -28,6 +28,14 @@
      gpu:       gpu,
      batchSize: batchSize,
      flag:      flag,
      list:      NewLockList(6),
   }
}
// Free free
func (t *HumanTracker) Free() {
   if t.tracker != nil {
      t.tracker.Free()
   }
}
@@ -52,26 +60,11 @@
   return false
}
// 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)
@@ -87,7 +80,7 @@
         res, err := t.tracker.Process(images)
         if err != nil {
            ejectResult(nil, rMsg, out)
            continue
      return
         }
         hr := convert2ProtoHumanTrackResult(res)
@@ -104,22 +97,11 @@
         }
         logo.Infoln("CAMERAID: ", rMsg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " Human Track COUNT: ", len(hr[0]))
         /////////////////////////////////////
         sc++
         if sc == 25 {
            logo.Infoln("HUMAN TRACKER RUN 25 FRAME USE TIME: ", time.Since(tm))
            sc = 0
            tm = time.Now()
         }
         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()
         }
      }
   }
// 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, t.Free)
}
// message HumanTrack {