From 7fd3f1e5b661e3457b2adf8b36a70a5211149865 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期二, 14 一月 2020 10:57:31 +0800 Subject: [PATCH] debug --- run.go | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/run.go b/run.go index bec3732..73abf30 100644 --- a/run.go +++ b/run.go @@ -2,12 +2,14 @@ import ( "context" + "io/ioutil" "unsafe" "basic.com/libgowrapper/sdkhelper.git" "basic.com/valib/gogpu.git" "basic.com/pubsub/protomsg.git" + "basic.com/valib/godraw.git" "basic.com/valib/deliver.git" "github.com/gogo/protobuf/proto" @@ -15,9 +17,9 @@ type reid struct { handle *ReID - list *sdkhelper.LockList fnLogger func(...interface{}) + gpu int ipc string } @@ -46,17 +48,11 @@ gpuM := sdkhelper.Atoi(cfg.Param[sGPU]) - rGPU := 0 + rGPU := gpu if rGPU == -1 { rGPU = gogpu.ValidGPU(gpuM + 512) } - if rGPU == -1 { - fn("Reid SDK Create Error When Find GPU") - return nil - } - - rGPU = 0 handle := NewSDK(rGPU, cfg.Param[sModel]) if handle == nil { @@ -66,9 +62,9 @@ return &reid{ handle: handle, - list: sdkhelper.NewLockList(6), fnLogger: fn, + gpu: rGPU, ipc: cfg.Param[sIPC], } } @@ -105,9 +101,17 @@ } s.fnLogger("REID~~~~~~Recv Image:", len(i.Data)) + if jpg, err := godraw.ToJpeg(i.Data, int(i.Width), int(i.Height), nil); err == nil { + ioutil.WriteFile("./pic.jpg", jpg, 0644) + } feat := s.handle.Extract2(unsafe.Pointer(&i.Data[0]), int(i.Width), int(i.Height), 3) if feat == nil { - + // feat = make([]float32, 1) + } else { + for k := 0; k < 3; k++ { + s.fnLogger("REID~~~~~~extractor---human_feats------%f", feat[k+2000]) + } + s.fnLogger("REID~~~~~~Run Reid Use GPU: ", s.gpu) } buf := float32SliceAsByteSlice(feat) c.Send(buf) @@ -123,9 +127,5 @@ l := len(src) * 4 ptr := unsafe.Pointer(&src[0]) - // It is important to keep in mind that the Go garbage collector - // will not interact with this data, and that if src if freed, - // the behavior of any Go code using the slice is nondeterministic. - // Reference: https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices return (*[1 << 26]byte)((*[1 << 26]byte)(ptr))[:l:l] } -- Gitblit v1.8.0