From 4217e31b519aa4f3f7e3637e9b43a04052a21092 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期一, 16 十二月 2019 14:10:17 +0800
Subject: [PATCH] update
---
goface.go | 35 ++++++++++++++++++++++++++++-------
1 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/goface.go b/goface.go
index 8370f71..d2495c6 100644
--- a/goface.go
+++ b/goface.go
@@ -24,10 +24,11 @@
extractor bool
propertizer bool
tracker bool
+ fnLogger func(...interface{})
}
// NewSDK sdk
-func NewSDK() interface{} {
+func NewSDK(fn func(...interface{})) interface{} {
h := C.create_sdkface()
if h == nil {
return nil
@@ -39,6 +40,7 @@
extractor: false,
propertizer: false,
tracker: false,
+ fnLogger: fn,
}
}
@@ -50,6 +52,12 @@
}
}
+func (s *SDKFace) printLog(l ...interface{}) {
+ if s.fnLogger != nil {
+ s.fnLogger(l)
+ }
+}
+
// Detector detector
func Detector(i interface{}, minFaces, rollAngles, threadMax, gpu int) bool {
s := i.(*SDKFace)
@@ -58,6 +66,7 @@
}
ret := C.init_detector(s.handle, C.int(minFaces), C.int(rollAngles), C.int(threadMax), C.int(gpu))
if ret <= 0 {
+ s.printLog("->face--> CREATE Detector ERROR")
return false
}
s.detector = true
@@ -72,6 +81,7 @@
}
ret := C.init_extractor(s.handle, C.int(threadMax), C.int(gpu))
if ret <= 0 {
+ s.printLog("->face--> CREATE Extractor ERROR")
return false
}
s.extractor = true
@@ -86,6 +96,7 @@
}
ret := C.init_propertizer(s.handle, C.int(threadMax))
if ret <= 0 {
+ s.printLog("->face--> CREATE Propertizer ERROR")
return false
}
s.propertizer = true
@@ -101,6 +112,7 @@
ret := C.init_tracker(s.handle, C.int(w), C.int(h), C.int(maxFaces), C.int(interval), C.int(sampleSize), C.int(threadMax), C.int(gpu))
if ret <= 0 {
+ s.printLog("->face--> CREATE Tracker ERROR")
return false
}
s.tracker = true
@@ -133,6 +145,7 @@
if ret > 0 {
return CFacePosArrayToGoArray(cfpos, int(count))
}
+ s.printLog("->face--> Detect No One, Ret: ", ret)
return nil
}
@@ -144,10 +157,11 @@
//(void *handle, const cFacePos *pos, const void*data, const int w, const int h, const int c, const int chan, void **feat, int *featLen);
var feat unsafe.Pointer
var featLen C.int
- p := C.extract(s.handle, pos, unsafe.Pointer(&data[0]), C.int(w), C.int(h), C.int(c), C.int(ch), &feat, &featLen)
- if p > 0 {
+ ret := C.extract(s.handle, pos, unsafe.Pointer(&data[0]), C.int(w), C.int(h), C.int(c), C.int(ch), &feat, &featLen)
+ if ret > 0 {
return C.GoBytes(feat, featLen)
}
+ s.printLog("->face--> Extract Nothing, Ret: ", ret)
return nil
}
@@ -177,6 +191,7 @@
C.free(thft)
return &gothft
}
+ s.printLog("->face--> Propertize Nothing, Ret: ", ret)
return nil
}
@@ -212,6 +227,7 @@
return faces
}
+ s.printLog("->face--> Track No One, Ret: ", ret)
return nil
}
@@ -237,12 +253,14 @@
s := i.(*SDKFace)
if !s.tracker {
+ s.printLog("->face--> TrackerResize Failed, No Tracker Init")
return false
}
ret := C.resize(s.handle, C.int(w), C.int(h), C.int(ch))
- if ret >= 0 {
+ if ret == 0 {
return true
}
+ s.printLog("->face--> TrackerResize Failed, Ret: ", ret, " SDK Channel: ", ch, " Size: ", w, "x", h)
return false
}
@@ -263,11 +281,13 @@
channel = 3
}
+ if !TrackerResize(i, w, h, dchan) {
+ return nil
+ }
+
var fInfo []sdkstruct.CFaceInfo
- if s.tracker {
- fInfo = Track(s, data, w, h, c, dchan)
- }
+ fInfo = Track(s, data, w, h, c, dchan)
var faces []sdkstruct.CFaceResult
//灏唖dk杩斿洖鍊艰浆鎹㈡垚protomsg绫诲瀷
@@ -286,6 +306,7 @@
faces = append(faces, result)
}
+ s.printLog("->face--> Run Detect Face Count: ", len(fInfo), " Result: ", len(faces))
return faces
}
--
Gitblit v1.8.0