zhangmeng
2019-12-17 c8215ae1ce2825dca6a003c27fc721e86ae85e38
work/sdk/ydetect.go
@@ -6,7 +6,6 @@
   "context"
   "fmt"
   "plugin"
   "time"
   "basic.com/libgowrapper/sdkstruct.git"
   "basic.com/pubsub/protomsg.git"
@@ -79,24 +78,7 @@
// Run impl interface
func (y *YoloDetect) Run(ctx context.Context, in <-chan work.MsgRS, out chan<- work.MsgRS, typ string) {
   go y.work(ctx, out, typ)
   for {
      select {
      case <-ctx.Done():
         y.fnFree(y.handle)
         return
      default:
         rMsg := <-in
         if !validRemoteMessage(rMsg, typ) {
            logo.Errorln("yolo validremotemessage invalid")
            ejectResult(nil, rMsg, out)
            continue
         }
         y.list.Push(rMsg)
      }
   }
   FlowSimple(ctx, in, out, typ, y.list.Push, y.list.Pop, y.track, func() { y.fnFree(y.handle) })
}
func (y *YoloDetect) track(rMsg work.MsgRS, out chan<- work.MsgRS, typ string) {
@@ -133,36 +115,6 @@
   }
   logo.Infoln("CAMERAID: ", rMsg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " DETECT YOLO COUNT: ", len(whole))
}
func (y *YoloDetect) work(ctx context.Context, out chan<- work.MsgRS, typ string) {
   tm := time.Now()
   sc := 0
   for {
      select {
      case <-ctx.Done():
         return
      default:
         rMsg := y.list.Pop().(work.MsgRS)
         y.track(rMsg, out, typ)
         sc++
         if sc == 25 {
            logo.Infoln("YOLO RUN 25 FRAME USE TIME: ", time.Since(tm))
            sc = 0
            tm = time.Now()
         }
         if time.Since(tm) > time.Second {
            logo.Infof("YOLO RUN %d FRAME USE TIME: %v", sc, time.Since(tm))
            sc = 0
            tm = time.Now()
         }
      }
   }
}
func convert2ProtoYoloTrack(obj []sdkstruct.CObjTrackInfo, fx, fy float64) []*protomsg.ObjInfo {