| | |
| | | |
| | | void *create_batch_image(const int size){ |
| | | c_img *imgs = (c_img*)malloc(size * sizeof(c_img)); |
| | | for(int i = 0; i < size; i++){ |
| | | imgs[i].data_ = NULL; |
| | | } |
| | | return imgs; |
| | | } |
| | | int fill_images(void *imgs, const int size, const int index, void *data, const int w, const int h, const int c){ |
| | | if(!imgs || !data || size <= index) return -1; |
| | | c_img *images = (c_img*)imgs; |
| | | images[index].data_ = data; |
| | | images[index].data_ = (unsigned char*)data; |
| | | images[index].w_ = w; |
| | | images[index].h_ = h; |
| | | images[index].c_ = c; |
| | |
| | | } |
| | | return ret; |
| | | } |
| | | void *process(void *handle, void *imgs, const int size){ |
| | | void *process(void *handle, void *imgs, const int size, void *result){ |
| | | c_img *images = (c_img*)imgs; |
| | | c_fgRet *res = init_fgres(size); |
| | | c_fgRet *res = (c_fgRet *)result; |
| | | int ret = c_human_tracker_process(handle, images, size, res); |
| | | if (ret != 0) |
| | | return NULL; |
| | |
| | | // HumanTracker struct |
| | | type HumanTracker struct { |
| | | handle unsafe.Pointer |
| | | result unsafe.Pointer |
| | | batchSize int |
| | | } |
| | | |
| | |
| | | } |
| | | p := C.c_human_tracker_create(C.int(gpu), C.int(batchSize), C.int(flag)) |
| | | if p != nil { |
| | | return &HumanTracker{p, batchSize} |
| | | res := C.init_fgres(C.int(batchSize)) |
| | | return &HumanTracker{p, res, batchSize} |
| | | } |
| | | return nil |
| | | } |
| | |
| | | func (h *HumanTracker) Free() { |
| | | if h.handle != nil { |
| | | C.c_human_tracker_release(&h.handle) |
| | | } |
| | | if h.result != nil { |
| | | C.free(h.result) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | cRet := C.process(h.handle, cImgs, C.int(h.batchSize)) |
| | | cRet := C.process(h.handle, cImgs, C.int(h.batchSize), h.result) |
| | | if cRet == nil { |
| | | return nil, errors.New("create C results error") |
| | | } |
| | | defer C.free(unsafe.Pointer(cRet)) |
| | | |
| | | var result []FgResult |
| | | p := uintptr(cRet) |