| | |
| | | #cgo LDFLAGS: -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking |
| | | #cgo LDFLAGS: -lcudart -lcublas -lcurand -lrt -ldl -lpthread |
| | | #include <stdlib.h> |
| | | #include "csdk.h" |
| | | #include "cface.h" |
| | | */ |
| | | import "C" |
| | | import ( |
| | |
| | | s.printLog("->face--> CREATE Detector ERROR: ", ret) |
| | | return false |
| | | } |
| | | s.printLog("->face--> CREATE Detector Threads: ", threadMax, " GPU:", gpu) |
| | | |
| | | s.detector = true |
| | | return true |
| | | } |
| | |
| | | s.printLog("->face--> CREATE Extractor ERROR: ", ret) |
| | | return false |
| | | } |
| | | s.printLog("->face--> CREATE Extractor Threads: ", threadMax, " GPU:", gpu) |
| | | |
| | | s.extractor = true |
| | | return true |
| | | } |
| | |
| | | s.printLog("->face--> CREATE Propertizer ERROR: ", ret) |
| | | return false |
| | | } |
| | | s.printLog("->face--> CREATE Propertizer Threads: ", threadMax) |
| | | |
| | | s.propertizer = true |
| | | return true |
| | | } |
| | |
| | | func (s *SDKFace) Tracker(w, h, maxFaces, interval, sampleSize, threadMax, gpu int) bool { |
| | | |
| | | if s.tracker { |
| | | return s.tracker |
| | | return true |
| | | } |
| | | ret := C.c_api_face_tracker_init(C.int(threadMax), C.int(gpu), C.int(w), C.int(h), C.int(maxFaces), C.int(interval), C.int(sampleSize)) |
| | | if ret <= 0 { |
| | |
| | | if !s.extractor { |
| | | return nil |
| | | } |
| | | s.printLog("->face--> facepos: ", fpos) |
| | | |
| | | var featLen C.int |
| | | pos := (*C.cFacePos)(unsafe.Pointer(&fpos)) |
| | | if pos == nil { |
| | | return nil |
| | | } |
| | | |
| | | p := C.c_api_face_extract(&featLen, pos, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), C.int(ch)) |
| | | defer C.free(unsafe.Pointer(p)) |
| | | b := C.GoBytes(unsafe.Pointer(p), featLen) |
| | | s.printLog("->face--> Extract Nothing, Ret: ", len(b)) |
| | | return b |
| | | if p != nil { |
| | | defer C.free(unsafe.Pointer(p)) |
| | | return C.GoBytes(unsafe.Pointer(p), featLen) |
| | | } |
| | | s.printLog("->face--> Extract Nothing") |
| | | return nil |
| | | } |
| | | |
| | | // Compare face compare |
| | |
| | | } |
| | | |
| | | // Propertize prop |
| | | func (s *SDKFace) Propertize(fpos sdkstruct.CFacePos, data []byte, w, h, c int, ch int) *sdkstruct.CThftResult { |
| | | func (s *SDKFace) Propertize(fpos sdkstruct.CFacePos, data []byte, w, h, c int, ch int) sdkstruct.CThftResult { |
| | | if !s.propertizer { |
| | | return nil |
| | | return sdkstruct.CThftResult{Age: 0} |
| | | } |
| | | |
| | | pos := (*C.cFacePos)(unsafe.Pointer(&fpos)) |
| | | result := C.c_api_face_property(pos, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), C.int(ch)) |
| | | s.printLog("->face--> Propertize") |
| | | return (*sdkstruct.CThftResult)(unsafe.Pointer(&result)) |
| | | return *(*sdkstruct.CThftResult)(unsafe.Pointer(&result)) |
| | | } |
| | | |
| | | // CFaceInfoArrayToGoArray convert cFaceInfo array to go |