From 5a43718b678531f0db9073ef636ed74624154549 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期三, 11 十二月 2019 13:27:56 +0800
Subject: [PATCH] update

---
 goyolo.go |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/goyolo.go b/goyolo.go
index 94145a7..742a70e 100644
--- a/goyolo.go
+++ b/goyolo.go
@@ -52,10 +52,8 @@
 // Free free
 func Free(i interface{}) {
 	y := i.(*YoloHandle)
-	if y != nil {
-		if y.handle != nil {
-			C.release(y.handle)
-		}
+	if y != nil && y.handle != nil {
+		C.release(y.handle)
 	}
 }
 
@@ -82,16 +80,16 @@
 		C.float(thrsh), C.int(umns),
 		&cobjinfo, &count)
 
-	if ret == 0 {
+	if ret > 0 {
+		defer C.free(cobjinfo)
 		return CYoloObjInfoArrayToGoArray(unsafe.Pointer(cobjinfo), int(count))
 	}
 	return nil
 }
 
 // YoloObjName obj name by type
-func YoloObjName(i interface{}, typ int) string {
-	y := i.(*YoloHandle)
-	p := C.obj_name_by_type(y.handle, C.int(typ))
+func YoloObjName(typ int) string {
+	p := C.obj_name_by_type(C.int(typ))
 
 	return C.GoString(p)
 }
@@ -200,6 +198,5 @@
 	whole, recent := YoloDetectTrack2(y, v.lastTrackObjs, &v.lastTrackID, data, w, h, channel, thrsh, umns)
 	y.tracker[id].lastTrackObjs = whole
 	y.tracker[id].lastTrackID = v.lastTrackID
-
 	return whole, recent
 }

--
Gitblit v1.8.0