zhangmeng
2019-12-19 5e920908a12c7d7372e145f04f315e00d5540d7a
update
1个文件已修改
17 ■■■■ 已修改文件
gohumantrack/gohumantrack.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gohumantrack/gohumantrack.go
@@ -22,6 +22,13 @@
    }
    return imgs;
}
void *create_fake_image(const int size){
    unsigned char *img = (unsigned char*)malloc(size);
    memset(img, 0, size);
    return img;
}
int fill_images(void *imgs, const int size, const int index, void *data, const int w, const int h, const int c){
    c_img *images = (c_img*)imgs;
    images[index].data_ = (unsigned char*)data;
@@ -102,6 +109,7 @@
    handle    unsafe.Pointer
    result    unsafe.Pointer
    batchSize int
    fakeImage unsafe.Pointer
}
// NewHumanTracker new
@@ -124,6 +132,9 @@
    }
    if h.result != nil {
        C.free(h.result)
    }
    if h.fakeImage != nil {
        C.free(h.fakeImage)
    }
}
@@ -181,11 +192,13 @@
        return nil, errors.New("create C images error")
    }
    defer C.free(cImgs)
    fake := make([]byte, wid*hei*chn)
    for k, v := range imgs {
        logo.Infoln("batch~~~~~~", k, " image: ", v)
        if v == nil {
            C.fill_images(cImgs, C.int(h.batchSize), C.int(k), unsafe.Pointer(&fake[0]), C.int(wid), C.int(hei), C.int(chn))
            if h.fakeImage == nil {
                h.fakeImage = C.create_fake_image(wid * hei * chn)
            }
            C.fill_images(cImgs, C.int(h.batchSize), C.int(k), h.fakeImage, C.int(wid), C.int(hei), C.int(chn))
        } else {
            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))
        }