From db20b766e2020950ed64a89065c8599a2ad69ff2 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期二, 14 一月 2020 18:01:12 +0800 Subject: [PATCH] update --- run.go | 47 +++++++++++++++++++++++------------------------ 1 files changed, 23 insertions(+), 24 deletions(-) diff --git a/run.go b/run.go index bba0c82..50cf58f 100644 --- a/run.go +++ b/run.go @@ -6,7 +6,7 @@ "sync" "time" - "basic.com/libgowrapper/sdkhelper.git" + "face/common" "basic.com/libgowrapper/sdkstruct.git" "basic.com/pubsub/protomsg.git" @@ -76,7 +76,7 @@ fn("Face SDK Create Error When New SDK") return nil } - cfg, err := sdkhelper.ReadConfig(config) + cfg, err := common.ReadConfig(config) if err != nil { fn("Face SDK Create Error When Read Config: ", err) return nil @@ -104,9 +104,9 @@ } w, h, detThrd, detNum, detAngle, propThrd, extThrd, trckInterval, trckSmpl, maxChan, gpuM := - 1280, 720, sdkhelper.Atoi(cfg.Param[dt]), sdkhelper.Atoi(cfg.Param[dn]), sdkhelper.Atoi(cfg.Param[da]), - sdkhelper.Atoi(cfg.Param[pt]), sdkhelper.Atoi(cfg.Param[et]), sdkhelper.Atoi(cfg.Param[ti]), sdkhelper.Atoi(cfg.Param[ts]), - sdkhelper.Atoi(cfg.Param[mc]), sdkhelper.Atoi(cfg.Param[gm]) + 1280, 720, common.Atoi(cfg.Param[dt]), common.Atoi(cfg.Param[dn]), common.Atoi(cfg.Param[da]), + common.Atoi(cfg.Param[pt]), common.Atoi(cfg.Param[et]), common.Atoi(cfg.Param[ti]), common.Atoi(cfg.Param[ts]), + common.Atoi(cfg.Param[mc]), common.Atoi(cfg.Param[gm]) if detAngle > 0 { } @@ -171,14 +171,14 @@ postPull = `_1` postPush = `_2` ) - ipcRcv := sdkhelper.GetIpcAddress(s.shm, s.id+postPull) - ipcSnd := sdkhelper.GetIpcAddress(s.shm, s.id+postPush) + ipcRcv := common.GetIpcAddress(s.shm, s.id+postPull) + ipcSnd := common.GetIpcAddress(s.shm, s.id+postPush) chRcv := make(chan []byte, s.maxChannel) chSnd := make(chan sdkstruct.MsgSDK, s.maxChannel) - rcver := sdkhelper.NewReciever(ipcRcv, chRcv, s.shm, s.fnLogger) - snder := sdkhelper.NewSender(ipcSnd, chSnd, s.shm, s.fnLogger) - torule := sdkhelper.NewToRule(s.ipc2Rule, s.ruleMsgMaxCacheSize, s.fnLogger) + rcver := common.NewReciever(ipcRcv, chRcv, s.shm, s.fnLogger) + snder := common.NewSender(ipcSnd, chSnd, s.shm, s.fnLogger) + torule := common.NewToRule(s.ipc2Rule, s.ruleMsgMaxCacheSize, s.fnLogger) snder.ApplyCallbackFunc(torule.Push) @@ -193,7 +193,6 @@ ////////////////////////////////////////////////////////////////// const ( - cacheFrameNum = 3 trackChnTimeout = time.Duration(10) ) @@ -226,8 +225,8 @@ func (f *face) run(ctx context.Context, in <-chan []byte, out chan<- sdkstruct.MsgSDK) { - chMsg := make(chan protomsg.SdkMessage) - go sdkhelper.UnserilizeProto(ctx, in, chMsg, f.fnLogger) + chMsg := make(chan protomsg.SdkMessage, f.maxChannel) + go common.UnserilizeProto(ctx, in, chMsg, f.fnLogger) for { select { @@ -235,9 +234,9 @@ f.handle.Free() return case rMsg := <-chMsg: - if !sdkhelper.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { + if !common.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { f.fnLogger("FACE TRACK VALIDREMOTEMESSAGE INVALID") - sdkhelper.EjectResult(nil, rMsg, out) + common.EjectResult(nil, rMsg, out) continue } @@ -246,18 +245,18 @@ f.ftrackChans[rMsg.Cid] <- rMsg } else { - f.ftrackChans[rMsg.Cid] = make(chan protomsg.SdkMessage, cacheFrameNum) + f.ftrackChans[rMsg.Cid] = make(chan protomsg.SdkMessage, f.maxChannel) chn := f.getAvailableChn() if chn < 0 { f.fnLogger("TOO MUCH CHANNEL") - sdkhelper.EjectResult(nil, rMsg, out) + common.EjectResult(nil, rMsg, out) continue } f.ftrackChannels[rMsg.Cid] = chn - i := sdkhelper.UnpackImage(rMsg, f.typ, f.fnLogger) + i := common.UnpackImage(rMsg, f.typ, f.fnLogger) if i == nil { - sdkhelper.EjectResult(nil, rMsg, out) + common.EjectResult(nil, rMsg, out) continue } // conv to bgr24 and resize @@ -286,14 +285,14 @@ case rMsg := <-in: - if !sdkhelper.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { - sdkhelper.EjectResult(nil, rMsg, out) + if !common.ValidRemoteMessage(rMsg, f.typ, f.fnLogger) { + common.EjectResult(nil, rMsg, out) continue } - i := sdkhelper.UnpackImage(rMsg, f.typ, f.fnLogger) + i := common.UnpackImage(rMsg, f.typ, f.fnLogger) if i == nil || i.Data == nil || i.Width <= 0 || i.Height <= 0 { - sdkhelper.EjectResult(nil, rMsg, out) + common.EjectResult(nil, rMsg, out) continue } @@ -306,7 +305,7 @@ count, data, _ := f.handle.Run(i.Data, imgW, imgH, 3, dtchn) - sdkhelper.EjectResult(data, rMsg, out) + common.EjectResult(data, rMsg, out) f.mtxRunning.Lock() f.running = true f.mtxRunning.Unlock() -- Gitblit v1.8.0