#ifndef __LIVENESS_IR_MNN_H #define __LIVENESS_IR_MNN_H #include #include //enum error { // DEEPCAM_UNKNOWN_ERROR = -2, // UNKNOWN ERROR // DEEPCAM_IMAGE_INVALID = -1, // DEEPCAM_NO_ERROR = 0, // NO ERROR //}; class LivenessIRMnn { public: static LivenessIRMnn* GetInstance(); int LivenessDetect(const cv::Mat& img, FaceInfo& face_info, float& score, bool motionFilter, int uniteFrames = 5); int LivenessDetect(const cv::Mat& img, int face_x1, int face_y1, int face_x2, int face_y2, const float* landmark, float& score, bool motionFilter, int uniteFrames = 5); private: LivenessIRMnn(); ~LivenessIRMnn(); 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); float IOU(float face0_x0, float face0_y0, float face0_x1, float face0_y1, float face1_x0, float face1_y0, float face1_x1, float face1_y1); int GetLightBlurScore(const cv::Mat& face, float& light, float& blur); int GetLivenessScore(const cv::Mat& face_img, float& score); long long get_cur_time(); private: static LivenessIRMnn* m_instance; std::mutex m_mt; std::shared_ptr m_ir_liveness; MNN::Session* m_sess_liveness = nullptr; MNN::CV::ImageProcess::Config m_img_config; MNN::Tensor* m_input_tensor; MNN::Tensor* m_score_tensor; }; #endif