From 0ffd95f2278e860736e46f8b73f357470f5a3d91 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期三, 15 一月 2020 17:56:18 +0800 Subject: [PATCH] debug --- csrc/buz/face/extractor.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/csrc/buz/face/extractor.cpp b/csrc/buz/face/extractor.cpp new file mode 100644 index 0000000..594eb1f --- /dev/null +++ b/csrc/buz/face/extractor.cpp @@ -0,0 +1,54 @@ +#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); + } + +} \ No newline at end of file -- Gitblit v1.8.0