4个文件已删除
12个文件已添加
1 文件已重命名
1个文件已修改
New file |
| | |
| | | #ifdef __cplusplus |
| | | extern "C"{ |
| | | #endif |
| | | |
| | | #include "csdk.h" |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | | |
| | | #include "csrc/all.hpp" |
| | | |
| | | using namespace csdk_wrap; |
| | | |
| | | static VecFunc dtors_; |
| | | |
| | | int c_api_face_detector_init(const int tm, const int gi, const int minFaces, const int rollAngle){ |
| | | return init_face_detector(tm, gi, minFaces, rollAngle, dtors_); |
| | | } |
| | | |
| | | int c_api_face_property_init(const int tm){ |
| | | return init_face_property(tm, dtors_); |
| | | } |
| | | |
| | | int c_api_face_extractor_init(const int tm, const int gi){ |
| | | return init_face_extractor(tm, gi, dtors_); |
| | | } |
| | | |
| | | int c_api_face_tracker_init(const int tm, const int gi, const int wid, const int hei, |
| | | const int maxFaces, const int detinterval, const int sampleSize){ |
| | | |
| | | return init_face_tracker(tm, gi, wid, hei, maxFaces, detinterval, sampleSize, dtors_); |
| | | } |
| | | |
| | | int c_api_face_track_resize(const int chan, const int wid, const int hei){ |
| | | return face_track_resize(chan, wid, hei); |
| | | } |
| | | |
| | | void c_api_release(){ |
| | | for(auto &i : dtors_){ |
| | | i(); |
| | | } |
| | | dtors_.clear(); |
| | | } |
| | | |
| | | //////////////////////////////////////////////// |
| | | |
| | | cFacePos* c_api_face_detect(int *faceCount, uchar*data, const int w, const int h, const int channel){ |
| | | const cIMAGE img{data, w, h, 3}; |
| | | return face_detect(faceCount, &img, channel); |
| | | } |
| | | |
| | | cThftResult c_api_face_property(const cFacePos* pos, uchar*data, const int w, const int h, const int channel){ |
| | | |
| | | const cIMAGE img{data, w, h, 3}; |
| | | return face_property(*pos, &img, channel); |
| | | } |
| | | |
| | | uchar* c_api_face_extract(int *featLen, const cFacePos* pos, uchar*data, const int w, const int h, const int channel){ |
| | | |
| | | const cIMAGE img{data, w, h, 3}; |
| | | return face_extract_feature(featLen, *pos, &img, channel); |
| | | } |
| | | |
| | | float c_api_face_compare(uchar *feat1, uchar *feat2){ |
| | | return face_compare(feat1, feat2); |
| | | } |
| | | |
| | | cRECT* c_api_face_track_only(int *fCount, uchar *data, const int wid, const int hei, const int channel){ |
| | | const cIMAGE img{data, wid, hei, 3}; |
| | | |
| | | return face_track_only(fCount, &img, channel); |
| | | } |
| | | |
| | | cFaceInfo* c_api_face_track_detect(int *fCount, uchar *data, const int wid, const int hei, const int channel){ |
| | | const cIMAGE img{data, wid, hei, 3}; |
| | | |
| | | return face_track_detect(fCount, &img, channel); |
| | | } |
| | | |
| | | cFaceInfo* c_api_face_track(int *fCount, uchar *data, const int wid, const int hei, const int channel){ |
| | | const cIMAGE img{data, wid, hei, 3}; |
| | | return face_track(fCount, &img, channel); |
| | | } |
| | | |
New file |
| | |
| | | #ifndef _c_wrapper_sdk_h_ |
| | | #define _c_wrapper_sdk_h_ |
| | | |
| | | #ifdef __cplusplus |
| | | extern "C"{ |
| | | #endif |
| | | |
| | | #include "csdk_struct.h" |
| | | |
| | | #ifndef uchar |
| | | typedef unsigned char uchar; |
| | | #endif |
| | | |
| | | typedef void* YoloHandle; |
| | | |
| | | int c_api_face_detector_init(const int tm, const int gi, const int minFaces, const int rollAngle); |
| | | int c_api_face_property_init(const int tm); |
| | | int c_api_face_extractor_init(const int tm, const int gi); |
| | | int c_api_face_tracker_init(const int tm, const int gi, const int wid, const int hei, |
| | | const int maxFaces, const int detinterval, const int sampleSize); |
| | | int c_api_face_track_resize(const int chan, const int w, const int h); |
| | | void c_api_release(); |
| | | /////////////////////////////////////////// |
| | | |
| | | /// face api |
| | | cFacePos* c_api_face_detect(int *faceCount, uchar*data, const int w, const int h, const int channel); |
| | | cThftResult c_api_face_property(const cFacePos* pos, uchar*data, const int w, const int h, const int channel); |
| | | |
| | | uchar* c_api_face_extract(int *featLen, const cFacePos* pos, uchar*data, const int w, const int h, const int channel); |
| | | float c_api_face_compare(uchar *feat1, uchar *feat2); |
| | | cRECT* c_api_face_track_only(int *fCount, uchar *data, const int wid, const int hei, const int channel); |
| | | cFaceInfo* c_api_face_track_detect(int *fCount, uchar *data, const int wid, const int hei, const int channel); |
| | | cFaceInfo* c_api_face_track(int *fCount, uchar *data, const int wid, const int hei, const int channel); |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | | |
| | | |
| | | #endif |
File was renamed from csrc/struct.h |
| | |
| | | #ifndef _face_struct_h_ |
| | | #define _face_struct_h_ |
| | | #ifndef _c_wrapper_c_structure_h_ |
| | | #define _c_wrapper_c_structure_h_ |
| | | |
| | | #include <string.h> |
| | | |
| | | typedef struct _cPOINT { |
| | | int x; |
| | |
| | | long nFaceID;//face tracking id |
| | | } cFaceInfo; |
| | | |
| | | |
| | | #endif |
New file |
| | |
| | | #ifndef _c_wrapper_face_detector_all_hpp_ |
| | | #define _c_wrapper_face_detector_all_hpp_ |
| | | |
| | | #include "buz/face/detector.cpp" |
| | | #include "buz/face/extractor.cpp" |
| | | #include "buz/face/property.cpp" |
| | | #include "buz/face/tracker.cpp" |
| | | |
| | | #endif |
New file |
| | |
| | | #ifndef _c_sdk_wrap_base_class_hpp_ |
| | | #define _c_sdk_wrap_base_class_hpp_ |
| | | |
| | | #include <vector> |
| | | #include <functional> |
| | | |
| | | using VecFunc = std::vector<std::function<void()> >; |
| | | |
| | | #endif |
New file |
| | |
| | | #include "detector.h" |
| | | |
| | | #include <stdio.h> |
| | | #include <stdlib.h> |
| | | #include <string.h> |
| | | |
| | | #include "THFaceImage_i.h" |
| | | |
| | | #include "csdk_struct.h" |
| | | |
| | | namespace csdk_wrap |
| | | { |
| | | int init_face_detector(const int tm, const int gi, const int minFaces, const int rollAngle, |
| | | VecFunc &vec){ |
| | | int ret = 0; |
| | | if (gi < 0) { |
| | | THFI_Param *param = new THFI_Param[tm]; |
| | | ret = THFI_Create(tm, param); |
| | | delete[] param; |
| | | } else { |
| | | THFI_Param_Ex *param = new THFI_Param_Ex[tm]; |
| | | THFI_Param detParam; |
| | | detParam.nMinFaceSize = minFaces; |
| | | detParam.nRollAngle = rollAngle; |
| | | for (int i = 0; i < tm; i++) { |
| | | param[i].tp = detParam; |
| | | param[i].nDeviceID = gi; |
| | | } |
| | | ret = THFI_Create_Ex(tm, param); |
| | | delete[] param; |
| | | } |
| | | if(ret != tm){ |
| | | printf("create face detector failed!\n"); |
| | | }else{ |
| | | vec.emplace_back([]{THFI_Release();}); |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | cFacePos* face_detect(int *faceCount, const cIMAGE *img, const int channel){ |
| | | if(channel < 0 || !img){ |
| | | return NULL; |
| | | } |
| | | cFacePos *fpos = NULL; |
| | | ::THFI_FacePos facesPos[30]; |
| | | int faceNum = THFI_DetectFace(channel, (BYTE*)(img->data), 24, img->width, img->height, facesPos, 30); |
| | | |
| | | if (faceNum > 0) { |
| | | fpos = (cFacePos*)malloc(faceNum * sizeof(cFacePos)); |
| | | *faceCount = faceNum; |
| | | memcpy(fpos, facesPos, sizeof(THFI_FacePos) * faceNum); |
| | | |
| | | }else{ |
| | | // printf ("no face detected\n"); |
| | | } |
| | | return fpos; |
| | | } |
| | | |
| | | } // csdk_wrap |
New file |
| | |
| | | #ifndef _c_wrapper_face_detector_hpp_ |
| | | #define _c_wrapper_face_detector_hpp_ |
| | | |
| | | #include "../base.hpp" |
| | | |
| | | |
| | | struct _cFacePos; |
| | | struct _cIMAGE; |
| | | |
| | | namespace csdk_wrap{ |
| | | |
| | | int init_face_detector(const int tm, const int gi, const int minFaces, const int rollAngle, |
| | | VecFunc &vec); |
| | | cFacePos* face_detect(int *faceCount, const cIMAGE *img, const int channel); |
| | | |
| | | } |
| | | |
| | | #endif |
New file |
| | |
| | | #include "extractor.h" |
| | | |
| | | #include "THFeature_i.h" |
| | | #include "csdk_struct.h" |
| | | |
| | | namespace csdk_wrap{ |
| | | |
| | | int init_face_extractor(const int tm, const int gi, VecFunc &vec){ |
| | | int ret = 0; |
| | | if (gi < 0) { |
| | | ret = EF_Init(tm); |
| | | } else { |
| | | EF_Param *param = new EF_Param[tm]; |
| | | for (int i = 0; i < tm; i++) { |
| | | param[i].nDeviceID = gi; |
| | | } |
| | | ret = EF_Init_Ex(tm, param); |
| | | delete[] param; |
| | | } |
| | | if(ret != tm){ |
| | | printf("create face extractor failed!\n");; |
| | | }else{ |
| | | vec.emplace_back([]{EF_Release();}); |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | | unsigned char* face_extract_feature(int *featLen, const cFacePos &pos, const cIMAGE *img, const int chan){ |
| | | if(!img){ |
| | | printf("face extract error, image or pos null\n"); |
| | | return NULL; |
| | | } |
| | | *featLen = EF_Size(); |
| | | unsigned char *feat = (unsigned char*)malloc(*featLen); |
| | | auto ret = EF_Extract(chan, (BYTE*)(img->data), img->width, img->height, 3, (THFI_FacePos*)(&pos), feat); |
| | | |
| | | if(ret != 1){ |
| | | printf("face extract error %d\n", ret); |
| | | free(feat); |
| | | *featLen = 0; |
| | | return NULL; |
| | | } |
| | | return feat; |
| | | } |
| | | |
| | | float face_compare(unsigned char *feat1, unsigned char *feat2){ |
| | | if (!feat1 || !feat2){ |
| | | return 0.0f; |
| | | } |
| | | |
| | | return EF_Compare(feat1, feat2); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | #ifndef _c_wrapper_face_extractor_h_ |
| | | #define _c_wrapper_face_extractor_h_ |
| | | |
| | | #include "../base.hpp" |
| | | |
| | | struct _cFacePos; |
| | | struct _cIMAGE; |
| | | |
| | | namespace csdk_wrap{ |
| | | int init_face_extractor(const int tm, const int gi, VecFunc &vec); |
| | | unsigned char* face_extract_feature(int *featLen, const cFacePos &pos, const cIMAGE *img, const int chan); |
| | | float face_compare(unsigned char *feat1, unsigned char *feat2); |
| | | } |
| | | #endif |
New file |
| | |
| | | #include "property.h" |
| | | |
| | | #include "THFaceProperty_i.h" |
| | | #include "csdk_struct.h" |
| | | |
| | | namespace csdk_wrap{ |
| | | |
| | | int init_face_property(const int tm, VecFunc &vec){ |
| | | auto ret = THFP_Create(tm); |
| | | if(ret != tm){ |
| | | printf("create face property error\n"); |
| | | }else{ |
| | | vec.emplace_back([]{THFP_Release();}); |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | | cThftResult face_property(const cFacePos &pos, const cIMAGE *img, const int chan){ |
| | | cThftResult result; |
| | | result.gender = result.age = result.race = -1; |
| | | |
| | | auto ret = THFP_Execute_V2(chan, (BYTE*)(img->data), img->width, img->height, |
| | | (THFI_FacePos*)(&pos), (THFP_Result_V2*)(&result)); |
| | | if(ret == 0){ |
| | | // printf("property face gender %s, age %d, race %s, beauty level %d, smile_level %d\n", |
| | | // result.gender ?"male":"female", |
| | | // result.age, |
| | | // result.race==2?"yello":"other", |
| | | // result.beauty_level, result.smile_level); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | #ifndef _c_wrapper_face_property_h_ |
| | | #define _c_wrapper_face_property_h_ |
| | | |
| | | #include "../base.hpp" |
| | | |
| | | struct _cThftResult; |
| | | struct _cFacePos; |
| | | struct _cIMAGE; |
| | | |
| | | namespace csdk_wrap{ |
| | | int init_face_property(const int tm, VecFunc &vec); |
| | | cThftResult face_property(const cFacePos &pos, const cIMAGE *img, const int chan); |
| | | } |
| | | #endif |
New file |
| | |
| | | #include "tracker.h" |
| | | |
| | | #include <stdio.h> |
| | | #include "THFaceTracking_i.h" |
| | | |
| | | namespace csdk_wrap{ |
| | | static THFT_Param param; |
| | | int init_face_tracker(const int tm, const int gi,const int w, const int h, |
| | | const int maxFaces, const int detinterval, const int sampleSize, |
| | | VecFunc &vec){ |
| | | param.nDeviceID = gi; |
| | | param.nImageWidth = w; |
| | | param.nImageHeight = h; |
| | | param.nMaxFaceNum = maxFaces; |
| | | param.nSampleSize = sampleSize > 0 ? sampleSize : w/2; |
| | | param.nDetectionIntervalFrame = detinterval; |
| | | printf("threads %d gi: %d size: %dx%d maxface: %d, sample: %d, interval: %d\n", |
| | | tm, gi, w, h, maxFaces, sampleSize, detinterval); |
| | | auto nNum = THFT_Create(tm, ¶m); |
| | | if(nNum != tm){ |
| | | printf("create face detector failed!\n"); |
| | | }else{ |
| | | vec.emplace_back([]{THFT_Release();}); |
| | | } |
| | | return nNum; |
| | | } |
| | | |
| | | cRECT* face_track_only(int *faceCount, const cIMAGE *img, const int chan){ |
| | | |
| | | *faceCount = 0; |
| | | |
| | | cRECT *pFaces = (cRECT*)malloc(param.nMaxFaceNum * sizeof(cRECT)); |
| | | auto nNum = THFT_FaceOnly(chan, img->data, img->width, img->height, (tagRECT*)pFaces, param.nMaxFaceNum, param.nSampleSize); |
| | | if (nNum > 0) |
| | | { |
| | | *faceCount = nNum; |
| | | }else{ |
| | | free(pFaces); |
| | | pFaces = NULL; |
| | | } |
| | | return pFaces; |
| | | } |
| | | |
| | | cFaceInfo* face_track_detect(int *faceCount, const cIMAGE *img, const int chan){ |
| | | *faceCount = 0; |
| | | |
| | | cFaceInfo* pFaceInfos = (cFaceInfo*)malloc(param.nMaxFaceNum * sizeof(cFaceInfo)); |
| | | auto nNum = THFT_FaceDetect(chan, img->data, img->width, img->height, (THFT_FaceInfo*)pFaceInfos, param.nMaxFaceNum, param.nSampleSize); |
| | | if (nNum > 0){ |
| | | *faceCount = nNum; |
| | | }else{ |
| | | free(pFaceInfos); |
| | | pFaceInfos = NULL; |
| | | } |
| | | return pFaceInfos; |
| | | } |
| | | |
| | | cFaceInfo* face_track(int *faceCount, const cIMAGE *img, const int chan){ |
| | | *faceCount = 0; |
| | | |
| | | cFaceInfo* pFaceInfos = (cFaceInfo*)malloc(param.nMaxFaceNum * sizeof(cFaceInfo)); |
| | | auto nNum = THFT_FaceTracking(chan, img->data, (THFT_FaceInfo*)pFaceInfos); |
| | | if (nNum > 0){ |
| | | *faceCount = nNum; |
| | | }else{ |
| | | free(pFaceInfos); |
| | | pFaceInfos = NULL; |
| | | } |
| | | return pFaceInfos; |
| | | } |
| | | |
| | | //THFACETRACKING_API int THFT_Reset(short nChannelID, THFT_Param* pParam); |
| | | int face_track_resize(const int chan, const int w, const int h){ |
| | | THFT_Param tmpParam; |
| | | tmpParam.nDeviceID = param.nDeviceID; |
| | | tmpParam.nImageWidth = w; |
| | | tmpParam.nImageHeight = h; |
| | | tmpParam.nMaxFaceNum = param.nMaxFaceNum; |
| | | tmpParam.nSampleSize = param.nSampleSize; |
| | | tmpParam.nDetectionIntervalFrame = param.nDetectionIntervalFrame; |
| | | |
| | | printf("chan %d size: %dx%d", chan, w, h); |
| | | |
| | | auto flag = THFT_Reset(chan, &tmpParam); |
| | | |
| | | return flag; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | #ifndef _c_wrapper_face_tracker_h_ |
| | | #define _c_wrapper_face_tracker_h_ |
| | | |
| | | #include "../base.hpp" |
| | | |
| | | struct _cRECT; |
| | | struct _cFaceInfo; |
| | | struct _cIMAGE; |
| | | |
| | | namespace csdk_wrap{ |
| | | int init_face_tracker(const int tm, const int gi,const int w, const int h, |
| | | const int maxFaces, const int detinterval, const int sampleSize, |
| | | VecFunc &vec); |
| | | cRECT* face_track_only(int *faceCount, const cIMAGE *img, const int chan); |
| | | cFaceInfo* face_track_detect(int *faceCount, const cIMAGE *img, const int chan); |
| | | |
| | | cFaceInfo* face_track(int *faceCount, const cIMAGE *img, const int chan); |
| | | int face_track_resize(const int chan, const int w, const int h); |
| | | } |
| | | #endif |
| | |
| | | #cgo LDFLAGS: -lTHFaceImage -lTHFeature -lTHFaceProperty -lTHFaceTracking |
| | | #cgo LDFLAGS: -lcudart -lcublas -lcurand -lrt -ldl -lpthread |
| | | #include <stdlib.h> |
| | | #include "cface.h" |
| | | #include "csdk.h" |
| | | */ |
| | | import "C" |
| | | import ( |
| | |
| | | |
| | | // SDKFace sdk |
| | | type SDKFace struct { |
| | | handle unsafe.Pointer |
| | | detector bool |
| | | extractor bool |
| | | propertizer bool |
| | |
| | | |
| | | // NewSDK sdk |
| | | func NewSDK(fn func(...interface{})) *SDKFace { |
| | | h := C.create_sdkface() |
| | | if h == nil { |
| | | return nil |
| | | } |
| | | |
| | | return &SDKFace{ |
| | | handle: h, |
| | | detector: false, |
| | | extractor: false, |
| | | propertizer: false, |
| | |
| | | |
| | | // Free free |
| | | func (s *SDKFace) Free() { |
| | | if s != nil && s.handle != nil { |
| | | C.release(s.handle) |
| | | } |
| | | C.c_api_release() |
| | | } |
| | | |
| | | func (s *SDKFace) printLog(l ...interface{}) { |
| | |
| | | } |
| | | |
| | | // Detector detector |
| | | func (s *SDKFace) Detector(minFaces, rollAngles, threadMax, gpu int) bool { |
| | | func (s *SDKFace) Detector(minFaces, rollAngle, threadMax, gpu int) bool { |
| | | |
| | | if s.detector { |
| | | return true |
| | | } |
| | | ret := C.init_detector(s.handle, C.int(minFaces), C.int(rollAngles), C.int(threadMax), C.int(gpu)) |
| | | |
| | | ret := C.c_api_face_detector_init(C.int(threadMax), C.int(gpu), C.int(minFaces), C.int(rollAngle)) |
| | | |
| | | if ret <= 0 { |
| | | s.printLog("->face--> CREATE Detector ERROR: ", ret) |
| | | return false |
| | |
| | | if s.extractor { |
| | | return true |
| | | } |
| | | ret := C.init_extractor(s.handle, C.int(threadMax), C.int(gpu)) |
| | | ret := C.c_api_face_extractor_init(C.int(threadMax), C.int(gpu)) |
| | | if ret <= 0 { |
| | | s.printLog("->face--> CREATE Extractor ERROR: ", ret) |
| | | return false |
| | |
| | | if s.propertizer { |
| | | return true |
| | | } |
| | | ret := C.init_propertizer(s.handle, C.int(threadMax)) |
| | | ret := C.c_api_face_property_init(C.int(threadMax)) |
| | | if ret <= 0 { |
| | | s.printLog("->face--> CREATE Propertizer ERROR: ", ret) |
| | | return false |
| | |
| | | if s.tracker { |
| | | return s.tracker |
| | | } |
| | | 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)) |
| | | |
| | | 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 { |
| | | s.printLog("->face--> CREATE Tracker ERROR: ", ret) |
| | | return false |
| | |
| | | return nil |
| | | } |
| | | |
| | | var cfpos unsafe.Pointer |
| | | var count C.int |
| | | ret := C.detect(s.handle, unsafe.Pointer(&data[0]), C.int(w), C.int(h), C.int(c), C.int(ch), &cfpos, &count) |
| | | if ret > 0 { |
| | | return CFacePosArrayToGoArray(cfpos, int(count)) |
| | | cfpos := C.c_api_face_detect(&count, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), C.int(ch)) |
| | | if cfpos != nil { |
| | | defer C.free(unsafe.Pointer(cfpos)) |
| | | return CFacePosArrayToGoArray(unsafe.Pointer(cfpos), int(count)) |
| | | } |
| | | s.printLog("->face--> Detect No One, Ret: ", ret) |
| | | |
| | | s.printLog("->face--> Detect No One") |
| | | return nil |
| | | } |
| | | |
| | | // Extract extract |
| | | func (s *SDKFace) Extract(fpos sdkstruct.CFacePos, data []byte, w, h, c int, ch int) []byte { |
| | | if !s.extractor { |
| | | return nil |
| | | } |
| | | |
| | | var featLen C.int |
| | | pos := (*C.cFacePos)(unsafe.Pointer(&fpos)) |
| | | |
| | | //(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 |
| | | 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 |
| | | 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 |
| | | } |
| | | |
| | | // Compare face compare |
| | |
| | | return 0 |
| | | } |
| | | |
| | | res := C.compare(s.handle, (*C.uchar)(unsafe.Pointer(&feat1[0])), (*C.uchar)(unsafe.Pointer(&feat2[0]))) |
| | | res := C.c_api_face_compare((*C.uchar)(unsafe.Pointer(&feat1[0])), (*C.uchar)(unsafe.Pointer(&feat2[0]))) |
| | | return float32(res) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | pos := (*C.cFacePos)(unsafe.Pointer(&fpos)) |
| | | |
| | | var thft unsafe.Pointer |
| | | ret := C.propertize(s.handle, pos, unsafe.Pointer(&data[0]), C.int(w), C.int(h), C.int(c), C.int(ch), &thft) |
| | | if ret == 0 { |
| | | gothft := *(*sdkstruct.CThftResult)(thft) |
| | | C.free(thft) |
| | | return &gothft |
| | | } |
| | | s.printLog("->face--> Propertize Nothing, Ret: ", ret) |
| | | return nil |
| | | 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)) |
| | | } |
| | | |
| | | // CFaceInfoArrayToGoArray convert cFaceInfo array to go |
| | |
| | | //img, const int chan, void **fInfo, int *fcnt); |
| | | |
| | | var fCount C.int |
| | | var finfos unsafe.Pointer |
| | | ret := C.track(s.handle, unsafe.Pointer(&data[0]), C.int(w), C.int(h), C.int(c), C.int(ch), &finfos, &fCount) |
| | | |
| | | if ret > 0 { |
| | | faces := CFaceInfoArrayToGoArray(finfos, int(fCount)) |
| | | //if len(faces) > 0{ |
| | | // fmt.Println("faces detected:", len(faces)) |
| | | //} |
| | | return faces |
| | | cFinfo := C.c_api_face_track(&fCount, (*C.uchar)(unsafe.Pointer(&data[0])), C.int(w), C.int(h), C.int(ch)) |
| | | // fmt.Println("cFinfo detected:", cFinfo) |
| | | if cFinfo == nil { |
| | | return nil |
| | | } |
| | | return nil |
| | | defer C.free(unsafe.Pointer(cFinfo)) |
| | | faces := CFaceInfoArrayToGoArray(unsafe.Pointer(cFinfo), int(fCount)) |
| | | return faces |
| | | } |
| | | |
| | | // FaceInfo2FacePos info -> pos |
| | |
| | | } |
| | | |
| | | // TrackerResize init face tracker |
| | | func (s *SDKFace) TrackerResize(w, h, ch int) bool { |
| | | func (s *SDKFace) TrackerResize(w, h, ch int) int { |
| | | |
| | | if !s.tracker { |
| | | s.printLog("->face--> TrackerResize Failed, No Tracker Init") |
| | | return false |
| | | return -1 |
| | | } |
| | | ret := C.track_resize(s.handle, C.int(w), C.int(h), C.int(ch)) |
| | | if ret == 1 { |
| | | return true |
| | | } |
| | | s.printLog("->face--> TrackerResize Failed, Ret: ", ret, " SDK Channel: ", ch, " Size: ", w, "x", h) |
| | | return false |
| | | return int(C.c_api_face_track_resize(C.int(ch), C.int(w), C.int(h))) |
| | | } |
| | | |
| | | // Run run |