From 4e40c5b5610857635a497ef3c3ed5c0564ecb061 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期四, 19 十二月 2019 17:06:24 +0800 Subject: [PATCH] udpate --- gohumantrack/gohumantrack.go | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gohumantrack/gohumantrack.go b/gohumantrack/gohumantrack.go index 7b11574..d9028bf 100644 --- a/gohumantrack/gohumantrack.go +++ b/gohumantrack/gohumantrack.go @@ -31,7 +31,6 @@ } int fill_images(void *imgs, const int size, const int index, void *data, const int w, const int h, const int c){ - if (!data) data = (unsigned char*)malloc(w*h*c); c_img *images = (c_img*)imgs; images[index].data_ = (unsigned char*)data; images[index].w_ = w; @@ -191,23 +190,23 @@ } defer C.free(cImgs) - // var freeFakeImage []unsafe.Pointer + var freeFakeImage []unsafe.Pointer for k, v := range imgs { if v == nil { - // fake := C.create_fake_image(C.int(wid * hei * chn)) - // freeFakeImage = append(freeFakeImage, fake) - C.fill_images(cImgs, C.int(h.batchSize), C.int(k), nil, C.int(wid), C.int(hei), C.int(chn)) + fake := C.create_fake_image(C.int(wid * hei * chn)) + freeFakeImage = append(freeFakeImage, fake) + C.fill_images(cImgs, C.int(h.batchSize), C.int(k), fake, C.int(wid), C.int(hei), C.int(chn)) } else { logo.Infoln("batch~~~~~~ real image len: ", len(v.Data), " size: ", v.Width, "x", v.Height, "x", v.Channel) C.fill_images(cImgs, C.int(h.batchSize), C.int(k), unsafe.Pointer(&v.Data[0]), C.int(v.Width), C.int(v.Height), C.int(v.Channel)) } } - // defer func(f []unsafe.Pointer) { - // for _, v := range f { - // C.free(v) - // } - // }(freeFakeImage) + defer func(f []unsafe.Pointer) { + for _, v := range f { + C.free(v) + } + }(freeFakeImage) cRet := C.process(h.handle, cImgs, C.int(h.batchSize), h.result) if cRet != 0 { -- Gitblit v1.8.0