From 1f11a8a98e70606664a103dfa65ec448cc81738a Mon Sep 17 00:00:00 2001 From: zhangmeng <zhangmeng@aiotlink.com> Date: 星期四, 19 十二月 2019 14:22:05 +0800 Subject: [PATCH] update --- work/sdk/humantrack.go | 38 ++++++++++++++++++++++---------------- 1 files changed, 22 insertions(+), 16 deletions(-) diff --git a/work/sdk/humantrack.go b/work/sdk/humantrack.go index ba9fb12..dae08ae 100644 --- a/work/sdk/humantrack.go +++ b/work/sdk/humantrack.go @@ -24,8 +24,8 @@ mapCameraImageIndex map[string]int recvImageCount int index int - images [batchSize]*gohumantrack.ImageHumanTracker - msgs [batchSize]*work.MsgRS + images []*gohumantrack.ImageHumanTracker + msgs []*work.MsgRS } // NewHumanTracker new @@ -38,6 +38,8 @@ recvImageCount: 0, index: 0, + images: make([]*gohumantrack.ImageHumanTracker, batchSize), + msgs: make([]*work.MsgRS, batchSize), } } @@ -50,10 +52,7 @@ // Init impl func (t *HumanTracker) Init() bool { - if t.batchSize != 1 { - logo.Errorln("ONLY SUPPORT BATCH SIZE = 1") - return false - } + gpu := t.gpu if gpu == -1 { @@ -92,7 +91,7 @@ return } - hr := convert2ProtoHumanTrackResult(res) + hr := convert2ProtoHumanTrackResult(res[0]) result := protomsg.HumanTrackResult{Result: hr} data, err := proto.Marshal(&result) if err != nil { @@ -104,7 +103,7 @@ if rMsg.Msg.Tasklab != nil { id, name = rMsg.Msg.Tasklab.Taskid, rMsg.Msg.Tasklab.Taskname } - logo.Infoln("CAMERAID: ", rMsg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " Human Track COUNT: ", len(hr[0])) + logo.Infoln("CAMERAID: ", rMsg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " Human Track COUNT: ", len(hr)) } @@ -127,8 +126,10 @@ // mapCameraImageIndex map[string]int // images []gohumantrack.ImageHumanTracker - t.recvImageCount++ if t.mapCameraImageIndex == nil { + t.recvImageCount = 0 + t.index = 0 + t.mapCameraImageIndex = make(map[string]int) for i := 0; i < t.batchSize; i++ { t.images[i] = nil @@ -137,13 +138,16 @@ t.msgs[i] = nil } } + + t.recvImageCount++ + if i, ok := t.mapCameraImageIndex[rMsg.Msg.Cid]; ok { - if i < batchSize { + if i < t.batchSize { t.images[i] = &img t.msgs[i] = &rMsg } } else { - if t.index < batchSize { + if t.index < t.batchSize { t.images[t.index] = &img t.msgs[t.index] = &rMsg t.mapCameraImageIndex[rMsg.Msg.Cid] = t.index @@ -151,13 +155,15 @@ t.index++ } if t.recvImageCount < t.batchSize+t.batchSize/2 { + logo.Infoln("batch~~~~~~Current Index: ", t.index) return } res, err := t.tracker.ProcessImagePointer(t.images[:]) + t.mapCameraImageIndex = nil if err != nil { - t.mapCameraImageIndex = nil + logo.Infoln("batch~~~~~~Track Failed: ", err) ejectResult(nil, rMsg, out) return } @@ -170,7 +176,7 @@ result := protomsg.HumanTrackResult{Result: hr} data, err := proto.Marshal(&result) if err != nil { - logo.Errorln("HUMAN TRACKER MARSHAL PROTO PLATE IDS ERROR", err) + logo.Errorln("batch~~~~~~HUMAN TRACKER MARSHAL PROTO PLATE IDS ERROR", err) data = nil } msg := *t.msgs[i] @@ -179,7 +185,7 @@ if msg.Msg.Tasklab != nil { id, name = msg.Msg.Tasklab.Taskid, msg.Msg.Tasklab.Taskname } - logo.Infoln("CAMERAID: ", msg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " Human Track COUNT: ", len(hr[0])) + logo.Infoln("batch~~~~~~CAMERAID: ", msg.Msg.Cid, " TASKID: ", id, " TASKNAME: ", name, " Human Track COUNT: ", len(hr)) } @@ -206,8 +212,8 @@ func convert2ProtoHumanTrackResult(obj gohumantrack.FgResult) []*protomsg.HumanTrack { res := []*protomsg.HumanTrack{} - for i := 0; i < int(v.FgNum); i++ { - r := v.Fginfo[i] + for i := 0; i < int(obj.FgNum); i++ { + r := obj.Fginfo[i] rect := protomsg.Rect{ Left: r.Left, Right: r.Right, -- Gitblit v1.8.0