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

37 lines
863 B
C++

#ifndef __FACE_MASK_H
#define __FACE_MASK_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>
class FaceMask {
public:
static FaceMask* GetInstance();
int Detect(cv::Mat& img, float& score, const float* landmark);
private:
FaceMask();
~FaceMask();
cv::Mat GetFace(const cv::Mat &src, const float* landmark);
cv::Mat FaceAlign(const cv::Mat& frame, const float* landmark, float face_rate = 1.25f);
private:
static FaceMask* m_instance;
std::mutex m_mt;
std::shared_ptr<MNN::Interpreter> m_detector;
MNN::Session* m_sess_mask = nullptr;
MNN::CV::ImageProcess::Config m_img_config;
MNN::Tensor* m_input_tensor = nullptr;
MNN::Tensor* m_score_tensor = nullptr;
};
#endif