Files
DeepCamFaceSDK2.0/Inc/CenterFaceMnn.h
2024-12-13 23:33:37 +08:00

88 lines
2.1 KiB
C++

/*************************************************************************
*
* DeepCam CONFIDENTIAL
* FILE: CenterFaceMnn.h
*
* [2019] - [2020] DeepCam, LLC and DeepCam
NOTICE:
* All information contained herein is, and remains the property of DeepCam LLC.
* The intellectual and technical concepts contained herein are proprietary to DeepCam
* and may be covered by U.S. and Foreign Patents,patents in process, and are protected by
* trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* DeepCam, LLC.
*
*
* Written: DongPo Wang
* Date: 11/23/2020
* Mail: dongpo.wang@deepcam.com
*/
#ifndef CENTERFACE_H
#define CENTERFACE_H
#include <opencv2/opencv.hpp>
#include <vector>
#include <memory>
#include <mutex>
#include <MNN/Interpreter.hpp>
#include <MNN/MNNDefine.h>
#include <MNN/ImageProcess.hpp>
#include <MNN/Tensor.hpp>
#include <Inc/DeepCamDef.h>
/*
struct FaceInfo {
float x1;
float y1;
float x2;
float y2;
float score;
float landmarks[10];
int GetWidth() {
return static_cast<int>(x2 - x1);
}
int GetHeight() {
return static_cast<int>(y2 - y1);
}
};
*/
class CenterFaceMnn
{
public:
static CenterFaceMnn* GetInstance();
int Detect(const cv::Mat& img, std::vector<FaceInfo>& faces, float scale = 0);
const std::string GetModelVer();
private:
CenterFaceMnn();
~CenterFaceMnn();
void Decode(float* heatmap, float* scale, float* offset, float* landmarks, int h, int w, std::vector<FaceInfo>& faces, float scoreThresh, float nmsThresh);
void NMS(std::vector<FaceInfo>& input, std::vector<FaceInfo>& output, float nmsthreshold);
std::vector<int> GetIds(float *heatmap, int h, int w, float thresh);
private:
static CenterFaceMnn* m_hInstance;
std::mutex m_mt;
std::shared_ptr<MNN::Interpreter> m_detector;
MNN::Tensor* input_tensor;
MNN::Tensor* hm_tensor;
MNN::Tensor* wh_tensor;
MNN::Tensor* reg_tensor;
MNN::Tensor* lm_tensor;
MNN::Session* m_session;
MNN::CV::ImageProcess::Config m_img_config;
const std::string m_model_ver = "";
};
#endif