From c8215ae1ce2825dca6a003c27fc721e86ae85e38 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期二, 17 十二月 2019 10:01:15 +0800 Subject: [PATCH] update --- work/sdk/ydetect.go | 50 +------------------------------------------------- 1 files changed, 1 insertions(+), 49 deletions(-) diff --git a/work/sdk/ydetect.go b/work/sdk/ydetect.go index 7951ca5..84364f9 100644 --- a/work/sdk/ydetect.go +++ b/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 { -- Gitblit v1.8.0