From a88fc40a16cefc8248baa4b6aab7b7577e0ba4cc Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期三, 19 七月 2017 16:42:37 +0800 Subject: [PATCH] code review --- /dev/null | 29 --- RtspFace/PL_Scale.cpp | 125 +++++++------- RtspFace/PL_Scale.h | 1 RtspFace/PL_Paint.h | 57 +++--- RtspFace/PL_Paint.cpp | 227 +++++++++++++++------------- 5 files changed, 212 insertions(+), 227 deletions(-) diff --git a/RtspFace/PL_Paint.cpp b/RtspFace/PL_Paint.cpp index daaca0d..6f724ff 100644 --- a/RtspFace/PL_Paint.cpp +++ b/RtspFace/PL_Paint.cpp @@ -7,6 +7,12 @@ #include <opencv2/core/mat.hpp> #include <opencv2/imgproc.hpp> +~PLPLContext::PLPLContext() +{ + delete (CvxText*)cvxText; + cvxText = nullptr; +} + struct PL_Paint_Internal { uint8_t* buffer; @@ -21,7 +27,7 @@ PL_Paint_Internal() : buffer(nullptr), buffSize(), config(), pmList(), - lastMbfBuffOrigin(), lastMbfBuffCopy(), + lastMbfBuffOrigin(), lastMbfBuffCopy(), payError(true) { } @@ -79,20 +85,17 @@ in->config = *config; } - if(in->config.fontPath.empty()) - { - LOG_ERROR << "fontPath is null!" << LOG_ENDL; - return false; - } - if(in->config.plplCtx->cvxText != nullptr) - { - delete(in->config.plplCtx->cvxText); - } - CvxText* cvxText =new CvxText(in->config.fontPath.c_str()); - in->config.plplCtx->cvxText = cvxText; - cvxText->setBackColor(cvScalar(128, 33, 14)); - CvScalar font = cvScalar(40,1,0.2,1); - cvxText->setFont(0, &font); + if(in->config.fontPath.empty()) + { + LOG_ERROR << "fontPath is null!" << LOG_ENDL; + return false; + } + + if(in->config.plplCtx->cvxText != nullptr) + { + delete (CvxText*)in->config.plplCtx->cvxText; + } + return true; } @@ -121,7 +124,7 @@ // void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0) - const PLGH_Color_YUV yuvColor(plplCtx->color_front.toY(), plplCtx->color_front.toU(), plplCtx->color_front.toV()); + const PLGH_Color_YUV yuvColor(plplCtx->color_front.toY(), plplCtx->color_front.toU(), plplCtx->color_front.toV()); cv::rectangle(yMat, cv::Point(LTX, LTY), cv::Point(RBX, RBY), CV_RGB(yuvColor.Y, yuvColor.Y, yuvColor.Y), 4); cv::rectangle(uMat, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), cv::Point(MH_SUBSAMPLE1(RBX, 2), MH_SUBSAMPLE1(RBY, 2)), CV_RGB(yuvColor.U, yuvColor.U, yuvColor.U), 2); @@ -145,8 +148,8 @@ // void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0) - const uint16_t Y = plplCtx->color_front.toY(); - const uint16_t UV = plplCtx->color_front.toUV(); + const uint16_t Y = plplCtx->color_front.toY(); + const uint16_t UV = plplCtx->color_front.toUV(); cv::rectangle(yMat, cv::Point(LTX, LTY), cv::Point(RBX, RBY), CV_RGB(Y, Y, Y), 4); cv::rectangle(uvMat, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), cv::Point(MH_SUBSAMPLE1(RBX, 2), MH_SUBSAMPLE1(RBY, 2)), CV_RGB(UV, UV, UV), 2); @@ -175,109 +178,121 @@ const uint16_t Y = plplCtx->color_front.toY(); const uint16_t UV = plplCtx->color_front.toUV(); - cv::putText(yMat, TXT, cv::Point(LTX, LTY), CV_FONT_HERSHEY_COMPLEX, 1, CV_RGB(Y, Y, Y)); - cv::putText(uvMat, TXT, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), CV_FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(UV, UV, UV)); + cv::putText(yMat, TXT, cv::Point(LTX, LTY), CV_FONT_HERSHEY_COMPLEX, 1, CV_RGB(Y, Y, Y)); + cv::putText(uvMat, TXT, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), CV_FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(UV, UV, UV)); } + bool plplDraw_WText_NV12(PLPLContext* plplCtx, MB_Frame* paintMb, int& paramOffset) { - int LTX = plplCtx->params[paramOffset + 0].val_i; - int LTY = plplCtx->params[paramOffset + 1].val_i; - const char* TXT = plplCtx->params[paramOffset + 2].val_s; - paramOffset += 3; + int LTX = plplCtx->params[paramOffset + 0].val_i; + int LTY = plplCtx->params[paramOffset + 1].val_i; + const char* WTXT = plplCtx->params[paramOffset + 2].val_s; + paramOffset += 3; - int src_width = paintMb->width; - int src_height = paintMb->height; - uint8_t* src_y = (uint8_t*)(paintMb->buffer); - uint8_t* src_uv = (uint8_t*)(src_y + (src_height * src_width)); - cv::Mat yMat(cv::Size(src_width, src_height), CV_8UC1, src_y); - cv::Mat uvMat(cv::Size(MH_SUBSAMPLE1(src_width, 2), MH_SUBSAMPLE1(src_height, 2)), CV_16UC1, src_uv); + int src_width = paintMb->width; + int src_height = paintMb->height; + uint8_t* src_y = (uint8_t*)(paintMb->buffer); + uint8_t* src_uv = (uint8_t*)(src_y + (src_height * src_width)); + cv::Mat yMat(cv::Size(src_width, src_height), CV_8UC1, src_y); + cv::Mat uvMat(cv::Size(MH_SUBSAMPLE1(src_width, 2), MH_SUBSAMPLE1(src_height, 2)), CV_16UC1, src_uv); - // void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0) + // void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0) - const uint16_t Y = plplCtx->color_front.toY(); - const uint16_t UV = plplCtx->color_front.toUV(); - CvxText* cvText = (CvxText*)plplCtx->cvxText; - cvText->putText(yMat, L"涓枃ABCDabcd", cv::Point(LTX, LTY), CV_RGB(Y, Y, Y)); - cvText->putText(uvMat, L"涓枃ABCDabcd", cv::Point(MH_SUBSAMPLE1(LTX, 2),MH_SUBSAMPLE1(LTY, 2)), CV_RGB(UV, UV, UV)); + if (in->config.plplCtx->cvxText == nullptr) + { + CvxText* cvxText = new CvxText(in->config.fontPath.c_str()); + in->config.plplCtx->cvxText = cvxText; + cvxText->setBackColor(cvScalar(128, 33, 14)); + CvScalar font = cvScalar(40, 1, 0.2, 1); + cvxText->setFont(0, &font); + } + + const uint16_t Y = plplCtx->color_front.toY(); + const uint16_t UV = plplCtx->color_front.toUV(); + + CvxText* cvText = (CvxText*)plplCtx->cvxText; + cvText->putText(yMat, (const wchar_t*)WTXT, cv::Point(LTX, LTY), CV_RGB(Y, Y, Y)); // L"涓枃ABCDabcd" + cvText->putText(uvMat, (const wchar_t*)WTXT, cv::Point(MH_SUBSAMPLE1(LTX, 2), MH_SUBSAMPLE1(LTY, 2)), CV_RGB(UV, UV, UV)); // L"涓枃ABCDabcd" } + bool plplExecutor_YUV(PL_Paint_Internal *in) { - MB_Frame* paintMb = &(in->lastMbfBuffOrigin); + MB_Frame* paintMb = &(in->lastMbfBuffOrigin); int ret = true; - if (in->config.copyData) - { - if (in->buffer == nullptr) - { - in->buffer = new uint8_t[in->lastMbfBuffOrigin.buffSize]; - in->buffSize = in->lastMbfBuffOrigin.buffSize; - } + if (in->config.copyData) + { + if (in->buffer == nullptr) + { + in->buffer = new uint8_t[in->lastMbfBuffOrigin.buffSize]; + in->buffSize = in->lastMbfBuffOrigin.buffSize; + } - in->lastMbfBuffCopy = in->lastMbfBuffOrigin; - in->lastMbfBuffCopy.buffer = in->buffer; - in->lastMbfBuffCopy.buffSize = in->buffSize; + in->lastMbfBuffCopy = in->lastMbfBuffOrigin; + in->lastMbfBuffCopy.buffer = in->buffer; + in->lastMbfBuffCopy.buffSize = in->buffSize; - memcpy(in->lastMbfBuffCopy.buffer, in->lastMbfBuffOrigin.buffer, in->lastMbfBuffCopy.buffSize); + memcpy(in->lastMbfBuffCopy.buffer, in->lastMbfBuffOrigin.buffer, in->lastMbfBuffCopy.buffSize); - paintMb = &(in->lastMbfBuffCopy); - } + paintMb = &(in->lastMbfBuffCopy); + } - //for (int i=640;i<2000;i++) ((uint8_t*)paintMb->buffer)[i]=255; + //for (int i=640;i<2000;i++) ((uint8_t*)paintMb->buffer)[i]=255; - PLPLContext* plplCtx = in->config.plplCtx; - int paramOffset = 0; - for (int iCmd = 0; iCmd < in->config.plplCtx->cmds.size(); iCmd++) - { - PLPLCmd cmd = plplCtx->cmds[iCmd]; + PLPLContext* plplCtx = in->config.plplCtx; + int paramOffset = 0; + for (int iCmd = 0; iCmd < in->config.plplCtx->cmds.size(); iCmd++) + { + PLPLCmd cmd = plplCtx->cmds[iCmd]; - switch(cmd) - { - case PLPLC_COLOR: - //COLOR F/B,R,G,B,A - if (plplCtx->params[paramOffset + 0].val_i == 'F') - { - plplCtx->color_front = PLGH_Color_RGBA(plplCtx->params[paramOffset + 1].val_i, - plplCtx->params[paramOffset + 2].val_i, - plplCtx->params[paramOffset + 3].val_i, - plplCtx->params[paramOffset + 4].val_i); - paramOffset += 5; - } - else if (plplCtx->params[paramOffset + 0].val_i == 'B') - { - plplCtx->color_back = PLGH_Color_RGBA(plplCtx->params[paramOffset + 1].val_i, - plplCtx->params[paramOffset + 2].val_i, - plplCtx->params[paramOffset + 3].val_i, - plplCtx->params[paramOffset + 4].val_i); - paramOffset += 5; - } - else - { - LOG_WARN << "plpl execute error" << LOG_ENDL; - return false; - } - break; + switch(cmd) + { + case PLPLC_COLOR: + //COLOR F/B,R,G,B,A + if (plplCtx->params[paramOffset + 0].val_i == 'F') + { + plplCtx->color_front = PLGH_Color_RGBA(plplCtx->params[paramOffset + 1].val_i, + plplCtx->params[paramOffset + 2].val_i, + plplCtx->params[paramOffset + 3].val_i, + plplCtx->params[paramOffset + 4].val_i); + paramOffset += 5; + } + else if (plplCtx->params[paramOffset + 0].val_i == 'B') + { + plplCtx->color_back = PLGH_Color_RGBA(plplCtx->params[paramOffset + 1].val_i, + plplCtx->params[paramOffset + 2].val_i, + plplCtx->params[paramOffset + 3].val_i, + plplCtx->params[paramOffset + 4].val_i); + paramOffset += 5; + } + else + { + LOG_WARN << "plpl execute error" << LOG_ENDL; + return false; + } + break; - case PLPLC_FILL: - plplCtx->fill = plplCtx->params[paramOffset + 0].val_i; - paramOffset += 1; - break; + case PLPLC_FILL: + plplCtx->fill = plplCtx->params[paramOffset + 0].val_i; + paramOffset += 1; + break; - case PLPLC_PEN: - plplCtx->pen = PLGH_Pen(plplCtx->params[paramOffset + 0].val_i, plplCtx->params[paramOffset + 1].val_i); - paramOffset += 2; - break; + case PLPLC_PEN: + plplCtx->pen = PLGH_Pen(plplCtx->params[paramOffset + 0].val_i, plplCtx->params[paramOffset + 1].val_i); + paramOffset += 2; + break; - case PLPLC_RECT: - //RECT LTX,LTY,RBX,RBY + case PLPLC_RECT: + //RECT LTX,LTY,RBX,RBY if (paintMb->type == MB_Frame::MBFT_YUV420) ret = plplDraw_Rect_YUV420(plplCtx, paintMb, paramOffset); else if (paintMb->type == MB_Frame::MBFT_NV12) ret = plplDraw_Rect_NV12(plplCtx, paintMb, paramOffset); else ret = false; - break; + break; - case PLPLC_TEXT: + case PLPLC_TEXT: //TEXT LTX,LTY,"STR" if (paintMb->type == MB_Frame::MBFT_YUV420) ret = plplDraw_Text_YUV420(plplCtx, paintMb, paramOffset); @@ -285,17 +300,17 @@ ret = plplDraw_Text_NV12(plplCtx, paintMb, paramOffset); else ret = false; - break; + break; - case PLPLC_WTEXT: - //TEXT LTX,LTY,"STR" - if (paintMb->type == MB_Frame::MBFT_NV12) - ret = plplDraw_WText_NV12(plplCtx, paintMb, paramOffset); - else - ret = false; - break; - } - } + case PLPLC_WTEXT: + //WTEXT LTX,LTY,"STR" + if (paintMb->type == MB_Frame::MBFT_NV12) + ret = plplDraw_WText_NV12(plplCtx, paintMb, paramOffset); + else + ret = false; + break; + } + } return ret; } @@ -337,8 +352,8 @@ { PL_Paint_Internal* in = (PL_Paint_Internal*)internal; in->payError = true; - pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_YUV420, PL_Paint::pay_breaker_MBFT_YUV, in); - pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_NV12, PL_Paint::pay_breaker_MBFT_YUV, in); + pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_YUV420, PL_Paint::pay_breaker_MBFT_YUV, in); + pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_NV12, PL_Paint::pay_breaker_MBFT_YUV, in); //#todo support RGB diff --git a/RtspFace/PL_Paint.h b/RtspFace/PL_Paint.h index 9b1a0e1..a541343 100644 --- a/RtspFace/PL_Paint.h +++ b/RtspFace/PL_Paint.h @@ -22,7 +22,8 @@ PLPLC_PEN, PLPLC_RECT, PLPLC_TEXT, - PLPLC_WTEXT, + PLPLC_WTEXT, + PLPLC__LAST }; @@ -32,19 +33,20 @@ float val_f; char val_s[10]; - PLPLType() : val_i(0) {} - PLPLType(int _val_i) : val_i(_val_i) {} - PLPLType(float _val_f) : val_f(_val_f) {} - PLPLType(const char* _val_s) - { - for (int i = 0; i < sizeof(val_s); i++) - val_s[i] = _val_s[i]; - } - PLPLType(const wchar_t* _val_s) - { - for (int i = 0; i < sizeof(val_s); i++) - val_s[i] = _val_s[i]; - } + PLPLType() : val_i(0) {} + PLPLType(int _val_i) : val_i(_val_i) {} + PLPLType(float _val_f) : val_f(_val_f) {} + PLPLType(const char* _val_s) + { + for (int i = 0; i < sizeof(val_s); i++) + val_s[i] = _val_s[i]; + } + PLPLType(const wchar_t* _val_s) + { + wchar_t* w_val_s = (wchar_t*)val_s; + for (int i = 0; i < sizeof(val_s) / sizeof(wchar_t); i++) + w_val_s[i] = _val_s[i]; + } }; typedef std::vector<PLPLCmd> plplc_vec_t; @@ -55,30 +57,27 @@ plplc_vec_t cmds; plplt_vec_t params; - PLGH_Color_RGBA color_front; - PLGH_Color_RGBA color_back; - int fill; - PLGH_Pen pen; - void* cvxText; - PLPLContext() : - cmds(), params(), color_front(), color_back(), fill(0), pen(0, 0), cvxText(nullptr) - {} + PLGH_Color_RGBA color_front; + PLGH_Color_RGBA color_back; + int fill; + PLGH_Pen pen; + void* cvxText; - ~PLPLContext() - { - delete(cvxText); - cvxText = nullptr; - } + PLPLContext() : + cmds(), params(), color_front(), color_back(), fill(0), pen(0, 0), cvxText(nullptr) + {} + + ~PLPLContext(); }; struct PL_Paint_Config { bool copyData; PLPLContext* plplCtx; - std::string fontPath; + std::string fontPath; PL_Paint_Config() : - copyData(false), plplCtx(nullptr), fontPath() + copyData(false), plplCtx(nullptr), fontPath(" ") { } }; diff --git a/RtspFace/PL_Scale.cpp b/RtspFace/PL_Scale.cpp index 69b0866..4877fd1 100644 --- a/RtspFace/PL_Scale.cpp +++ b/RtspFace/PL_Scale.cpp @@ -2,7 +2,7 @@ #include "MaterialBuffer.h" #include "logger.h" #include <libyuv.h> -#include <android/native_window.h> + struct PL_Scale_Internal { uint8_t* buffer; @@ -94,8 +94,8 @@ { #define SUBSAMPLE(v, a) ((((v) + (a) - 1)) / (a)) - const int dst_width = in->config.toWidth; - const int dst_height = in->config.toHeight; + const int dst_width = in->config.toWidth; + const int dst_height = in->config.toHeight; size_t dstSizeMax = 0; if (srcType == MB_Frame::MBFT_YUV420||srcType == MB_Frame::MBFT_NV12) @@ -139,42 +139,43 @@ in->buffSize = dstSizeMax; } - else if (srcType == MB_Frame::MBFT_NV12) - { - const uint8_t* src_y = (const uint8_t*)(srcBuffer); - const uint8_t* src_uv = (const uint8_t*)(src_y + (srcHeight * srcWidth)); - if (srcWidth != dst_width || srcHeight != dst_height) - { - // RK3288, 1920->640: 2.8~12ms, avg=4ms + else if (srcType == MB_Frame::MBFT_NV12) + { + const uint8_t* src_y = (const uint8_t*)(srcBuffer); + const uint8_t* src_uv = (const uint8_t*)(src_y + (srcHeight * srcWidth)); + if (srcWidth != dst_width || srcHeight != dst_height) + { + // RK3288, 1920->640: 2.8~12ms, avg=4ms - uint8_t* dst_y = (uint8_t*)(in->buffer); - uint8_t* dst_uv = (uint8_t*)(dst_y + (dst_height * dst_width)); + uint8_t* dst_y = (uint8_t*)(in->buffer); + uint8_t* dst_uv = (uint8_t*)(dst_y + (dst_height * dst_width)); - libyuv::ScalePlane(src_y, srcWidth, - srcWidth, srcHeight, - dst_y, dst_width, - dst_width, dst_height, - libyuv::kFilterNone); + libyuv::ScalePlane(src_y, srcWidth, + srcWidth, srcHeight, + dst_y, dst_width, + dst_width, dst_height, + libyuv::kFilterNone); - libyuv::ScalePlane_16((uint16*)src_uv, SUBSAMPLE(srcWidth, 2), - SUBSAMPLE(srcWidth, 2), SUBSAMPLE(srcHeight, 2), - (uint16*)dst_uv, SUBSAMPLE(dst_width, 2), - SUBSAMPLE(dst_width, 2), SUBSAMPLE(dst_height, 2), - libyuv::kFilterNone); - in->buffSize = dstSizeMax; - } - else if (srcType == MB_Frame::MBFT_BGRA) - { - //#todo - LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl; - return false; - } else - { - LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl; - return false; - } - return true; - } + libyuv::ScalePlane_16((uint16*)src_uv, SUBSAMPLE(srcWidth, 2), + SUBSAMPLE(srcWidth, 2), SUBSAMPLE(srcHeight, 2), + (uint16*)dst_uv, SUBSAMPLE(dst_width, 2), + SUBSAMPLE(dst_width, 2), SUBSAMPLE(dst_height, 2), + libyuv::kFilterNone); + in->buffSize = dstSizeMax; + } + else if (srcType == MB_Frame::MBFT_BGRA) + { + //#todo + LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl; + return false; + } + else + { + LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl; + return false; + } + return true; + } } bool PL_Scale::pay(const PipeMaterial& pm) @@ -222,32 +223,32 @@ } } break; - case PipeMaterial::PMT_PM_LIST: - { - // break pm list into single pm(s) + case PipeMaterial::PMT_PM_LIST: + { + // break pm list into single pm(s) - MB_Frame* ppm = (MB_Frame*)pm.buffer; - for (size_t i = 0; i < pm.buffSize; i++, ppm++) - { - if (ppm->type== PipeMaterial::PMT_FRAME) - { - MB_Frame* frame = (MB_Frame*)ppm->buffer; - switch(frame->type) - { - case MB_Frame::MBFT_YUV420: - case MB_Frame::MBFT_BGRA: - case MB_Frame::MBFT_NV12: - in->lastFrame = *frame; - ret = image_scale(in, (uint8_t*)frame->buffer,frame->type, - frame->width, frame->height); - break; - default: - LOG_ERROR << "Only support MBFT_YUV420 / MBFT_BGRA" << std::endl; - return false; - } - } - } - }break; + MB_Frame* ppm = (MB_Frame*)pm.buffer; + for (size_t i = 0; i < pm.buffSize; i++, ppm++) + { + if (ppm->type== PipeMaterial::PMT_FRAME) + { + MB_Frame* frame = (MB_Frame*)ppm->buffer; + switch(frame->type) + { + case MB_Frame::MBFT_YUV420: + case MB_Frame::MBFT_BGRA: + case MB_Frame::MBFT_NV12: + in->lastFrame = *frame; + ret = image_scale(in, (uint8_t*)frame->buffer,frame->type, + frame->width, frame->height); + break; + default: + LOG_ERROR << "Only support MBFT_YUV420 / MBFT_BGRA" << std::endl; + return false; + } + } + } + }break; default: LOG_ERROR << "Only support PMT_BYTES / PMT_FRAME" << std::endl; return false; @@ -275,7 +276,7 @@ } break; case PipeMaterial::PMT_FRAME: - case PipeMaterial::PMT_PM_LIST: + case PipeMaterial::PMT_PM_LIST: { newPm.type = PipeMaterial::PMT_FRAME; newPm.buffer = &(in->lastFrame); diff --git a/RtspFace/PL_Scale.h b/RtspFace/PL_Scale.h index d662b1f..76e00b5 100644 --- a/RtspFace/PL_Scale.h +++ b/RtspFace/PL_Scale.h @@ -5,7 +5,6 @@ struct PL_Scale_Config { - void* windowSurface; uint16_t toWidth; uint16_t toHeight; int filterMode; // libyuv/scale.h/FilterMode diff --git a/RtspFace/SensetimeFaceAPIWrapper/include/cv_common.h b/RtspFace/SensetimeFaceAPIWrapper/include/cv_common.h deleted file mode 100644 index 21ce097..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/include/cv_common.h +++ /dev/null @@ -1,285 +0,0 @@ -锘�#ifndef CV_COMMON_H_ -#define CV_COMMON_H_ - -/// @defgroup cv_common cv common -/// @brief common definitions & API for cv libs -/// @{ - -#include <cv_utils.h> - -#ifdef __cplusplus -# define CV_SDK_API extern "C" CV_SDK_API_ -#else -# define CV_SDK_API CV_SDK_API_ -#endif - -/// cv handle declearation -typedef void *cv_handle_t; - -/// cv result declearation -typedef cv_errcode cv_result_t; - -/// cv rectangle definition -typedef struct cv_rect_t { - int left; ///< 鐭╁舰鏈�宸﹁竟鐨勫潗鏍� - int top; ///< 鐭╁舰鏈�涓婅竟鐨勫潗鏍� - int right; ///< 鐭╁舰鏈�鍙宠竟鐨勫潗鏍� - int bottom; ///< 鐭╁舰鏈�涓嬭竟鐨勫潗鏍� -} cv_rect_t; - -/// cv float type point definition -typedef struct cv_pointf_t { - float x; ///< 鐐圭殑姘村钩鏂瑰悜鍧愭爣, 涓烘诞鐐规暟 - float y; ///< 鐐圭殑绔栫洿鏂瑰悜鍧愭爣, 涓烘诞鐐规暟 -} cv_pointf_t; - -/// cv integer type point definition -typedef struct cv_pointi_t { - int x; ///< 鐐圭殑姘村钩鏂瑰悜鍧愭爣, 涓烘暣鏁� - int y; ///< 鐐圭殑绔栫洿鏂瑰悜鍧愭爣, 涓烘暣鏁� -} cv_pointi_t; - -/// cv object struct -typedef struct cv_object_t { - cv_pointi_t *corner; - int corner_count; -} cv_object_t; - -/// cv landmark array struct -typedef struct cv_landmarks_t { - cv_pointf_t *points_array; - int points_count; -} cv_landmarks_t; - -/// @brief 鍏抽敭鐐硅窡韪粨鏋滅粨鏋勪綋 -typedef struct cv_target_t { - cv_rect_t rect; ///< 浠h〃闈㈤儴鐨勭煩褰㈠尯鍩� - cv_pointf_t *points_array; ///< 鐩爣鍏抽敭鐐瑰潗鏍� - int points_count; ///< 鐩爣鍏抽敭鐐归暱搴� - float score; ///< 鐩爣缃俊搴� - int id; ///< 鐩爣ID, 鐢ㄤ簬琛ㄧず鍦ㄧ洰鏍囪窡韪腑鐨勭浉鍚岀洰鏍囧湪涓嶅悓甯у娆″嚭鐜� -} cv_target_t; - -typedef struct cv_feature_header_t { - int ver; ///< 鐗堟湰淇℃伅 - int idx; ///< 鏁扮粍涓嬫爣绱㈠紩 - int len; ///< CV_FEATURE鍏ㄩ儴鍐呭鐨勯暱搴�, 鍖呮嫭feature_header鍜岀壒寰佹暟缁�, 鎸夊瓧鑺傝绠�, 涓巗izeof(cv_feature_header_t)瀹氫箟涓嶅悓 -} cv_feature_header_t; - -/// @brief 鐗瑰緛鏍煎紡瀹氫箟 -typedef struct cv_feature_t { - int ver; ///< 鐗瑰緛鐗堝搴旀ā鍨嬫湰鍙� - int idx; ///< 鐗瑰緛绱㈠紩搴忓彿 - int len; ///< CV_FEATURE鍏ㄩ儴鍐呭鐨勯暱搴�, 鍖呮嫭feature_header鍜岀壒寰佹暟缁�, 鎸夊瓧鑺傝绠�, 涓巗izeof(cv_feature_header_t)瀹氫箟涓嶅悓 - float feat[0]; ///< 鐗瑰緛鏁扮粍 -} cv_feature_t; - -#define CV_FEATURE_HEADER(pf) ((cv_feature_header_t*)(pf)) -#define CV_FEATURE_SIZE(pf) (CV_FEATURE_HEADER(pf)->len) -#define CV_FEATURE_LENGTH(pf) ((CV_FEATURE_HEADER(pf)->len-sizeof(cv_feature_header_t))/sizeof(float)) -#define CV_ENCODE_FEATURE_SIZE(pf) ((CV_FEATURE_HEADER(pf)->len+2)/3*4 + 1) - -/// cv pixel format definition -typedef enum { - CV_PIX_FMT_GRAY8, ///< Y 1 8bpp ( 鍗曢�氶亾8bit鐏板害鍍忕礌 ) - CV_PIX_FMT_YUV420P, ///< YUV 4:2:0 12bpp ( 3閫氶亾, 涓�涓寒搴﹂�氶亾, 鍙︿袱涓负U鍒嗛噺鍜孷鍒嗛噺閫氶亾, 鎵�鏈夐�氶亾閮芥槸杩炵画鐨� ) - CV_PIX_FMT_NV12, ///< YUV 4:2:0 12bpp ( 2閫氶亾, 涓�涓�氶亾鏄繛缁殑浜害閫氶亾, 鍙︿竴閫氶亾涓篣V鍒嗛噺浜ら敊 ) - CV_PIX_FMT_NV21, ///< YUV 4:2:0 12bpp ( 2閫氶亾, 涓�涓�氶亾鏄繛缁殑浜害閫氶亾, 鍙︿竴閫氶亾涓篤U鍒嗛噺浜ら敊 ) - CV_PIX_FMT_BGRA8888, ///< BGRA 8:8:8:8 32bpp ( 4閫氶亾32bit BGRA 鍍忕礌 ) - CV_PIX_FMT_BGR888 ///< BGR 8:8:8 24bpp ( 3閫氶亾24bit BGR 鍍忕礌 ) -} cv_pixel_format; - -/// @brief 鏃堕棿鎴冲畾涔� -typedef struct cv_time_t { - long int tv_sec; ///< 绉� - long int tv_usec; ///< 寰 -}cv_time_t; - -/// 鍥惧儚鏍煎紡瀹氫箟 -typedef struct cv_image { - unsigned char *data; ///< 鍥惧儚鏁版嵁鎸囬拡 - cv_pixel_format pixel_format; ///< 鍍忕礌鏍煎紡 - int width; ///< 瀹藉害(浠ュ儚绱犱负鍗曚綅) - int height; ///< 楂樺害(浠ュ儚绱犱负鍗曚綅) - int stride; ///< 璺ㄥ害, 鍗虫瘡琛屾墍鍗犵殑瀛楄妭鏁� - cv_time_t time_stamp; ///< 鏃堕棿鎴� -} cv_image; - -typedef struct cv_clustering_result_t { - unsigned int count; ///< 鐩爣鏁伴噺 - int *idxs; ///< 鐩爣绱㈠紩鏁扮粍 - unsigned int group_flags; ///< 淇濈暀鍙傛暟 -} cv_clustering_result_t; - -/// @brief 鍥惧儚鍒嗙被鏍囩缁撴灉 -typedef struct cv_classifier_result_t { - int id; ///鏍囩 - float score; /// 缃俊搴� -} cv_classifier_result_t; - -// ====================== image utilities ======================== - -/// @brief 鍒涘缓鍥惧儚鎸囬拡骞跺垎閰嶅唴瀛� -/// @param[in] width 杈撳叆瀹藉害 -/// @param[in] height 杈撳叆楂樺害 -/// @param[in] pixel_format 杈撳叆鍍忕礌鏍煎紡 -/// @param[out] image 杈撳嚭鍥惧儚鎸囬拡鎵�鍦ㄥ湴鍧� -/// @return 鎴愬姛杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒鐮� -CV_SDK_API -cv_result_t cv_image_allocate( - int width, - int height, - cv_pixel_format pixel_format, - cv_image ** image -); - -/// @brief 閲婃斁鍥惧儚鏁版嵁 -/// @param[in] image 鍥惧儚鎸囬拡 -CV_SDK_API void -cv_image_release(cv_image* image); - -/// @brief 杩涜棰滆壊鏍煎紡杞崲 -/// @param[in] image_src 鐢ㄤ簬寰呰浆鎹㈢殑鍥惧儚鏁版嵁 -/// @param[out] image_dst 杞崲鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭�, 鍍忕礌鍊煎垵濮嬪寲涓�0 -/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷 -CV_SDK_API cv_result_t -cv_common_color_convert( - const cv_image* image_src, - cv_image* image_dst -); - -/// @brief 杩涜浠垮皠鍙樻崲 -/// @param[in] image_src 鐢ㄤ簬寰呰浆鎹㈢殑鍥惧儚鏁版嵁 -/// @param[in] src_points_array 婧愬浘鐨勪豢灏勭偣鏁扮粍 -/// @param[in] src_points_count 婧愬浘浠垮皠鐐圭殑鏁扮洰 -/// @param[in] dst_points_array 鐩爣鍥剧殑浠垮皠鐐规暟缁� -/// @param[in] dst_points_count 鐩爣鍥句豢灏勭偣鐨勬暟鐩� -/// @param[out] image_dst 杞崲鍚庣殑鍥惧儚鏁版嵁, 蹇呴』鏄疊GR鏍煎紡鍥惧儚锛岀洰鏍囧浘鍍忛渶瑕佺敱鐢ㄦ埛鍒嗛厤鍐呭瓨, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭� -/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷 -CV_SDK_API -cv_result_t -cv_common_image_affine_transfer( - const cv_image *image_src, - const cv_pointf_t *src_points_array, - const int src_points_count, - const cv_pointf_t *dst_points_array, - const int dst_points_count, - cv_image *image_dst -); - -/// @brief 鍥剧墖璋冩暣鏂规硶 -typedef enum { - CV_IMAGE_RESIZE_BILINEAR, ///< 鍙岀嚎鎬ф彃鍊� - CV_IMAGE_RESIZE_AREA ///< 鍖哄煙鎻掑�� -} cv_image_resize_method; - -/// @brief 杩涜缂╂斁鍙樻崲 -/// @note 璇ュ嚱鏁扮洰鍓嶄笉鏀寔stride鍙傛暟, 鎵�浠tride鍙傛暟搴旂瓑浜� width * elemSize -/// @param[in] image_src 鐢ㄤ簬寰呰浆鎹㈢殑鍥惧儚鏁版嵁 -/// @param[out] image_dst 杞崲鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭� -/// @param[in] method 缂╂斁杞崲鐨勬柟娉� -/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷 -CV_SDK_API -cv_result_t -cv_common_image_resize( - const cv_image *image_src, - cv_image *image_dst, - cv_image_resize_method method -); - -/// @brief 杩涜鍥惧儚瑁佸壀 -/// @param[in] image_src 鐢ㄤ簬寰呰鍓殑鍥惧儚鏁版嵁 -/// @param[in] crop_area 鍥惧儚瑁佸壀鐨勫尯鍩� -/// @param[out] image_dst 瑁佸壀鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭� -/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷 -CV_SDK_API -cv_result_t -cv_common_image_crop( - const cv_image *image_src, - const cv_rect_t *crop_area, - cv_image *image_dst -); - -/// @brief 杩涜鍥惧儚鏃嬭浆 -/// @note 璇ュ嚱鏁扮洰鍓嶄笉鏀寔stride鍙傛暟, 鎵�浠tride鍙傛暟搴旂瓑浜� width * elemSize -/// @param[in] image_src 鐢ㄤ簬寰呮棆杞殑鍥惧儚鏁版嵁 -/// @param[out] image_dst 鏃嬭浆鍚庣殑鍥惧儚鏁版嵁, 鐩爣鍥惧儚鐢辩敤鎴峰垎閰嶅唴瀛�, 闇�鎻愬墠瀹氫箟瀹�, 楂�, PixelFormat绛変俊鎭� -/// @param[in] rotate_degree 鍥惧儚椤烘椂閽堟棆杞殑瑙掑害, 鐜板湪鍙敮鎸�0, 90, 180, 270 -/// @return 姝e父杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷 -CV_SDK_API -cv_result_t -cv_common_image_rotate( - const cv_image *image_src, - cv_image *image_dst, - unsigned int rotate_degree -); - - -// ====================== model loader ======================== - -/// 妯″瀷鎸囬拡 -typedef void * cv_model_t; - -/// 缁勫悎妯″瀷鎸囬拡 -typedef void * cv_composite_model_t; - -/// @brief 鍔犺浇澶栭儴妯″瀷 -/// @param[in] file 杈撳叆妯″瀷鏂囦欢璺緞 -/// @param[out] model 杈撳嚭宸插垵濮嬪寲鐨勬ā鍨嬫寚閽� -/// @return 鎴愬姛杩斿洖CV_OK -CV_SDK_API cv_result_t -cv_common_load_model( - const char *file, - cv_model_t *model -); - -/// @brief 閿�姣佸凡鍔犺浇鐨勬ā鍨� -/// @param[in] model 妯″瀷鎸囬拡 -CV_SDK_API -void cv_common_unload_model( - cv_model_t model -); - -/// @brief 鍔犺浇鍐呴儴妯″瀷 -/// @param[in] model_start 鍐呴儴妯″瀷鎸囬拡澶� -/// @param[in] model_end 鍐呴儴妯″瀷鎸囬拡灏� -/// @param[out] model 杈撳嚭宸插垵濮嬪寲鐨勬ā鍨嬫寚閽� -/// @return 鎴愬姛杩斿洖CV_OK -CV_SDK_API cv_result_t -cv_common_load_resource( - const unsigned char *model_start, - const unsigned char *model_end, - cv_model_t *model -); - - -/// @brief 鍔犺浇缁勫悎妯″瀷 -/// @param[in] file 缁勫悎妯″瀷鏂囦欢璺緞锛� 鏂囦欢鏄敱澶氫釜瀛愭ā鍨嬫枃浠剁粍鎴恡ar鍖� -/// @param[out] model 杈撳嚭宸插垵濮嬪寲鐨勭粍鍚堟ā鍨嬫寚閽� -/// @return 鎴愬姛杩斿洖CV_OK -CV_SDK_API cv_result_t -cv_common_load_composite_model( - const char *file, - cv_composite_model_t *model -); - -/// @brief 閿�姣佸凡鍔犺浇鐨勭粍鍚堟ā鍨� -/// @param[in] model 灏嗛攢姣佺殑妯″瀷 -CV_SDK_API cv_result_t -cv_common_unload_composite_model( - cv_composite_model_t model -); - -/// @brief 鑾峰彇瀛愭ā鍨� -/// @param[in] model 缁勫悎妯″瀷 -/// @param[in] name 瀛愭ā鍨嬪悕瀛� -/// @param[in] 鎴愬姛杩斿洖CV_OK -CV_SDK_API cv_result_t -cv_common_composite_model_get_submodel( - cv_composite_model_t model, - const char *name, - cv_model_t *submodel -); - -/// @} -#endif // INCLUDE_CV_COMMON_H_ diff --git a/RtspFace/SensetimeFaceAPIWrapper/include/cv_face.h b/RtspFace/SensetimeFaceAPIWrapper/include/cv_face.h deleted file mode 100644 index f820a93..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/include/cv_face.h +++ /dev/null @@ -1,580 +0,0 @@ -锘� -#ifndef INCLUDE_CVFACE_API_CV_FACE_EXTERNAL_H_ -#define INCLUDE_CVFACE_API_CV_FACE_EXTERNAL_H_ - - -#include "cv_common.h" -/// @defgroup cvface_common cvface common -/// @brief Common definitions for cvface -/// @{ - -/// @brief 浜鸿劯淇℃伅缁撴瀯浣� -typedef struct cv_face_t { - cv_rect_t rect; ///< 浠h〃闈㈤儴鐨勭煩褰㈠尯鍩� - float score; ///< 缃俊搴︼紝鐢ㄤ簬绛涢櫎璐熶緥锛屼笌浜鸿劯鐓х墖璐ㄩ噺鏃犲叧锛屽�艰秺楂樿〃绀虹疆淇″害瓒婇珮銆� - int points_count; ///< 浜鸿劯鍏抽敭鐐规暟缁勭殑闀垮害锛屽鏋滄病鏈夎绠楀叧閿偣锛屽垯涓�0 - float yaw; ///< 姘村钩杞锛岀湡瀹炲害閲忕殑宸﹁礋鍙虫 - float pitch; ///< 淇话瑙掞紝鐪熷疄搴﹂噺鐨勪笂璐熶笅姝� - float roll; ///< 鏃嬭浆瑙掞紝鐪熷疄搴﹂噺鐨勫乏璐熷彸姝� - float eye_dist; ///< 涓ょ溂闂磋窛 - int ID; ///< faceID锛岀敤浜庤〃绀哄湪瀹炴椂浜鸿劯璺熻釜涓殑鐩稿悓浜鸿劯鍦ㄤ笉鍚屽抚澶氭鍑虹幇锛屽湪浜鸿劯妫�娴嬬殑缁撴灉涓棤瀹為檯鎰忎箟 - cv_pointf_t points_array[256]; ///< 浜鸿劯鍏抽敭鐐圭殑鏁扮粍鏀寔21鐐癸紝106鐐癸紝浠ュ強涓哄皢鏉ラ鐣欑殑绌洪棿 -} cv_face_t; - -/// 浜鸿劯妫�娴嬨�佽窡韪厤缃�夐」 -#define CV_FACE_DEFAULT_CONFIG 0x00000000 ///< 榛樿閫夐」锛屼笉璁剧疆浠讳綍寮�鍏� -#define CV_FACE_RESIZE_IMG_320W 0x00000002 ///< resize鍥惧儚涓洪暱杈�320鐨勫浘鍍� -#define CV_FACE_RESIZE_IMG_640W 0x00000004 ///< resize鍥惧儚涓洪暱杈�640鐨勫浘鍍� -#define CV_FACE_RESIZE_IMG_1280W 0x00000008 ///< resize鍥惧儚涓洪暱杈�1280鐨勫浘鍍� - -/// detect config flags, 0x----00-- ~ 0x----FF-- -#define CV_DETECT_ENABLE_ALIGN_21 0x00000100 ///< 寮�鍚潰閮ㄥ叧閿�21鐐规娴嬮�夐」 -#define CV_DETECT_ENABLE_ALIGN_106 0x00000200 ///< 寮�鍚潰閮ㄥ叧閿�106鐐规娴嬮�夐」 - -/// 璇ョ増鏈瑂dk鏈紑鍚鍔熻兘(濡傦細闈㈤儴鍏抽敭21鐐规娴嬬増鏈紶鍏ヤ簡闈㈤儴鍏抽敭106鐐规娴嬪弬鏁�) -#define CV_E_UNSURPPORTED (-1000) -/// 鎸囧畾浣嶇疆鏈壘鍒發icense.lic鏂囦欢 -#define CV_E_MISSLICENSE (-1001) -/// cv_face_init_license_config 鍑芥暟琚噸澶嶈皟鐢� -#define CV_E_MULTI_CALLS (-1002) - -/// @brief 浜鸿劯鏈濆悜 -typedef enum { - CV_FACE_UP = 0x0000001, ///< 浜鸿劯鍚戜笂锛屽嵆浜鸿劯鏈濆悜姝e父 - CV_FACE_LEFT = 0x0000002, ///< 浜鸿劯鍚戝乏锛屽嵆浜鸿劯琚�嗘椂閽堟棆杞簡90搴� - CV_FACE_DOWN = 0x0000004, ///< 浜鸿劯鍚戜笅锛屽嵆浜鸿劯琚�嗘椂閽堟棆杞簡180搴� - CV_FACE_RIGHT = 0x0000008, ///< 浜鸿劯鍚戝彸锛屽嵆浜鸿劯琚�嗘椂閽堟棆杞簡270搴� - CV_FACE_UNKNOWN = 0xf ///< 浜鸿劯鏈濆悜鏈煡锛孉PI鑷姩鍒ゆ柇浜鸿劯鏈濆悜锛岃�楁椂澧炲姞銆俧ace_track涓嶆敮鎸佹鍙傛暟锛岀瓑鍚屼簬CV_FACE_UP -} cv_face_orientation; - -/// @brief 杈撳嚭褰撳墠SDK鎵�鏀寔鐨勭畻娉曞強鍐呯疆妯″瀷淇℃伅 -CV_SDK_API -void -cv_face_algorithm_info(); - -/// @brief 鎵嬪姩鍔犺浇license鏂囦欢锛岄櫎IOS,Android骞冲彴澶栵紝閮藉彲浠ヤ笉涓诲姩璋冪敤姝ゅ嚱鏁帮紙浣嗛渶瑕佸皢license鏂囦欢鏀惧湪鍙墽琛岀▼搴忓悓涓�鐩綍锛屽悕绉板懡鍚嶄负license.lic锛�,璇ュ嚱鏁板彧鑳借鎴愬姛璋冪敤涓�娆� -/// param[in] szLicense 鎺堟潈鏂囦欢涓殑瀛楃涓诧紝license鏂囦欢鐨勫叏閮ㄥ唴瀹� -CV_SDK_API -cv_result_t -cv_face_init_license_config(const char* szLicense); - - -/// @defgroup cvface_detect cvface detect -/// @brief face position detection interfaces -/// -/// This set of interfaces processing face position & 21 or 106 points landmark detection routines -/// -/// @{ - -/// @brief 鍒涘缓浜鸿劯妫�娴嬪彞鏌� -/// @param[out] handle鍑芥暟鎴愬姛鏃惰璁剧疆涓烘湁鏁堢殑detector handle -/// @param[in] model_path 妯″瀷鏂囦欢鐨勭粷瀵硅矾寰勬垨鐩稿璺緞锛岃嫢涓嶆寚瀹氭ā鍨嬪彲涓篘ULL -/// @param[in] config 閰嶇疆閫夐」锛岄粯璁ら厤缃负CV_DETECT_ENABLE_ALIGN_21(21鍏抽敭鐐规娴�)銆傛敮鎸�106鍏抽敭鐐规娴婥V_DETECT_ENABLE_ALIGN_106鍜岃嚜鍔ㄧ缉鏀綜V_FACE_RESIZE_IMG_XXXX銆� -/// @return 杩斿洖CV_OK 澶辫触杩斿洖閿欒鐮� -CV_SDK_API -cv_result_t -cv_face_create_detector( - cv_handle_t *handle, - const char *model_path, - unsigned int config -); - -/// @brief 鑾峰彇褰撳墠浜鸿劯妫�娴嬬殑榛樿闃�鍊� -/// @param[in] handle 浜鸿劯妫�娴嬪彞鏌� -/// @param[out] threshold 浜鸿劯妫�娴嬬殑榛樿闃�鍊� -CV_SDK_API -cv_result_t cv_face_detect_get_threshold( - cv_handle_t detector_handle, - float *threshold - ); - -/// @brief 璁剧疆褰撳墠浜鸿劯妫�娴嬬殑闃�鍊硷紝闇�瑕佸湪璋冪敤cv_face_detect涔嬪墠璋冪敤姝ゅ嚱鏁帮紝闃堝�奸渶澶т簬0锛岃缃悗璋冪敤cv_face_detect_get_threshold涓烘柊璁剧疆鍚庣殑鍊�) -/// @param[in] handle 浜鸿劯妫�娴嬪彞鏌� -/// @param[in] threshold 浜鸿劯妫�娴嬫柊闃�鍊� -CV_SDK_API -cv_result_t cv_face_detect_set_threshold( - cv_handle_t detector_handle, - float threshold - ); - -/// @brief 閿�姣佸凡鍒濆鍖栫殑浜鸿劯妫�娴嬪彞鏌� -/// @param[in] detector_handle 宸插垵濮嬪寲鐨勪汉鑴告娴嬪彞鏌� -CV_SDK_API -void cv_face_destroy_detector( - cv_handle_t detector_handle -); - -/// @brief 浜鸿劯妫�娴� -/// @param[in] detector_handle 宸插垵濮嬪寲鐨勪汉鑴告娴嬪彞鏌� -/// @param[in] image 鐢ㄤ簬妫�娴嬬殑鍥惧儚鏁版嵁 -/// @param[in] piexl_format 鐢ㄤ簬妫�娴嬬殑鍥惧儚鏁版嵁鐨勫儚绱犳牸寮� -/// @param[in] image_width 鐢ㄤ簬妫�娴嬬殑鍥惧儚鐨勫搴�(浠ュ儚绱犱负鍗曚綅) -/// @param[in] image_height 鐢ㄤ簬妫�娴嬬殑鍥惧儚鐨勯珮搴�(浠ュ儚绱犱负鍗曚綅) -/// @param[in] image_stride 鐢ㄤ簬妫�娴嬬殑鍥惧儚涓瘡涓�琛岀殑璺ㄥ害(浠ュ儚绱犱负鍗曚綅) 鍥惧儚璺ㄥ害=鍥惧儚瀹藉害*鍥惧儚缁村害 -/// @param[in] orientation 鍥剧墖涓汉鑴哥殑鏂瑰悜 -/// @param[out] p_faces_array 妫�娴嬪埌鐨勪汉鑴镐俊鎭暟缁勶紝api璐熻矗鍒嗛厤鍐呭瓨锛岄渶瑕佽皟鐢╟v_face_release_detector_result鍑芥暟閲婃斁 -/// @param[out] p_faces_count 妫�娴嬪埌鐨勪汉鑴告暟閲� -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_face_detect( - cv_handle_t detector_handle, - const unsigned char *image, - cv_pixel_format pixel_format, - int image_width, - int image_height, - int image_stride, - cv_face_orientation orientation, - cv_face_t **p_faces_array, - int *p_faces_count -); - -/// @brief 閲婃斁浜鸿劯妫�娴嬭繑鍥炵粨鏋滄椂鍒嗛厤鐨勭┖闂� -/// @param[in] faces_array 妫�娴嬪埌鐨勪汉鑴镐俊鎭暟缁� -/// @param[in] faces_count 妫�娴嬪埌鐨勪汉鑴告暟閲� -CV_SDK_API -void -cv_face_release_detector_result( - cv_face_t *faces_array, - int faces_count -); - - -/// @} - - -/// @defgroup cvface_track cvface track -/// @brief face tracking interfaces -/// -/// This set of interfaces processing face tracking routines -/// -/// @{ - -#define CV_FACE_TRACKING_TWO_THREAD 0x00110000 ///< 寮�鍚弻绾跨▼浜鸿劯璺熻釜锛屽缓璁綆閰嶇疆鐜寮�鍚閫夐」銆� - -/// @brief 鍒涘缓瀹炴椂浜鸿劯璺熻釜鍙ユ焺銆傚彲浠ヨ皟鐢╟v_face_track_set_detect_face_cnt_limit璁剧疆妫�娴嬬殑鏈�澶т汉鑴告暟鐩紝榛樿涓轰笉闄愬埗浜鸿劯妫�娴嬫暟閲忋�� -/// @param[out] handle鍑芥暟鎴愬姛鏃惰璁剧疆涓烘湁鏁堢殑tracker handle -/// @param[in] model_path 妯″瀷鏂囦欢鐨勭粷瀵硅矾寰勬垨鐩稿璺緞锛岃嫢涓嶆寚瀹氭ā鍨嬪彲涓篘ULL -/// @param[in] config 榛樿閰嶇疆涓篊V_DETECT_ENABLE_ALIGN_21(21鍏抽敭鐐规娴�)銆傛敮鎸�106鍏抽敭鐐规娴婥V_DETECT_ENABLE_ALIGN_106銆佽嚜鍔ㄧ缉鏀綜V_FACE_RESIZE_IMG_XXXX鍜屽弻绾跨▼璺熻釜CV_FACE_TRACKING_TWO_THREAD銆� -/// @return 杩斿洖CV_OK 澶辫触杩斿洖閿欒鐮� -CV_SDK_API -cv_result_t -cv_face_create_tracker( - cv_handle_t *handle, - const char *model_path, - unsigned int config -); - -/// @brief 閿�姣佸凡鍒濆鍖栫殑瀹炴椂浜鸿劯璺熻釜鍙ユ焺 -/// @param[in] tracker_handle 宸插垵濮嬪寲鐨勫疄鏃朵汉鑴歌窡韪彞鏌� -CV_SDK_API -void -cv_face_destroy_tracker( - cv_handle_t tracker_handle -); - -/// @brief 瀵硅繛缁棰戝抚杩涜瀹炴椂蹇�熶汉鑴歌窡韪� -/// @param[in] tracker_handle 宸插垵濮嬪寲鐨勫疄鏃朵汉鑴歌窡韪彞鏌� -/// @param[in] image 鐢ㄤ簬妫�娴嬬殑鍥惧儚鏁版嵁 -/// @param[in] piexl_format 鐢ㄤ簬妫�娴嬬殑鍥惧儚鏁版嵁鐨勫儚绱犳牸寮� -/// @param[in] image_width 鐢ㄤ簬妫�娴嬬殑鍥惧儚鐨勫搴�(浠ュ儚绱犱负鍗曚綅) -/// @param[in] image_height 鐢ㄤ簬妫�娴嬬殑鍥惧儚鐨勯珮搴�(浠ュ儚绱犱负鍗曚綅) -/// @param[in] image_stride 鐢ㄤ簬妫�娴嬬殑鍥惧儚涓瘡涓�琛岀殑璺ㄥ害(浠ュ儚绱犱负鍗曚綅)锛屽浘鍍忚法搴�=鍥惧儚瀹藉害*鍥惧儚缁村害 -/// @param[in] orientation 瑙嗛涓汉鑴哥殑鏂瑰悜 -/// @param[out] p_faces_array 妫�娴嬪埌鐨勪汉鑴镐俊鎭暟缁勶紝api璐熻矗鍒嗛厤鍐呭瓨锛岄渶瑕佽皟鐢╟v_facesdk_release_tracker_result鍑芥暟閲婃斁 -/// @param[out] p_faces_count 妫�娴嬪埌鐨勪汉鑴告暟閲� -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_face_track( - cv_handle_t tracker_handle, - const unsigned char *image, - cv_pixel_format pixel_format, - int image_width, - int image_height, - int image_stride, - cv_face_orientation orientation, - cv_face_t **p_faces_array, - int *p_faces_count -); - -/// @brief 閲嶇疆浜鸿劯璺熻釜妫�娴嬪櫒 -/// @param[in] tracker_handle 宸插垵濮嬪寲鐨勫疄鏃朵汉鑴歌窡韪彞鏌� -CV_SDK_API -void -cv_face_reset_tracker( - cv_handle_t tracker_handle -); - -/// @brief 閲婃斁瀹炴椂浜鸿劯璺熻釜杩斿洖缁撴灉鏃跺垎閰嶇殑绌洪棿 -/// @param[in] faces_array 妫�娴嬪埌鐨勪汉鑴镐俊鎭暟缁� -/// @param[in] faces_count 妫�娴嬪埌鐨勪汉鑴告暟閲� -CV_SDK_API -void -cv_face_release_tracker_result( - cv_face_t *faces_array, - int faces_count -); - -/// @brief 璁剧疆妫�娴嬪埌鐨勬渶澶т汉鑴告暟鐩甆锛屾寔缁璽rack宸叉娴嬪埌鐨凬涓汉鑴哥洿鍒颁汉鑴告暟灏忎簬N鍐嶇户缁仛detect,濡傛灉鏈皟鐢ㄥ垯涓嶅妫�娴嬩汉鑴告暟閲忓仛闄愬埗 -/// @param[in] tracker_handle 宸插垵濮嬪寲鐨勫疄鏃朵汉鑴歌窡韪彞鏌� -/// @param[in] detect_face_cnt_limit 鏈�澶т汉鑴告暟鐩甆锛�-1琛ㄧず涓嶈涓婇檺 -/// @param[out] val 濡傛灉涓洪潪绌烘寚閽堬紝鍒欒繑鍥為噰鐢ㄧ殑鏂扮殑鍊硷紝娉ㄦ剰锛岀敱浜庡唴閮ㄧ殑闄愬埗锛� 瀹為檯閲囩敤鐨勫�煎苟涓嶄竴瀹氱瓑浜巇etect_face_cnt_limit -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� (瀹為檯璁剧疆妫�娴嬪埌鐨勬渶澶х洰鏍囨暟鐩甆鍙兘灏忎簬detect_face_cnt_limit) -CV_SDK_API -cv_result_t -cv_face_track_set_detect_face_cnt_limit( - cv_handle_t tracker_handle, - int detect_face_cnt_limit, - int* val -); - -/// @} - - -/// @defgroup cvface_verify cvface verify -/// @brief face verification interfaces -/// -/// This set of interfaces processing face verification routines. -/// -/// @{ - -/// @brief 鍒涘缓浜鸿劯楠岃瘉鍙ユ焺 -/// @param[out] handle鍑芥暟鎴愬姛鏃惰璁剧疆涓烘湁鏁堢殑verify handle -/// @param[in] model_path 妯″瀷搴撴墍鍦ㄦ枃浠跺す鐨勭粷瀵硅矾寰勬垨鐩稿璺緞(sdk涓ā鍨嬫枃浠惰矾寰勪负sdk/models/verify.model")锛屼笉鑳戒负NULL -/// @return 杩斿洖CV_OK 澶辫触杩斿洖閿欒鐮� -CV_SDK_API -cv_result_t -cv_verify_create_handle( - cv_handle_t* handle, - const char *model_path -); - -/// @brief 鍒涘缓浜鸿劯楠岃瘉鍙ユ焺鐨勫壇鏈紝涓庢棫鐨勫彞鏌勫叡浜唴瀛橈紝鍙敤浜庡绾跨▼璋冪敤 -/// @param[in] old_handle 鏃х殑浜鸿劯楠岃瘉鍙ユ焺锛屾柊鍙ユ焺閲婃斁鍚庢墠鑳介噴鏀炬棫鍙ユ焺 -/// @param[out] new_handle 鍑芥暟鎴愬姛杩斿洖浜鸿劯楠岃瘉鍙ユ焺鐨勫壇鏈� -/// @return 鎴愬姛杩斿洖CV_OK -CV_SDK_API -cv_result_t -cv_verify_duplicate_handle( - cv_handle_t old_handle, - cv_handle_t* new_handle -); - -/// @brief 閿�姣佸凡鍒濆鍖栫殑浜鸿劯楠岃瘉鍙ユ焺 -/// @param[in] verify_handle 宸插垵濮嬪寲鐨勪汉鑴搁獙璇佸彞鏌� -CV_SDK_API -void -cv_verify_destroy_handle( - cv_handle_t verify_handle -); - -/// @brief 鑾峰彇褰撳墠浜鸿劯楠岃瘉浣跨敤鐨勬ā鍨嬬増鏈彿 -/// @param[in] verify_handle 浜鸿劯楠岃瘉鍙ユ焺 -/// @return 鐗堟湰鍙� -CV_SDK_API -int -cv_verify_get_version( - cv_handle_t verify_handle -); - -/// @brief 鑾峰彇褰撳墠浜鸿劯楠岃瘉浣跨敤鐨勬ā鍨嬫彁鍙栫殑feature闀垮害锛屼笉鍖呭惈cv_feature_header_t鐨勯暱搴� -/// @param[in] verify_handle 浜鸿劯楠岃瘉鍙ユ焺 -/// @return 鐗瑰緛闀垮害 -CV_SDK_API -int -cv_verify_get_feature_length( - cv_handle_t verify_handle -); - -/// @brief 鎻愬彇浜鸿劯鐗瑰緛锛岃繑鍥炵壒寰佹暟鎹暱搴︼紝鍙互鎶婅繑鍥炴暟缁勭紪鐮佹垚瀛楃涓插悗瀛樺偍璧锋潵浠ヤ究浠ュ悗浣跨敤 -/// @param[in] verify_handle 宸插垵濮嬪寲鐨勪汉鑴搁獙璇佸彞鏌� -/// @param[in] image 鐢ㄤ簬妫�娴嬬殑鍥惧儚鏁版嵁 -/// @param[in] piexl_format 鐢ㄤ簬妫�娴嬬殑鍥惧儚鏁版嵁鐨勫儚绱犳牸寮� -/// @param[in] image_width 鐢ㄤ簬妫�娴嬬殑鍥惧儚鐨勫搴�(浠ュ儚绱犱负鍗曚綅) -/// @param[in] image_height 鐢ㄤ簬妫�娴嬬殑鍥惧儚鐨勯珮搴�(浠ュ儚绱犱负鍗曚綅) -/// @param[in] image_stride 鐢ㄤ簬妫�娴嬬殑鍥惧儚涓瘡涓�琛岀殑璺ㄥ害(浠ュ儚绱犱负鍗曚綅)锛屽浘鍍忚法搴�=鍥惧儚瀹藉害*鍥惧儚缁村害 -/// @param[in] face 杈撳叆寰呭鐞嗙殑浜鸿劯淇℃伅锛岄渶瑕佸寘鎷叧閿偣淇℃伅锛屽嵆 face.points_array 涓嶄负NULL -/// @param[out] p_feature 浜鸿劯鐗瑰緛鏁版嵁锛岄渶瑕佽皟鐢╟v_verify_release_feature鍑芥暟閲婃斁 -/// @param[out] feature_blob_size 鐗瑰緛鐨勯暱搴︼紝鍖呭惈cv_feature_header_t鐨勯暱搴︼紝涓巆v_feature_header_t->len涓�鑷� -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_get_feature( - cv_handle_t verify_handle, - const unsigned char *image, - cv_pixel_format pixel_format, - int image_width, - int image_height, - int image_stride, - const cv_face_t *face, - cv_feature_t **p_feature, - unsigned int *feature_blob_size -); - -/// @brief 鐗瑰緛淇℃伅缂栫爜鎴愬瓧绗︿覆锛岀紪鐮佸悗鐨勫瓧绗︿覆鐢ㄤ簬淇濆瓨 -/// @param[in] feature 杈撳叆鐨勭壒寰佷俊鎭� -/// @param[out] feature_str 杈撳嚭鐨勭紪鐮佸悗鐨勫瓧绗︿覆,鐢辩敤鎴峰垎閰嶅拰閲婃斁 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_serialize_feature( - const cv_feature_t *feature, - char *feature_str -); - - -/// @brief 瑙g爜瀛楃涓叉垚鐗瑰緛淇℃伅 -/// @param[in] feature_str 杈撳叆鐨勫緟瑙g爜鐨勫瓧绗︿覆锛宎pi璐熻矗鍒嗛厤鍐呭瓨锛岄渶瑕佽皟鐢╟v_verify_release_feature閲婃斁 -/// @return 杩斿洖瑙g爜鍚庣殑feature, 闇�瑕佺敤鎴蜂娇鐢� cv_common_feature_release() 閲婃斁 -CV_SDK_API -cv_feature_t * -cv_verify_deserialize_feature( - const char *feature_str -); - -/// @brief 浜鸿劯楠岃瘉 -/// @param[in] verify_handle 宸插垵濮嬪寲鐨勪汉鑴搁獙璇佸彞鏌� -/// @param[in] feature1 绗竴寮犱汉鑴哥壒寰佷俊鎭� -/// @param[in] feature2 绗簩寮犱汉鑴哥壒寰佷俊鎭� -/// @param[out] score 浜鸿劯楠岃瘉鐩镐技搴﹀緱鍒嗭紝鑼冨洿0-1锛屽緱鍒嗚秺鎺ヨ繎1瓒婄浉浼� -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_compare_feature( - cv_handle_t verify_handle, - const cv_feature_t *feature1, - const cv_feature_t *feature2, - float *score -); - -/// @brief 閲婃斁鎻愬彇浜鸿劯鐗瑰緛鏃跺垎閰嶇殑绌洪棿 -/// @param[in] feature 鎻愬彇鍒扮殑浜鸿劯鐗瑰緛淇℃伅 -CV_SDK_API -void -cv_verify_release_feature( - cv_feature_t *feature -); - -/// @} - - -/// @defgroup cvface_search cvface search -/// @brief face searching interfaces -/// -/// This set of interfaces processing face search routines. -/// -/// @{ - -/// @defgroup cvface_database cvface database for search -/// @ingroup cvface_search -/// @brief face database CURD interfaces for face searching -/// @{ - -/// @brief 鍒涘缓浜鸿劯鏁版嵁搴撳彞鏌� -/// @handle[out] 鎴愬姛鏃跺�欒缃负浜鸿劯鏁版嵁搴撳彞鏌� -/// @return[in] 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_create_db(cv_handle_t *handle); - -/// @brief 閿�姣佸凡鍒濆鍖栫殑浜鸿劯鏁版嵁搴撳彞鏌� -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -CV_SDK_API -void -cv_verify_destroy_db( - cv_handle_t db_handle -); - -/// @brief 浜鸿劯鏁版嵁搴撳鍔犳暟鎹� -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -/// @param[in] items 鐢ㄤ簬鍒涘缓鏁版嵁搴撶殑浜鸿劯鐗瑰緛淇℃伅鏁扮粍 -/// @param[in] item_count 鐗瑰緛淇℃伅鏁伴噺 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_build_db( - cv_handle_t db_handle, - cv_feature_t* const *items, - unsigned int item_count -); - -/// @brief 浜鸿劯鏁版嵁搴撳鍔犳暟鎹� -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -/// @param[in] item 寰呭姞鍏ョ殑浜鸿劯鐗瑰緛淇℃伅 -/// @param[out] idx 鍔犲叆鍚庣殑浜鸿劯鏁版嵁搴撶储寮曞�� -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_add_face( - cv_handle_t db_handle, - const cv_feature_t *item, - int *idx -); - -/// @brief 浜鸿劯鏁版嵁搴撳垹闄ゆ暟鎹� -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -/// @param[in] idx 寰呭垹闄ょ殑浜鸿劯鏁版嵁搴撶储寮曞��(涓庡姞鍏ユ椂涓�鑷�) -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_delete_face( - cv_handle_t db_handle, - int idx -); - -/// @brief 灏嗕汉鑴告暟鎹簱淇℃伅淇濆瓨涓烘暟鎹簱鏂囦欢 -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -/// @param[in] db_path 浜鸿劯鏁版嵁搴撲繚瀛樻枃浠剁殑璺緞 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_save_db( - cv_handle_t db_handle, - const char *db_path -); - -/// @brief 鍔犺浇浜鸿劯鏁版嵁搴撴枃浠� -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -/// @param[in] db_path 浜鸿劯鏁版嵁搴撲繚瀛樻枃浠剁殑璺緞 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_load_db( - cv_handle_t db_handle, - const char *db_path -); - -/// @} - -/// @brief 鎼滅储浜鸿劯鏁版嵁搴� -/// @param[in] verify_handle 宸插垵濮嬪寲鐨勪汉鑴搁獙璇佸彞鏌� -/// @param[in] db_handle 宸插垵濮嬪寲鐨勪汉鑴告暟鎹簱鍙ユ焺 -/// @param[in] query 寰呮悳绱㈢殑浜鸿劯鐗瑰緛淇℃伅 -/// @param[in] top_k 鏈�澶х殑浜鸿劯鎼滅储鏁伴噺 -/// @param[out] top_idxs 鎼滅储鍒扮殑浜鸿劯鏁版嵁搴撶储寮曞�兼暟缁�(鐢辩敤鎴峰垎閰嶅拰閲婃斁) -/// @param[out] top_scores 鎼滅储鍒扮殑浜鸿劯鐩镐技搴﹀緱鍒嗘暟缁�(鐢辩敤鎴峰垎閰嶅拰閲婃斁)锛岃寖鍥�0-1锛屽緱鍒嗚秺鎺ヨ繎1瓒婄浉浼� -/// @param result_length 瀹為檯鎼滅储鍒扮殑浜鸿劯鏁伴噺 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_search_face( - cv_handle_t verify_handle, - cv_handle_t db_handle, - const cv_feature_t *query, - unsigned int top_k, - int *top_idxs, - float *top_scores, - unsigned int *result_length -); - -/// @brief 浠庝竴缁勭壒寰佹暟缁勪腑鎼滅储浜鸿劯 -/// @param[in] verify_handle 宸插垵濮嬪寲鐨勪汉鑴搁獙璇佸彞鏌� -/// @param[in] list_feature 浜鸿劯鐗瑰緛淇℃伅鏁扮粍 -/// @param[in] list_count 浜鸿劯鐗瑰緛淇℃伅鏁伴噺 -/// @param[in] query 寰呮悳绱㈢殑浜鸿劯鐗瑰緛淇℃伅 -/// @param[in] top_k 鏈�澶х殑浜鸿劯鎼滅储鏁伴噺 -/// @param[out] top_idxs 鎼滅储鍒扮殑浜鸿劯鏁版嵁搴撶储寮曞�兼暟缁�(鐢辩敤鎴峰垎閰嶅拰閲婃斁) -/// @param[out] top_scores 鎼滅储鍒扮殑浜鸿劯鐩镐技搴﹀緱鍒嗘暟缁�(鐢辩敤鎴峰垎閰嶅拰閲婃斁)锛岃寖鍥�0-1锛屽緱鍒嗚秺鎺ヨ繎1瓒婄浉浼� -/// @param[out] result_length 瀹為檯鎼滅储鍒扮殑浜鸿劯鏁伴噺 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_search_face_from_list( - cv_handle_t verify_handle, - cv_feature_t* const *list_feature, - int list_count, - const cv_feature_t *query, - unsigned int top_k, - int *top_idxs, - float *top_scores, - unsigned int *result_length -); - -/// @} - - -/// @defgroup cvface_group cvface group -/// @brief face grouping interfaces -/// -/// This set of interfaces processing face grouping routines. -/// -/// @{ - - -/// @brief 鎵归噺浜鸿劯鍒嗙粍 -/// @param[in] verify_handle 宸插垵濮嬪寲鐨勪汉鑴搁獙璇佸彞鏌� -/// @param[in] features 浜鸿劯鐗瑰緛淇℃伅鏁扮粍 -/// @param[in] feature_count 浜鸿劯鐗瑰緛淇℃伅鏁伴噺 -/// @param[out] p_groups_array 鍒嗙粍缁撴灉锛宨ndex瀵瑰簲features鐨刬ndex锛宲_groups_array[0]琛ㄧずindex涓�0鐨刦eature瀵瑰簲鐨勫垎缁勶紝鍐呭瓨鐢辩敤鎴风鐞嗭紝p_groups_array澶у皬涓巉eature_count涓�鑷� -/// @param[out] group_count 鍒嗙粍鐨勭粍鏁帮紝闇�鐢ㄦ埛鍒濆鍖栦负0 -/// @return 鎴愬姛杩斿洖CV_OK锛屽惁鍒欒繑鍥為敊璇被鍨� -CV_SDK_API -cv_result_t -cv_verify_grouping( - cv_handle_t verify_handle, - const cv_feature_t * const *features, - unsigned int feature_count, - unsigned int *p_groups_array, - unsigned int *groups_count -); - -/// @brief 鍒濆鍖栫壒寰佹暟缁勭粨鏋� -/// @param[in] p_groups_array 鐗瑰緛鍒嗙粍缁撴灉瀛樺偍鍦板潃 -/// @param[in] feature_count 鐗瑰緛鏁扮粍闀垮害 -CV_SDK_API -void -cv_verify_initialize_labels( - unsigned int *p_groups_array, - unsigned int feature_count -); - -/// @} - - -/// @defgroup cvface_group cvface group -/// @brief face grouping interfaces -/// -/// This set of interfaces processing face grouping routines. -/// -/// @{ - -/// @brief 鍒涘缓鐗瑰緛鑱氱被鍙ユ焺 -/// @param[out] handle 杈撳嚭宸插垵濮嬪寲鐨勭壒寰佽仛绫诲彞鏌勬墍鍦ㄥ湴鍧� -/// @param[in] model 杞藉叆鐨勬ā鍨嬭矾寰� -/// @return 鎴愬姛杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒淇℃伅 -CV_SDK_API -cv_result_t -cv_face_create_clustering( -cv_handle_t *clustering_handle, -const char* model_path -); - -/// @brief 鐗瑰緛鑱氱被锛堝寘鍚閲忚仛绫伙級 -/// @param[in] handle 宸插垵濮嬪寲鐨勭壒寰佽仛绫诲彞鏌� -/// @param[in] features 寰呰仛绫荤殑鐗瑰緛鏁扮粍 -/// @param[out] labels 绫诲埆鏁扮粍, 0琛ㄧず闇�瑕侀噸鏂拌仛绫伙紝1琛ㄧず鏄崟寮犱汉鑴革紙褰撲汉鑴告暟閲忓ぇ浜庣瓑浜�2鏄墠浼氬崟鐙垎缁勶級锛�2琛ㄧず鍣煶锛堟ā绯娿�佷晶鑴搞�佷笉鏄汉鑴哥瓑锛夛紝3鍙婂叾浠ヤ笂琛ㄧず瀹為檯鍒嗙被缁撴灉 -/// @param[out] size 鐗瑰緛鍜岀被鍒殑鏁伴噺 -/// @return 鎴愬姛杩斿洖CV_OK, 鍚﹀垯杩斿洖閿欒绫诲瀷 -CV_SDK_API -cv_result_t -cv_face_clustering( -cv_handle_t clustering_handle, -const cv_feature_t * const *features, -unsigned int *labels, -int size -); - - -/// @brief 閿�姣佸凡鍒濆鍖栫殑鐗瑰緛鑱氱被鍙ユ焺 -/// @param[in] handle 宸插垵濮嬪寲鐨勭壒寰佽仛绫诲彞鏌� -CV_SDK_API -void -cv_face_clustering_destroy( -cv_handle_t clustering_handle -); - -/// @} - - -#endif // INCLUDE_CVFACE_API_CV_FACE_H_ diff --git a/RtspFace/SensetimeFaceAPIWrapper/include/cv_utils.h b/RtspFace/SensetimeFaceAPIWrapper/include/cv_utils.h deleted file mode 100644 index 6277a9f..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/include/cv_utils.h +++ /dev/null @@ -1,47 +0,0 @@ -锘�#ifndef CV_UTILS_H -#define CV_UTILS_H - -#ifdef _MSC_VER -# ifdef CV_STATIC_LIB -# define CV_SDK_API_ -# elif defined SDK_EXPORTS -# define CV_SDK_API_ __declspec(dllexport) -# else -# define CV_SDK_API_ __declspec(dllimport) -# endif -#else /* _MSC_VER */ -# ifdef SDK_EXPORTS -# define CV_SDK_API_ __attribute__((visibility ("default"))) -# else -# define CV_SDK_API_ -# endif -#endif - -typedef int cv_errcode; - -#define CV_OK 0 ///< 姝e父杩愯 - -#define CV_E_INVALIDARG -1 ///< 鏃犳晥鍙傛暟 -#define CV_E_HANDLE -2 ///< 鍙ユ焺閿欒 -#define CV_E_OUTOFMEMORY -3 ///< 鍐呭瓨涓嶈冻 -#define CV_E_FAIL -4 ///< 杩愯澶辫触锛屽唴閮ㄩ敊璇� -#define CV_E_DELNOTFOUND -5 ///< 瀹氫箟缂哄け -#define CV_E_INVALID_PIXEL_FORMAT -6 ///< 涓嶆敮鎸佺殑鍥惧儚鏍煎紡 -#define CV_E_FILE_NOT_FOUND -7 ///< 鏂囦欢涓嶅瓨鍦� -#define CV_E_INVALID_FILE_FORMAT -8 ///< 妯″瀷鏍煎紡涓嶆纭鑷村姞杞藉け璐� -#define CV_E_FILE_EXPIRE -9 ///< 妯″瀷鏂囦欢杩囨湡 - -#define CV_E_INVALID_AUTH -13 ///< license涓嶅悎娉� -#define CV_E_INVALID_APPID -14 ///< 鍖呭悕閿欒 -#define CV_E_AUTH_EXPIRE -15 ///< SDK杩囨湡 -#define CV_E_UUID_MISMATCH -16 ///< UUID涓嶅尮閰� -#define CV_E_ONLINE_AUTH_CONNECT_FAIL -17 ///< 鍦ㄧ嚎楠岃瘉杩炴帴澶辫触 -#define CV_E_ONLINE_AUTH_TIMEOUT -18 ///< 鍦ㄧ嚎楠岃瘉瓒呮椂 -#define CV_E_ONLINE_AUTH_INVALID -19 ///< 鍦ㄧ嚎鏍¢獙澶辫触 -#define CV_E_LICENSE_IS_NOT_ACTIVABLE -20 ///< license涓嶅彲婵�娲� -#define CV_E_ACTIVE_FAIL -21 ///< license婵�娲诲け璐� -#define CV_E_ACTIVE_CODE_INVALID -22 ///< 婵�娲荤爜鏃犳晥 - -#define CV_E_UNSUPPORTED -1000 ///< 涓嶆敮鎸佺殑鍑芥暟璋冪敤鏂瑰紡 - -#endif diff --git a/RtspFace/SensetimeFaceAPIWrapper/models/CLUSTERING_VERSION b/RtspFace/SensetimeFaceAPIWrapper/models/CLUSTERING_VERSION deleted file mode 100644 index 7d46d12..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/models/CLUSTERING_VERSION +++ /dev/null @@ -1 +0,0 @@ -M_Clustering_L2G_Common_4.0 \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/models/VERIFY_VERSION b/RtspFace/SensetimeFaceAPIWrapper/models/VERIFY_VERSION deleted file mode 100644 index 17be7dd..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/models/VERIFY_VERSION +++ /dev/null @@ -1 +0,0 @@ -M_Verify_XDNet_Common_4.00.0_half \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/models/clustering.model b/RtspFace/SensetimeFaceAPIWrapper/models/clustering.model deleted file mode 100644 index 58e9c30..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/models/clustering.model +++ /dev/null Binary files differ diff --git a/RtspFace/SensetimeFaceAPIWrapper/models/verify.model b/RtspFace/SensetimeFaceAPIWrapper/models/verify.model deleted file mode 100644 index e69de29..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/models/verify.model +++ /dev/null diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.cpp deleted file mode 100644 index 1850fe7..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "DBuntil.h" -#include <mysql.h> -#include <cstdio> -#include <iostream> - -DBuntil::DBuntil() -{ -} - -DBuntil::~DBuntil() -{ - if (result != NULL) - mysql_free_result(result); - mysql_close(&myCont); -} - -bool DBuntil::db_init(my_db mydb) -{ - std::cout<<"db_init(my_db mydb) start"<<std::endl; - - if(mysql_init(&myCont)!=NULL) - { - std::cout<<"init succeed"<<std::endl; - } - else - std::cout<<"init failed"<<std::endl; - - if(mysql_real_connect(&myCont, mydb.host, mydb.user, mydb.pswd, mydb.db, mydb.port, NULL, 0) != NULL) - { - std::cout<<"mysql_real_connect succeed"<<std::endl; - std::cout<<"db_init(my_db mydb) end"<<std::endl; - return true; - } - else - { - std::cout<<"mysql_real_connect failed"<<std::endl; - std::cout<<"db_init(my_db mydb) end"<<std::endl; - return false; - } - -} - -bool DBuntil::db_search(person* per) -{ - std::cout<<"db_search start"<<std::endl; - if(db_select(per)) - { - return true; - } - else - return false; -} - -bool DBuntil::db_select(person* per) -{ - std::cout<<"db_select start"<<std::endl; - sprintf( sql, "select a.p_id,b.name,b.img from face_person a,user_info b where a.face_id = %d AND a.p_id = b.pid " ,per->f_id ); - std::cout<<"==========start============"<<std::endl; - std::cout<<"per->f_id="<<per->f_id<<std::endl; - std::cout<<sql<<std::endl; - std::cout<<"==========end=============="<<std::endl; - mysql_query(&myCont, "SET NAMES utf8");//璁剧疆缂栫爜鏍煎紡 - - res = mysql_query(&myCont,sql);//鏌ヨ - if (!res) - { - result = mysql_store_result(&myCont); - if (result != NULL) - { - while (sql_row = mysql_fetch_row(result)) - { - //鑾峰彇鍏蜂綋鐨勬暟鎹� - per->p_id = atoi( sql_row[0]); - per->name = sql_row[1]; - - std::cout<<"per->p_id="<<per->p_id<<std::endl; - std::cout<<"per->name="<<per->name<<std::endl; - std::cout<<"per->f_id="<<per->f_id<<std::endl; - } - } - else - std::cout<<"result is null?"<<std::endl; - } - else - { - std::cout<<"query sql failed!"<<std::endl; - return false; - } - return true; -} - -bool DBuntil::db_add(person *per) -{ - // - sprintf( sql, "INSERT INTO user_info(NAME, img) VALUES('%s', NULL)" , per->name ); - res = mysql_query(&myCont,sql); - if(!res) - { - sprintf( sql, "INSERT INTO face_person(p_id, face_id) VALUES (LAST_INSERT_ID(), %d)" , per->f_id ); - res = mysql_query(&myCont,sql); - if(!res) - { - return true; - } - else - {} - } - else - {} - return false; -} - -bool DBuntil::db_register(person *per) -{ - if(db_add(per)) - { - return true; - } - else - return false; -} \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.h b/RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.h deleted file mode 100644 index 1aa1305..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _DBUNTIL_H_ -#define _DBUNTIL_H_ -#include <mysql.h> -struct person -{ - int p_id; - char *name; - int f_id; - //图片 -}; - -struct my_db -{ - char user[25]; - char pswd[25]; - char host[25]; - char db[25]; - unsigned int port; -}; - -class DBuntil -{ -public: - DBuntil(); - ~DBuntil(); - - bool db_search(person *p); - bool db_register(person *p); - bool db_init(my_db mydb); - - MYSQL myCont; - MYSQL_RES *result; - MYSQL_ROW sql_row; -private: - bool db_add(person *per); - int db_update(); - bool db_select(person *per); - char sql[1024]; - int res; -}; - -#endif \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/FaceDBPool.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/FaceDBPool.cpp deleted file mode 100644 index 680d1e0..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/FaceDBPool.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include "FaceDBPool.h" -#include "../../logger.h" -#include "faceAPI.h" - -#include <pthread.h> -#include <map> - -#define PLP_MUTEX_LOCK(mut,_ret) if (mut != nullptr) {\ - int ret = pthread_mutex_lock((pthread_mutex_t*)mut); \ - if(ret != 0) \ - { \ - LOG_ERROR << "pthread_mutex_lock " << #mut << ": " << ret << std::endl; \ - return _ret; \ - } \ -} - -#define PLP_MUTEX_UNLOCK(mut,_ret) if (mut != nullptr) {\ - int ret = pthread_mutex_unlock((pthread_mutex_t*)mut); \ - if(ret != 0) \ - { \ - LOG_ERROR << "pthread_mutex_unlock " << #mut << ": " << ret << std::endl; \ - return _ret; \ - } \ -} - -struct MutexLocker -{ - pthread_mutex_t* mut; - MutexLocker(void* _mut) : mut((pthread_mutex_t*)_mut) - { - PLP_MUTEX_LOCK(mut,); - } - ~MutexLocker() - { - PLP_MUTEX_UNLOCK(mut,); - } -}; - -struct ThreadSafeFaceDB -{ - int dbid; - pthread_mutex_t db_mutex; - FaceDB* api; - - ThreadSafeFaceDB() : dbid(-1), db_mutex(), api(nullptr) - { - pthread_mutex_init(&db_mutex, NULL); - } - - ~ThreadSafeFaceDB() - { - pthread_mutex_destroy(&db_mutex); - } -}; - -typedef std::map<int, ThreadSafeFaceDB*> facedb_map_t; - -FaceDBPool::FaceDBPool() : - pool_mutex(nullptr), face_db_map(nullptr) -{ - pool_mutex = new pthread_mutex_t; - pthread_mutex_init((pthread_mutex_t*)pool_mutex, NULL); - - face_db_map = new facedb_map_t(); -} - -FaceDBPool::~FaceDBPool() -{ - facedb_map_t* _face_db_map = (facedb_map_t*)face_db_map; - for (facedb_map_t::iterator iter = _face_db_map->begin(); iter != _face_db_map->end(); ++iter) - { - iter->second->api->finally(); - delete iter->second->api; - delete iter->second; - } - - _face_db_map->clear(); - - pthread_mutex_destroy((pthread_mutex_t*)pool_mutex); - delete (pthread_mutex_t*)pool_mutex; - pool_mutex = nullptr; -} - -void FaceDBPool::manage(int dbid, FaceDB* db) -{ - if (dbid < 0 || db == nullptr) - return; - - MutexLocker _ml(pool_mutex); - - facedb_map_t* _face_db_map = (facedb_map_t*)face_db_map; - - if (_face_db_map->find(dbid) != _face_db_map->end()) - return; - - ThreadSafeFaceDB* tsfdb = new ThreadSafeFaceDB; - tsfdb->dbid = dbid; - tsfdb->api = db; - - _face_db_map->insert(std::make_pair(dbid, tsfdb)); -} - -void FaceDBPool::unmanage(int dbid) -{ - MutexLocker _ml(pool_mutex); - - facedb_map_t* _face_db_map = (facedb_map_t*)face_db_map; - facedb_map_t::iterator iter = _face_db_map->find(dbid); - if (iter == _face_db_map->end()) - return; - - iter->second->api->finally(); - delete iter->second->api; - delete iter->second; - - _face_db_map->erase(iter); -} - -FaceDB* FaceDBPool::get_free(int dbid) -{ - ThreadSafeFaceDB* tsfdb = nullptr; - { - //avoid dead lock - MutexLocker _ml(pool_mutex); - - facedb_map_t* _face_db_map = (facedb_map_t*)face_db_map; - if (_face_db_map->empty()) - return nullptr; - - facedb_map_t::iterator iter = _face_db_map->find(dbid); - if (iter == _face_db_map->end()) - return nullptr; - - tsfdb = iter->second; - } - - if (tsfdb != nullptr) - { - PLP_MUTEX_LOCK(&(tsfdb->db_mutex), nullptr); - return tsfdb->api; - } -} - -void FaceDBPool::release(int dbid) -{ - ThreadSafeFaceDB* tsfdb = nullptr; - { - //avoid dead lock - MutexLocker _ml(pool_mutex); - - facedb_map_t* _face_db_map = (facedb_map_t*)face_db_map; - if (_face_db_map->empty()) - return; - - facedb_map_t::iterator iter = _face_db_map->find(dbid); - if (iter == _face_db_map->end()) - return; - - tsfdb = iter->second; - } - - if (tsfdb != nullptr) - { - PLP_MUTEX_UNLOCK(&(tsfdb->db_mutex),); - } -} diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/FaceDBPool.h b/RtspFace/SensetimeFaceAPIWrapper/src/FaceDBPool.h deleted file mode 100644 index f56c5a3..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/FaceDBPool.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _FACEDBPOOL_H_ -#define _FACEDBPOOL_H_ - -#include "faceAPI.h" - -class FaceDBPool -{ -public: - FaceDBPool(); - ~FaceDBPool(); - - void manage(int dbid, FaceDB* db); - void unmanage(int dbid); - - FaceDB* get_free(int dbid); - void release(int dbid); - - bool wait_free() { return true; } - bool notify_free() { return true; } - -private: - void* pool_mutex; - void* face_db_map; -}; - -#endif diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/Makefile b/RtspFace/SensetimeFaceAPIWrapper/src/Makefile deleted file mode 100644 index d3036c1..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -锘緾XX=g++ -CXXFLAGS:=-I../include -CXXFLAGS+=/usr/include/mysql -CXXFLAGS+=$(shell pkg-config --cflags opencv) - -LDFLAGS+=-L../libs/lib_dummy /usr/lib64/mysql - -LIBS:=-lcvface_api -lpthread -lmysqlclient -LIBS+=$(shell pkg-config --libs opencv) - -OBJ = faceAPI.o db.o tools.o main.o - -demo: $(OBJ) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o demo $(OBJ) $(LIBS) -main.o : test.cpp - $(CXX) $(CXXFLAGS) $(LDFLAGS) -c test.cpp -o main.o -tools.o : tools.h - $(CXX) $(CXXFLAGS) $(LDFLAGS) -c tools.cpp -o tools.o -db.o : DBuntil.h - $(CXX) $(CXXFLAGS) -o db.o -c DBuntil.cpp $(LDFLAGS) $(LIBS) -faceAPI.o : faceAPI.h - $(CXX) $(CXXFLAGS) $(LDFLAGS) -c faceAPI.cpp -o faceAPI.o -#faceDB.o : faceDB.cpp -# $(CXX) $(CXXFLAGS) $(LDFLAGS) -c faceDB.cpp -o faceDB.o - -.PHONY: clean -clean: - rm -f *.o demo \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/db/DBuntil.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/db/DBuntil.cpp deleted file mode 100644 index 27a2c76..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/db/DBuntil.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "DBuntil.h" -#include <mysql.h> -#include <cstdio> -#include <iostream> - - -MYSQL myCont; -MYSQL_RES *result; -MYSQL_ROW sql_row; - -DBuntil::DBuntil(){} - -DBuntil::DBuntil(my_db mydb) -{ - if(mysql_init(&myCont)!=NULL) - { - std::cout<<"init succeed"<<std::endl; - } - else - std::cout<<"init failed"<<std::endl; - - if(mysql_real_connect(&myCont, mydb.host, mydb.user, mydb.pswd, mydb.db, mydb.port, NULL, 0) != NULL) - { - std::cout<<"mysql_real_connect succeed"<<std::endl; - } - else - std::cout<<"mysql_real_connect failed"<<std::endl; -} - -DBuntil::~DBuntil() -{ - if (result != NULL) - mysql_free_result(result); - - mysql_close(&myCont); -} - -*person DBuntil::db_rearch(int f_id) -{ - person p= {0,""}; - db_select(f_id,&p); - //瀵圭粨鏋勪綋璧嬪�� - return &p; -} - -bool DBuntil::db_select(int f_id,person* per) -{ - - sprintf( sql, "select a.p_id,b.`name`,b.img from face_person a,user_info b where a.face_id = %d AND a.p_id = b.pid " , f_id ); - - mysql_query(&myCont, "SET NAMES utf8"); //璁剧疆缂栫爜鏍煎紡 - res = mysql_query(&myCont,sql);//鏌ヨ - if (!res) - { - result = mysql_store_result(&myCont); - if (result) - { - while (sql_row = mysql_fetch_row(result)) - { - //鑾峰彇鍏蜂綋鐨勬暟鎹� - per->p_id = atoi( sql_row[0]); - per->name = sql_row[1]; - } - } - } - else - { - std::cout<<"query sql failed!"<<std::endl; - return false; - } - return true; -} - -bool DBuntil::db_add(int f_id,person *per) -{ - // - sprintf( sql, "INSERT INTO user_info(NAME, img) VALUES('%s', NULL)" , per->name ); - res = mysql_query(&myCont,sql); - if(!res) - { - sprintf( sql, "INSERT INTO face_person(p_id, face_id) VALUES (LAST_INSERT_ID(), %d)" , f_id ); - res = mysql_query(&myCont,sql); - if(!res) - { - return true; - } - } - return false; -} - -bool DBuntil::db_register(int f_id,person *per) -{ - if(db_add(f_id,per)){ - return true; - } - return false; -} \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/db/DBuntil.h b/RtspFace/SensetimeFaceAPIWrapper/src/db/DBuntil.h deleted file mode 100644 index 337b371..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/db/DBuntil.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _DBUNTIL_H_ -#define _DBUNTIL_H_ - -struct person { - int p_id; - char *name; - int f_id; - //图片 -}; - -struct my_db { - char user[25]; - char pswd[25]; - char host[25]; - char db[25]; - unsigned int port; -}; - -class DBuntil -{ - -public: - DBuntil(); - DBuntil(my_db mydb); - ~DBuntil(); - person db_rearch(int f_id); - - bool db_register(int f_id,person *p); - -private: - - bool db_add(int f_id,person *per); - int db_update(); - bool db_select(int f_id,person *per); - - char sql[1024]; - int res; -}; - - -#endif \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/db/Makefile b/RtspFace/SensetimeFaceAPIWrapper/src/db/Makefile deleted file mode 100644 index 0d21f84..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/db/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CXX = g++ - -CXXFLAGS:=-I/usr/include/mysql - -LDFLAGS:=-L/usr/lib64/mysql - -LIBS:=-lmysqlclient -OBJ = main.o db.o - -demo : $(OBJ) - $(CXX) $(CXXFLAGS) -o demo $(OBJ) $(LDFLAGS) $(LIBS) -main.o : main.cpp - $(CXX) $(CXXFLAGS) -o main.o -c main.cpp $(LDFLAGS) $(LIBS) -db.o : DBuntil.cpp - $(CXX) $(CXXFLAGS) -o db.o -c DBuntil.cpp $(LDFLAGS) $(LIBS) -clean : - rm -f *.o demo diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/db/demo.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/db/demo.cpp deleted file mode 100644 index 9daea23..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/db/demo.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include <Windows.h> -#include <mysql.h> -#include <string> -#include <iostream> - -using namespace std; -#pragma comment(lib,"D:\\Program Files\\mysql-5.7.17-winx64\\lib\\libmysql.lib") - -int main() -{ - - const char user[] = "root"; - const char pswd[] = ""; - const char host[] = "localhost"; - const char db[] = "demo"; - unsigned int port = 3306; - MYSQL myCont; - MYSQL_RES *result; - MYSQL_ROW sql_row; - int res; - char *sql; - mysql_init(&myCont); - - - if (mysql_real_connect(&myCont, host, user, pswd, db, port, NULL, 0) != NULL) - { - sql="INSERT INTO user_info (NAME, img) VALUES ('c', null)"; - res = mysql_query(&myCont,sql);//查询 - if (res) - { - cout << "INSERT sql1 failed!" << endl; - }else - { - sql="INSERT INTO face_person (p_id, face_id) VALUES (LAST_INSERT_ID(), 2)"; - res = mysql_query(&myCont,sql); - if (res) - { - cout << "INSERT sql2 failed!" << endl; - } - } - - printf("MySQL client version: %s\n", mysql_get_client_info()); - sql="select a.pid,a.name,a.img,b.face_id from user_info a,face_person b where a.pid = b.p_id"; - mysql_query(&myCont, "SET NAMES gbk"); //设置编码格式 - res = mysql_query(&myCont,sql);//查询 - cout<<res<< endl; - if (!res) - { - result = mysql_store_result(&myCont); - if (result) - { - while (sql_row = mysql_fetch_row(result))//获取具体的数据 - { - cout<<" pid:" << sql_row[0] << endl; - cout<<" name:" << sql_row[1] << endl; - //cout<<" img:" << sql_row[2] << endl; - cout<<" faceid:" << sql_row[3] << endl; - cout<< endl; - } - } - } - else - { - cout << "query sql failed!" << endl; - } - - } - else - { - cout << "connect failed!" << endl; - } - - - - if (result != NULL) - mysql_free_result(result); - - mysql_close(&myCont); - system("pause"); - return 0; - -} \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/db/main.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/db/main.cpp deleted file mode 100644 index a9304df..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/db/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include <string> -#include <iostream> - -#include "DBuntil.h" - -using namespace std; - - -int main(int argc, char *argv[]) -{ - int i=2; - my_db mydb={"root","Basic@2017","localhost","demo",3306}; - - DBuntil dbu = DBuntil(mydb); - person p={0,"test"}; - if(dbu.db_register(i,&p)){ - cout<<"add succeed"<<endl; - }else - cout<<"add false"<<endl; - p={}; - - p = dbu.db_rearch(i); - if(p.p_id != NULL) - { - cout<<p.p_id<<endl; - cout<<p.name<<endl; - }else - cout<<"person is null"<<endl; - - return 0; -} diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/db/run.sh b/RtspFace/SensetimeFaceAPIWrapper/src/db/run.sh deleted file mode 100644 index 425936f..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/db/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./demo diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.cpp deleted file mode 100644 index 23e5868..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.cpp +++ /dev/null @@ -1,322 +0,0 @@ -锘�#include "faceAPI.h" -#include <iostream> - - -FaceAPI::FaceAPI() -{ - //鍒涘缓闈欐�佷汉鑴歌瘑鍒彞鏌勶紝鍚屾椂鍒涘缓鐘舵�佹爣閲� - cv_result_t cv_result = 0; - - //FaceDB* f_db = FaceDB.GetInstance(); - fdb=new FaceDB(); -} - -FaceAPI::~FaceAPI() -{ - -} - -int FaceAPI::do_init(char* db_path) -{ - return fdb->init(db_path); -} - -//@brief 鎼滅储鍔熻兘 -//@param 鍥剧墖 -//@return 浜鸿劯id -int FaceAPI::do_reasch(cv::Mat image) -{ - if (!image.data) - { - fprintf(stderr, "fail to read img\n"); - return -1; - } - else - fprintf(stderr, "read img\n"); - p_f = fdb->extract_feature(image); - fprintf(stderr, "fdb->extract_feature(image)\n"); - if (!p_f) - { - fprintf(stderr, "p_f is null\n"); - return -2; - } - return p_img_search(p_f); -} - -//@brief 鎼滅储鍔熻兘 -//@param 瀛楃涓叉牸寮忕殑鐗瑰緛鍊� -//@return 浜鸿劯id -int FaceAPI::do_reasch(char* s_feature) -{ - get_feature(s_feature,p_f); - return p_img_search(p_f); -} - -//@brief 娉ㄥ唽鍔熻兘 -//@param 鍥剧墖 -//@return 浜鸿劯id -int FaceAPI::do_register(cv::Mat image) -{ - p_f = fdb->extract_feature(image); - int indx = fdb->db_add(p_f); - if(fdb->finally()) - { - fprintf(stderr, "fdb->finally()%d\n",indx); - return indx; - } - - return -2; -} - -//@brief 鍦ㄦ暟鎹簱涓悳绱汉鑴竔d -//@param 鐗瑰緛鍊� -//@return 浜鸿劯id -int FaceAPI::p_img_search(cv_feature_t *p_feature) -{ - std::cout<<"p img search"<<std::endl; - - return fdb->search_db(p_feature); -} - -//@brief 鐗瑰緛鍊艰浆鎹负瀛楃涓� -//@param 鐗瑰緛鍊� -//@param 瀛楃涓叉牸寮忕殑鐗瑰緛鍊� -//@return 鐘舵�侀噺 -int FaceAPI::get_char(cv_feature_t *p_feature,char* feature_str) -{ - - return cv_verify_serialize_feature(p_feature,feature_str); -} - -//@brief 瀛楃涓茶浆鎹负鐗瑰緛鍊� -//@param 瀛楃涓叉牸寮忕殑鐗瑰緛鍊� -//@param 鐗瑰緛鍊� -//@return 鐘舵�侀噺 -int FaceAPI::get_feature(char *feature_str,cv_feature_t *p_feature) -{ - - p_feature = cv_verify_deserialize_feature(feature_str); - if(p_feature != NULL) - { - return 0; - } - else - return -1; -} - -//faceDB瀹炵幇閮ㄥ垎 -//"./out1.db" -//char *db_path = "out.db"; -FaceDB::FaceDB() -{ - -} - -FaceDB::~FaceDB() {} - -//鍒濆鍖栬缃� -bool FaceDB::init(char* db_path_t) -{ - - db_path = db_path_t; - - //鍔犺浇涓�娆″彲澶氭浣跨敤銆� - cv_verify_create_handle(&handle_verify, "../models/verify.model"); - fprintf(stderr, "create cv_verify_create_handle\n"); - cv_face_create_detector(&handle_detect, NULL, CV_DETECT_ENABLE_ALIGN_21); - fprintf(stderr, "create cv_face_create_detector\n"); - - - // 鍒涘缓浜鸿劯鏁版嵁搴撳彞鏌勶紝鍦╠b_save()涓紝鏁版嵁搴撲繚瀛樻垚鍔燂紝浼氶噴鏀捐鍙ユ焺 - cv_verify_create_db(&handle_db); - fprintf(stderr, "create cv_verify_create_db\n"); - - - if(db_load()) - { - fprintf(stderr, "db load\n"); - return true; - } - fprintf(stderr, "db load falied\n"); - return false; -} - -//璋冪敤鏁版嵁搴撲繚瀛� -bool FaceDB::finally() -{ - if(db_save()) - { - - return true; - } - - return false; - -} - -//@brief 鏁版嵁搴撴坊鍔犳暟鎹� -//@param 鐗瑰緛鍊� -//@return 浜鸿劯id锛屾坊鍔犲け璐ヨ繑鍥�-1 -int FaceDB::db_add(cv_feature_t* p_feature) -{ - int idx; - cv_result_t cv_result = cv_verify_add_face(handle_db, p_feature, &idx); - if (cv_result != CV_OK) - { - fprintf(stderr, "cv_verify_add_face failed, error code %d\n", cv_result); - return -1; - } - cv_verify_release_feature(p_feature); - return idx; -} - - -//@brief 淇濆瓨鏁版嵁搴� -//@return 鐘舵�侀噺 -bool FaceDB::db_save() -{ - cv_result = cv_verify_save_db(handle_db, db_path); - if (cv_result != CV_OK) - { - fprintf(stderr, "cv_verify_save_db failed, error code %d\n", cv_result); - return false; - } - else - { - fprintf(stderr, "save done!\n"); - } - - cv_verify_destroy_db(handle_db); - fprintf(stderr, "db_save end!\n"); - return true; -} - -//@brief 鍔犺浇鏁版嵁搴� -//@return 鐘舵�侀噺 -bool FaceDB::db_load() -{ - if (handle_db != NULL) - { - fprintf(stderr, "handle_db is not null!%s\n",db_path); - } - else - { - fprintf(stderr, "handle_db is null!%s\n",db_path); - } - cv_result = cv_verify_load_db(handle_db, db_path); - if (cv_result != CV_OK) - { - fprintf(stderr, "cv_verify_load_db failed, error code %d\n", cv_result); - return false; - } - else - { - fprintf(stderr, "load done!\n"); - } - - return true; -} - -//@brief 鎼滅储鏁版嵁搴� -//@param 浜鸿劯鐗瑰緛鍊� -//@return 浜鸿劯id -int FaceDB::search_db(cv_feature_t *p_feature) -{ - int indx=-1; - //鏌ヨ鍓�10鏉� - int top_k = 3; - int *top_idxs = new int[top_k]; - float *top_scores = new float[top_k]; - unsigned int result_length = 0; - cv_result = cv_verify_search_face(handle_verify, handle_db, - p_feature, top_k, - top_idxs, top_scores, &result_length); - - - if (cv_result == CV_OK) - { - //杈撳嚭妫�鏌ョ粨鏋� - for (unsigned int t = 0; t < result_length; t++) - { - // const cv_feature_t item = result[t].item; - fprintf(stderr, "%d\t", top_idxs[t]); - fprintf(stderr, "%0.2f\n", top_scores[t]); - } - } - else - { - fprintf(stderr, "cv_verify_search_face failed, error code %d\n", cv_result); - } - std::cout<<"this is hits"<<std::endl; - if (top_scores[0] >= 0.7) - { - indx=top_idxs[0]; - std::cout<<"indx="<<indx<<std::endl; - } - if (top_idxs) - { - delete[]top_idxs; - } - if (top_scores) - { - delete[]top_scores; - } - cv_verify_release_feature(p_feature); - std::cout<<"return indx"<<std::endl; - return indx; -} - -//@brief 鎻愬彇鐗瑰緛鍊� -//@param 鍥剧墖 -//@return 鐗瑰緛鍊� -cv_feature_t* FaceDB::extract_feature(cv::Mat image_color) -{ - if (handle_verify != NULL) - { - fprintf(stderr, "fdb.handle_verify is not null!\n"); - } - else - { - fprintf(stderr, "fdb.handle_verify is null!\n"); - } - - //璇ュ彉閲忓唴瀛樹細鍦╠b_add()涓紝娣诲姞鎴愬姛鍚庨噴鏀俱�� - cv_feature_t *p_feature = NULL; - - cv_face_t *p_face = NULL; - int face_count = 0; - cv_result_t st_result = CV_OK; - fprintf(stderr, "cv_face_detect start!\n"); - if (handle_detect != NULL) - { - fprintf(stderr, "handle_detect is not null!\n"); - } - else - { - fprintf(stderr, "handle_detect is null!\n"); - } - st_result = cv_face_detect(handle_detect, image_color.data, CV_PIX_FMT_BGR888, - image_color.cols, image_color.rows, image_color.step, - CV_FACE_UP, &p_face, &face_count); - fprintf(stderr, "cv_face_detect end!\n"); - if (face_count >= 1) - { - fprintf(stderr, "cv_verify_get_feature end!\n"); - st_result = cv_verify_get_feature(handle_verify, - (unsigned char *)image_color.data, CV_PIX_FMT_BGR888, - image_color.cols, image_color.rows, image_color.step, - p_face, &p_feature, NULL); - fprintf(stderr, "cv_verify_get_feature end!\n"); - if (st_result != CV_OK) - { - fprintf(stderr, "cv_verify_get_feature failed, error code %d\n", st_result); - } - } - else - { - fprintf(stderr, "can't find face in "); - } - // release the memory of face - cv_face_release_detector_result(p_face, face_count); - return p_feature; -} \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.h b/RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.h deleted file mode 100644 index 5dd5201..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _FACEAPI_H_ -#define _FACEAPI_H_ - -#include <opencv2/opencv.hpp> -#include <cv_face.h> -#include "time_helper.h" - -class FaceDB; - -class FaceAPI -{ -public: - FaceAPI(); - ~FaceAPI(); - int do_init(char* db_path); - //查询 前台调用 - int do_reasch(char* s_feature); - int do_reasch(cv::Mat image); - //注册 后台另一进程调用 - int do_register(cv::Mat image); - -private: - - //调用搜索 - int p_img_search(cv_feature_t *p_feature); - - //转换函数 - int get_char(cv_feature_t *p_feature,char* feature_str); - int get_feature(char *feature_str,cv_feature_t *p_feature); - - FaceDB *fdb; - cv_feature_t* p_f; -}; - - -class FaceDB -{ -public: - FaceDB(); - virtual ~FaceDB(); - - //人脸验证 - cv_handle_t handle_verify; - //数据库操作 - cv_handle_t handle_db; - //静态人脸识别 - cv_handle_t handle_detect; - - //初始化 - bool init(char* db_path); - //保存数据库 - bool finally(); - - //搜索SDK数据库 - int search_db(cv_feature_t* p_feature ); - //添加记录 - int db_add(cv_feature_t* p_feature); - - - //提取特征值 - cv_feature_t *extract_feature(cv::Mat image_color); - -private: - cv_result_t cv_result; - char* db_path; - - //加载sdk数据库 - bool db_load(); - bool db_save(); -}; - -#endif diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/faceDB.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/faceDB.cpp deleted file mode 100644 index 62e2695..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/faceDB.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "faceDB.h" -//faceDB实现部分 -//"./out1.db" -//char *db_path = "out.db"; - -FaceDB::FaceDB() -{ - -} - -FaceDB::~FaceDB() {} - -//初始化设置 -bool FaceDB::init(char* db_path_t) -{ - - db_path = db_path_t; - - //加载一次可多次使用。 - cv_verify_create_handle(&handle_verify, "../models/verify.model"); - fprintf(stderr, "create cv_verify_create_handle\n"); - cv_face_create_detector(&handle_detect, NULL, CV_DETECT_ENABLE_ALIGN_21); - fprintf(stderr, "create cv_face_create_detector\n"); - - - // 创建人脸数据库句柄,在db_save()中,数据库保存成功,会释放该句柄 - cv_verify_create_db(&handle_db); - fprintf(stderr, "create cv_verify_create_db\n"); - - - if(db_load()) - { - fprintf(stderr, "db load\n"); - return true; - } - fprintf(stderr, "db load falied\n"); - return false; -} - -//调用数据库保存 -bool FaceDB::finally() -{ - if(db_save()) - { - return true; - } - - return false; - -} - -//@brief 数据库添加数据 -//@param 特征值 -//@return 人脸id,添加失败返回-1 -int FaceDB::db_add(cv_feature_t* p_feature) -{ - int idx; - cv_result_t cv_result = cv_verify_add_face(handle_db, p_feature, &idx); - if (cv_result != CV_OK) { - fprintf(stderr, "cv_verify_add_face failed, error code %d\n", cv_result); - return -1; - } - cv_verify_release_feature(p_feature); - return idx; -} - - -//@brief 保存数据库 -//@return 状态量 -bool FaceDB::db_save() -{ - cv_result = cv_verify_save_db(handle_db, db_path); - if (cv_result != CV_OK) { - fprintf(stderr, "cv_verify_save_db failed, error code %d\n", cv_result); - return false; - } else { - fprintf(stderr, "save done!\n"); - } - cv_verify_destroy_db(handle_db); - return true; -} - -//@brief 加载数据库 -//@return 状态量 -bool FaceDB::db_load() -{ - if (handle_db != NULL) { - fprintf(stderr, "handle_db is not null!%s\n",db_path); - } else { - fprintf(stderr, "handle_db is null!%s\n",db_path); - } - cv_result = cv_verify_load_db(handle_db, db_path); - if (cv_result != CV_OK) { - fprintf(stderr, "cv_verify_load_db failed, error code %d\n", cv_result); - return false; - } else { - fprintf(stderr, "load done!\n"); - } - - return true; -} - -//@brief 搜索数据库 -//@param 人脸特征值 -//@return 人脸id -int FaceDB::search_db(cv_feature_t *p_feature) -{ - int indx=-1; - //查询前10条 - int top_k = 3; - int *top_idxs = new int[top_k]; - float *top_scores = new float[top_k]; - unsigned int result_length = 0; - cv_result = cv_verify_search_face(handle_verify, handle_db, - p_feature, top_k, - top_idxs, top_scores, &result_length); - - - if (cv_result == CV_OK) { - //输出检查结果 - for (unsigned int t = 0; t < result_length; t++) { - // const cv_feature_t item = result[t].item; - fprintf(stderr, "%d\t", top_idxs[t]); - fprintf(stderr, "%0.2f\n", top_scores[t]); - } - } else { - fprintf(stderr, "cv_verify_search_face failed, error code %d\n", cv_result); - } - std::cout<<"this is hits"<<std::endl; - if (top_scores[0] != 0) { - indx=top_idxs[0]; - std::cout<<"indx="<<indx<<std::endl; - } - if (top_idxs) { - delete[]top_idxs; - } - if (top_scores) { - delete[]top_scores; - } - cv_verify_release_feature(p_feature); - std::cout<<"return indx"<<std::endl; - return indx; -} - -//@brief 提取特征值 -//@param 图片 -//@return 特征值 -cv_feature_t* FaceDB::extract_feature(cv::Mat image_color) -{ - if (handle_verify != NULL) { - fprintf(stderr, "fdb.handle_verify is not null!\n"); - } else { - fprintf(stderr, "fdb.handle_verify is null!\n"); - } - - //该变量内存会在db_add()中,添加成功后释放。 - cv_feature_t *p_feature = NULL; - - cv_face_t *p_face = NULL; - int face_count = 0; - cv_result_t st_result = CV_OK; - st_result = cv_face_detect(handle_detect, image_color.data, CV_PIX_FMT_BGR888, - image_color.cols, image_color.rows, image_color.step, - CV_FACE_UP, &p_face, &face_count); - if (face_count >= 1) { - st_result = cv_verify_get_feature(handle_verify, - (unsigned char *)image_color.data, CV_PIX_FMT_BGR888, - image_color.cols, image_color.rows, image_color.step, - p_face, &p_feature, NULL); - if (st_result != CV_OK) { - fprintf(stderr, "cv_verify_get_feature failed, error code %d\n", st_result); - } - } else { - fprintf(stderr, "can't find face in "); - } - // release the memory of face - cv_face_release_detector_result(p_face, face_count); - return p_feature; -} \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/faceDB.h b/RtspFace/SensetimeFaceAPIWrapper/src/faceDB.h deleted file mode 100644 index 6895c0c..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/faceDB.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _FACEDB_H_ -#define _FACEDB_H_ - -#include <opencv2/opencv.hpp> -#include <cv_face.h> -#include "time_helper.h" -class FaceDB -{ -public: - FaceDB(); - virtual ~FaceDB(); - - //人脸验证 - cv_handle_t handle_verify; - //数据库操作 - cv_handle_t handle_db; - //静态人脸识别 - cv_handle_t handle_detect; - - //初始化 - bool init(char* db_path); - //保存数据库 - bool finally(); - - //搜索SDK数据库 - int search_db(cv_feature_t* p_feature ); - //添加记录 - int db_add(cv_feature_t* p_feature); - - - //提取特征值 - cv_feature_t *extract_feature(cv::Mat image_color); - -private: - cv_result_t cv_result; - char* db_path; - - //加载sdk数据库 - bool db_load(); - bool db_save(); -}; -#endif \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/out.db b/RtspFace/SensetimeFaceAPIWrapper/src/out.db deleted file mode 100644 index 83608c5..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/out.db +++ /dev/null Binary files differ diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/run.sh b/RtspFace/SensetimeFaceAPIWrapper/src/run.sh deleted file mode 100644 index 66cf2b1..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -LD_LIBRARY_PATH=../libs/lib_dummy ./demo ../test_img/face_01.jpg \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/sample_face_track.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/sample_face_track.cpp deleted file mode 100644 index 2d01890..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/sample_face_track.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include <vector> -#include <stdio.h> -#include <cv_face.h> - -#include <opencv2/opencv.hpp> - -using namespace std; -using namespace cv; - -int main(int argc, char *argv[]) -{ - if (argc < 2) { - fprintf(stderr, "test_sample_face_track [alignment point size(21 or 106)] [detect face cont limit]\n"); - fprintf(stderr, "for example: \"test_sample_face_track 21 1\"\n"); - return -1; - } - - VideoCapture capture; - capture.open(0); // open the camera - if (!capture.isOpened()) { - fprintf(stderr, "can not open camera!\n"); - return -1; - } - namedWindow("TrackingTest"); - int frame_width = capture.get(CV_CAP_PROP_FRAME_WIDTH); - int frame_height = capture.get(CV_CAP_PROP_FRAME_HEIGHT); - - int point_size = atoi(argv[1]); - int config; - if (point_size == 21) { - config = CV_DETECT_ENABLE_ALIGN_21; - } else if (point_size == 106) { - config = CV_DETECT_ENABLE_ALIGN_106; - } else { - fprintf(stderr, "alignment point size must be 21 or 106\n"); - return -1; - } - - cv_handle_t handle_track = NULL; - cv_result_t cv_result = CV_OK; - do { - // init handle - cv_result = cv_face_create_tracker(&handle_track, NULL, config | CV_FACE_TRACKING_TWO_THREAD); - if (cv_result != CV_OK) { - fprintf(stderr, "cv_face_create_tracker failed, error code %d\n", cv_result); - break; - } - - if (argc == 3) { - int detect_face_cnt_limit = atoi(argv[2]); - if (detect_face_cnt_limit < -1) { - detect_face_cnt_limit = -1; - } - int val = 0; - cv_result = cv_face_track_set_detect_face_cnt_limit(handle_track, detect_face_cnt_limit, &val); - if (cv_result != CV_OK) { - fprintf(stderr, "cv_face_track_set_detect_face_cnt_limit failed, error : %d\n", cv_result); - break; - } else { - fprintf(stderr, "detect face count limit : %d\n", val); - } - } - - Mat bgr_frame; - cv_face_t *p_face = NULL; - int face_count = 0; - while (capture.read(bgr_frame)) { // CV_PIX_FMT_BGR888 - resize(bgr_frame, bgr_frame, Size(frame_width, frame_height), 0, 0, - INTER_LINEAR); - // realtime track - face_count = 0; - cv_result = cv_face_track(handle_track, bgr_frame.data, CV_PIX_FMT_BGR888, - bgr_frame.cols, bgr_frame.rows, bgr_frame.step, - CV_FACE_UP, &p_face, &face_count); - if (cv_result != CV_OK) { - fprintf(stderr, "cv_face_track failed, error : %d\n", cv_result); - cv_face_release_tracker_result(p_face, face_count); - break; - } - - for (int i = 0; i < face_count; i++) { - fprintf(stderr, "face: %d-----[%d, %d, %d, %d]-----id: %d\n", i, - p_face[i].rect.left, p_face[i].rect.top, - p_face[i].rect.right, p_face[i].rect.bottom, p_face[i].ID); - fprintf(stderr, "face pose: [yaw: %.2f, pitch: %.2f, roll: %.2f, eye distance: %.2f]\n", - p_face[i].yaw, - p_face[i].pitch, p_face[i].roll, p_face[i].eye_dist); - - // draw the video - Scalar scalar_color = CV_RGB(p_face[i].ID * 53 % 256, - p_face[i].ID * 93 % 256, - p_face[i].ID * 143 % 256); - rectangle(bgr_frame, Point2f(static_cast<float>(p_face[i].rect.left), - static_cast<float>(p_face[i].rect.top)), - Point2f(static_cast<float>(p_face[i].rect.right), - static_cast<float>(p_face[i].rect.bottom)), scalar_color, 2); - for (int j = 0; j < p_face[i].points_count; j++) { - circle(bgr_frame, Point2f(p_face[i].points_array[j].x, - p_face[i].points_array[j].y), 1, Scalar(0, 255, 0)); - } - } - - // release the memory of face - cv_face_release_tracker_result(p_face, face_count); - imshow("TrackingTest", bgr_frame); - if (waitKey(1) != -1) - break; - } - - } while (0); - - // destroy track handle - cv_face_destroy_tracker(handle_track); - - return 0; -} - diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/test.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/test.cpp deleted file mode 100644 index 8ae3ba2..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include <iostream> -#include <vector> -#include <stdio.h> - -#include "faceAPI.h" -#include "tools.h" - -using namespace std; - -int main(int argc, char *argv[] ) -{ - - //文件路径 - char *db_path = "./out.db"; - char *image_path = argv[1]; - char *image_list = "../test_image/imglist"; - my_db mydb= {"root","Basic@2017","localhost","demo",3306}; - - person p= {0,"axsdcc",1}; - - cv::Mat bgr_image = cv::imread(image_path); - if(bgr_image.data != NULL) - { - cout<<image_path<<endl; - } - else - { - cout<<"image is null"<<endl; - cout<<image_path<<endl; - } - -// FaceDB db =FaceDB(); -// db.init(db_path); -// int id = db.search_db(db.extract_feature(bgr_image)); - int idx = -11; - tools tool=tools(); - tool.init(mydb,db_path); - cout<<"======tools init ==========="<<endl; - if(tool.search(bgr_image,&p)) - { - idx=tool.reg(bgr_image,&p); - } - - cout<<"id="<<idx<<endl; - cout<<"============================================"<<endl; - cout<<"p_id="<<p.p_id<<endl; - cout<<"name="<<p.name<<endl; - cout<<"f_id="<<p.f_id<<endl; - - - return 0; -} diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/time_helper.h b/RtspFace/SensetimeFaceAPIWrapper/src/time_helper.h deleted file mode 100644 index caf2cb6..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/time_helper.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef TIME_HELPER_H_8FVB3L0U -#define TIME_HELPER_H_8FVB3L0U - -#ifndef DISABLE_TIMING -#include <ctime> -#include <cstdio> - -#ifdef _MSC_VER -#define __TIC__() double __timing_start = clock() -#define __TOC__() \ - do { \ - double __timing_end = clock(); \ - fprintf(stdout, "TIME(ms): %lf\n", \ - (__timing_end - __timing_start) \ - / CLOCKS_PER_SEC * 1000); \ - } while (0) -#else -#include <unistd.h> -#include <sys/time.h> - -#define __TIC__() \ - struct timeval __timing_start, __timing_end; \ - gettimeofday(&__timing_start, NULL); - -#define __TOC__() \ - do { \ - gettimeofday(&__timing_end, NULL); \ - double __timing_gap = (__timing_end.tv_sec - \ - __timing_start.tv_sec) * \ - 1000.0 + \ - (__timing_end.tv_usec - \ - __timing_start.tv_usec) / \ - 1000.0; \ - fprintf(stdout, "TIME(ms): %lf\n", __timing_gap); \ - } while (0) - -#endif - -#else -#define __TIC__() -#define __TOC__() -#endif - -#endif /* end of include guard: IMAGEHELPER_HPP_8FVB3L0U */ diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/tools.cpp b/RtspFace/SensetimeFaceAPIWrapper/src/tools.cpp deleted file mode 100644 index a8be726..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/tools.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "tools.h" - -tools::tools() -{ -} - -tools::~tools() {} - -bool tools::init(my_db mydb,char* db_path_t) -{ - - //my_db mydb= {"root","Basic@2017","localhost","demo",3306}; - if(dbu.db_init(mydb)) - { - db_path = db_path_t; - } - else - return false; - if(!f_api.do_init(db_path_t)){ - return false; - } - else - return true; -} - -int tools::search(cv::Mat image,person *p) -{ - //p={}; - int temp = f_api.do_reasch(image); - p->f_id = temp; - - if(p->f_id > 0) - { - if(do_search(p) == 0) - { - return 0; - } - } - return -1; -} - -int tools::search(char* s_feature,person *p) -{ - p= {}; - p->f_id = f_api.do_reasch(s_feature); - if(p->f_id > 0) - { - if(do_search(p) == 0) - { - return 0; - } - } - return -1; -} - -int tools::reg(cv::Mat image,person *p) -{ - if(do_register(image,p) == 0) - { - return 0; - } - return -1; -} - -int tools::do_search(person *p) -{ - dbu.db_search(p); - if(p->p_id != NULL) - { - return 0; - } - return -1; -} - -int tools::do_register(cv::Mat image,person *p) -{ - //p= {}; - p->f_id = f_api.do_register(image); - if(p->f_id > 0) - { - fprintf(stderr, " tools::do_register %d\n",p->f_id); - if(dbu.db_register(p)) - { - return 0; - } - } - return -1; - -} \ No newline at end of file diff --git a/RtspFace/SensetimeFaceAPIWrapper/src/tools.h b/RtspFace/SensetimeFaceAPIWrapper/src/tools.h deleted file mode 100644 index 61ff9b8..0000000 --- a/RtspFace/SensetimeFaceAPIWrapper/src/tools.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _TOOLS_H_ -#define _TOOLS_H_ - -#include "DBuntil.h" -#include "faceAPI.h" - -class tools -{ -public: - tools(); - ~tools(); - bool init(my_db mydb,char* db_path); - int search(cv::Mat image,person *p); - int search(char* s_feature,person *p); - int reg(cv::Mat image,person *p); - - bool init(); -private: - int do_register(cv::Mat image,person *p); - int do_search(person *p); - - char* db_path; - person per; - DBuntil dbu; - FaceAPI f_api; - -}; - -#endif \ No newline at end of file -- Gitblit v1.8.0