From 7c6a958f00e327a8991f48093456de7cb84cf918 Mon Sep 17 00:00:00 2001 From: 554325746@qq.com <554325746@qq.com> Date: 星期三, 05 二月 2020 20:20:24 +0800 Subject: [PATCH] change log for proto marshal --- run.go | 53 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 33 insertions(+), 20 deletions(-) diff --git a/run.go b/run.go index 8b00ebf..cef375d 100644 --- a/run.go +++ b/run.go @@ -48,7 +48,7 @@ "reid/rpc" - "basic.com/libgowrapper/sdkhelper.git" + "reid/common" "basic.com/valib/gogpu.git" @@ -66,9 +66,9 @@ } // Create Reid -func Create(config string, typ, id string, gpu int, shm bool, ipc2Rule string, ruleMaxSize int, fn func(...interface{}), reserved map[string]interface{}) interface{} { +func Create(config string, typ, id string, gpu int, shm bool, fn func(...interface{}), reserved map[string]interface{}) interface{} { - cfg, err := sdkhelper.ReadConfig(config) + cfg, err := common.ReadConfig(config) if err != nil { fn("Reid SDK Create Error When Read Config: ", err) return nil @@ -88,7 +88,7 @@ } } - gpuM := sdkhelper.Atoi(cfg.Param[sGPU]) + gpuM := common.Atoi(cfg.Param[sGPU]) rGPU := gpu @@ -120,8 +120,11 @@ postPush = `_1` ) - sndURL := s.ipc + postPush - rcvURL := s.ipc + postPull + ipcSnd := s.ipc + postPush + ipcRcv := s.ipc + postPull + + sndURL := common.GetIpcAddress(true, ipcSnd) + rcvURL := common.GetIpcAddress(true, ipcRcv) chSnd := make(chan []byte, 3) chRcv := make(chan []byte, 3) @@ -130,7 +133,7 @@ go recv.Run(ctx) chMsg := make(chan protomsg.SdkMessage, 3) - go sdkhelper.UnserilizeProto(ctx, chRcv, chMsg, s.fnLogger) + go common.UnserilizeProto(ctx, chRcv, chMsg, s.fnLogger) send := rpc.NewSender(sndURL, chSnd, true, s.fnLogger) go send.Run(ctx) @@ -141,20 +144,24 @@ return case msg := <-chMsg: if len(msg.Tasklab.Sdkinfos) == 0 || int(msg.Tasklab.Index) >= len(msg.Tasklab.Sdkinfos) { + s.fnLogger("reid !!!!!! Recv Msg From Humantrack Error") continue } - i := sdkhelper.UnpackImage(msg, "reid", s.fnLogger) + i := common.UnpackImage(msg, "reid", s.fnLogger) if i == nil || i.Data == nil || i.Width <= 0 || i.Height <= 0 { - s.fnLogger("reid !!!!!! unpack image error") + s.fnLogger("reid !!!!!! Unpack Image From Humantrack Msg Failed") continue } sdkInfo := msg.Tasklab.Sdkinfos[int(msg.Tasklab.Index)] + s.fnLogger("reid !!!!!! Recv From Humantrack SDK Result Length: ", len(sdkInfo.Sdkdata)) + res := &protomsg.HumanTrackResult{} if err := proto.Unmarshal(sdkInfo.Sdkdata, res); err != nil { - s.fnLogger(err, " sdkinfo msg Unmarshal 澶勭悊寮傚父") + s.fnLogger("reid !!!!!! proto.Unmarshal SDK Result From Humantrack msg Error:", err) continue } + for _, v := range res.Result { var clen C.int @@ -171,18 +178,24 @@ } - if out, err := proto.Marshal(res); err == nil { - msg.Tasklab.Sdkinfos[int(msg.Tasklab.Index)].Sdkdata = out - nMsg := protomsg.SdkMessage{} - - if data, err := proto.Marshal(&nMsg); err == nil { - if data == nil { - s.fnLogger(err, " msg Marshal 澶勭悊寮傚父") - continue - } - chSnd <- data + if len(res.Result) > 0 { + if out, err := proto.Marshal(res); err == nil { + msg.Tasklab.Sdkinfos[int(msg.Tasklab.Index)].Sdkdata = out + s.fnLogger("reid !!!!!! Send To Humantrack Result Length:", len(out)) } } + + if data, err := proto.Marshal(&msg); err == nil { + if data == nil { + s.fnLogger("reid !!!!!! proto.Marshal Failed To Marshal proto.SdkMessage") + continue + } + // s.fnLogger("reid !!!!!! MSG Send Back To Humantrack Length:", len(data)) + + chSnd <- data + } else { + s.fnLogger("reid !!!!!! proto.Marshal Out Msg Error:", err) + } default: time.Sleep(10 * time.Millisecond) -- Gitblit v1.8.0