From 9b01e3eec13fae6c8e855fe2f4b331b9b20ce638 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期二, 14 一月 2020 14:02:16 +0800 Subject: [PATCH] switch to yolo debug --- run.go | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 44 insertions(+), 3 deletions(-) diff --git a/run.go b/run.go index c31f84a..0a78442 100644 --- a/run.go +++ b/run.go @@ -1,13 +1,19 @@ package main import ( + "bufio" "context" + "fmt" + "io/ioutil" + "os" + "time" "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" @@ -82,8 +88,13 @@ return default: - msg, err = c.Recv() - if err != nil { + for { + msg, err = c.Recv() + if err == nil { + break + } + s.fnLogger("REID~~~~~~Recv From HumanTrack error: ", err) + time.Sleep(5 * time.Millisecond) continue } @@ -99,6 +110,11 @@ } 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) @@ -107,9 +123,34 @@ s.fnLogger("REID~~~~~~extractor---human_feats------%f", feat[k+2000]) } s.fnLogger("REID~~~~~~Run Reid Use GPU: ", s.gpu) + + ///////////////////////////////// + if f, err := os.Create("./reid-feat.txt"); err == nil { + defer f.Close() + + w := bufio.NewWriter(f) + for k, v := range feat { + lineStr := fmt.Sprintf("%d->%f", k, v) + fmt.Fprintln(w, lineStr) + } + w.Flush() + } + ///////////////////////////////// + } buf := float32SliceAsByteSlice(feat) - c.Send(buf) + ioutil.WriteFile("./reid-feat-byte.txt", buf, 0644) + + for { + err = c.Send(buf) + if err == nil { + break + } + s.fnLogger("REID~~~~~~Send HumanTrack error: ", err) + time.Sleep(5 * time.Millisecond) + continue + } + } } -- Gitblit v1.8.0