| | |
| | | handle unsafe.Pointer |
| | | result unsafe.Pointer |
| | | batchSize int |
| | | fakeImage unsafe.Pointer |
| | | } |
| | | |
| | | // NewHumanTracker new |
| | |
| | | p := C.c_human_tracker_create(C.int(gpu), C.int(batchSize), C.int(flag)) |
| | | if p != nil { |
| | | res := C.init_fgres(C.int(batchSize)) |
| | | return &HumanTracker{p, res, batchSize, nil} |
| | | return &HumanTracker{p, res, batchSize} |
| | | } |
| | | return nil |
| | | } |
| | |
| | | } |
| | | if h.result != nil { |
| | | C.free(h.result) |
| | | } |
| | | if h.fakeImage != nil { |
| | | C.free(h.fakeImage) |
| | | } |
| | | } |
| | | |
| | |
| | | return nil, errors.New("create C images error") |
| | | } |
| | | defer C.free(cImgs) |
| | | |
| | | var freeFakeImage []unsafe.Pointer |
| | | |
| | | for k, v := range imgs { |
| | | logo.Infoln("batch~~~~~~", k, " image: ", v) |
| | | if v == nil { |
| | | if h.fakeImage == nil { |
| | | h.fakeImage = C.create_fake_image(C.int(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)) |
| | | 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 { |
| | | 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) |
| | | |
| | | cRet := C.process(h.handle, cImgs, C.int(h.batchSize), h.result) |
| | | if cRet != 0 { |