From dd56c126c4e2ac2b309e05b47aa9477dee8ed318 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期一, 13 一月 2020 09:44:58 +0800 Subject: [PATCH] debug --- run.go | 50 +++++++++++++++----------------------------------- 1 files changed, 15 insertions(+), 35 deletions(-) diff --git a/run.go b/run.go index 3e9c399..023e949 100644 --- a/run.go +++ b/run.go @@ -23,6 +23,8 @@ ) func (f *face) channelAvailable() int { + f.mapChanLock.Lock() + defer f.mapChanLock.Unlock() for i := 0; i < f.maxChannel; i++ { found := false @@ -55,20 +57,20 @@ } func (f *face) channelNew(id string) *channel { - f.mapChanLock.Lock() - defer f.mapChanLock.Unlock() index := f.channelAvailable() if index < 0 { return nil } + f.mapChanLock.Lock() c := &channel{ index: index, - msgs: sdkhelper.NewLockList(6), + msgs: sdkhelper.NewLockList(3), } - f.mapChan[id] = c + f.mapChanLock.Unlock() + return c } @@ -191,13 +193,10 @@ func (f *face) run(msgs []protomsg.SdkMessage, out chan<- sdkstruct.MsgSDK, typ string) { - f.fnLogger("######run batch images") - for _, msg := range msgs { if c, ok := f.channelExist(msg.Cid); ok { - f.fnLogger("######push image: ", c.index) + f.fnLogger("######recv from :", msg.Cid, " Chan:", c.index) c.msgs.Push(msg) - f.fnLogger("######push over image: ", c.index) } else { nc := f.channelNew(msg.Cid) @@ -220,23 +219,18 @@ nc.msgs.Push(msg) } } - f.fnLogger("######run over batch images") - } func (f *face) detectTrackOneChn(c *channel, out chan<- sdkstruct.MsgSDK) { - tm := time.Now() - sc := 0 dtchn := c.index - f.fnLogger("DETECTTRACKONECHN DTCHN: ", dtchn) var curCid string for { select { case <-time.After(trackChnTimeout * time.Second): - f.fnLogger("Timeout to get image, curCid:", curCid) + f.fnLogger("######Timeout to get image, curCid:", curCid) if curCid != "" { f.channelRelease(curCid) } @@ -252,7 +246,7 @@ if !sdkhelper.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { sdkhelper.EjectResult(nil, rMsg, out) - f.fnLogger("Face!!!!!!SkdMessage Invalid") + f.fnLogger("Face!!!!!!SkdMessage Invalid: ", dtchn) continue } @@ -260,7 +254,7 @@ i := sdkhelper.UnpackImage(rMsg, f.typ, f.fnLogger) if i == nil || i.Data == nil || i.Width <= 0 || i.Height <= 0 { sdkhelper.EjectResult(nil, rMsg, out) - f.fnLogger("Face!!!!!!Unpack Image From SkdMessage Failed") + f.fnLogger("Face!!!!!!Unpack Image From SkdMessage Failed: ", dtchn) continue } @@ -270,34 +264,20 @@ // conv to bgr24 and resize imgW, imgH := int(i.Width), int(i.Height) - f.fnLogger("######face sdk run: ", dtchn) + f.fnLogger("######run cid:", rMsg.Cid, "chan: ", dtchn) count, data, _ := f.handle.Run(i.Data, imgW, imgH, 3, dtchn) - f.fnLogger("######face over sdk run: ", dtchn) + f.fnLogger("######over run cid:", rMsg.Cid, "chan: ", dtchn) - f.fnLogger("######face eject data: ", dtchn) + f.fnLogger("######eject cid:", rMsg.Cid, "chan: ", dtchn) sdkhelper.EjectResult(data, rMsg, out) - f.fnLogger("######face over eject data: ", dtchn) + f.fnLogger("######over eject cid:", rMsg.Cid, "chan: ", dtchn) var id, name string if rMsg.Tasklab != nil { id, name = rMsg.Tasklab.Taskid, rMsg.Tasklab.Taskname } - f.fnLogger("CAMERAID: ", rMsg.Cid, " TASKID: ", id, " TASKNAME: ", name, " DETECT ", f.typ, " COUNT: ", count) + f.fnLogger("Chan: ", dtchn, "CAMERAID: ", rMsg.Cid, " TASKID: ", id, " TASKNAME: ", name, " DETECT ", f.typ, " COUNT: ", count) } - - sc++ - if sc == 25 { - f.fnLogger("CHAN:%d, FACE RUN 25 FRAME USE TIME: ", dtchn, time.Since(tm)) - sc = 0 - tm = time.Now() - } - - if time.Since(tm) > time.Second { - f.fnLogger("CHAN: ", dtchn, " FACE RUN ", sc, " FRAME USE TIME: ", time.Since(tm)) - sc = 0 - tm = time.Now() - } - } } } -- Gitblit v1.8.0