stydb
2019-12-03 6d6e6d425c4fe63a487ff27be9341671b2c1dd93
gohumantrack/gohumantrack.go
@@ -17,12 +17,15 @@
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;
@@ -36,9 +39,9 @@
   }
   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;
@@ -95,6 +98,7 @@
// HumanTracker struct
type HumanTracker struct {
   handle    unsafe.Pointer
   result      unsafe.Pointer
   batchSize int
}
@@ -105,7 +109,8 @@
   }
   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
}
@@ -114,6 +119,9 @@
func (h *HumanTracker) Free() {
   if h.handle != nil {
      C.c_human_tracker_release(&h.handle)
   }
   if h.result != nil {
      C.free(h.result)
   }
}
@@ -146,11 +154,10 @@
      }
   }
   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)