/************************************************************************* * * 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 #include #include #include #include #include #include #include #include /* struct FaceInfo { float x1; float y1; float x2; float y2; float score; float landmarks[10]; int GetWidth() { return static_cast(x2 - x1); } int GetHeight() { return static_cast(y2 - y1); } }; */ class CenterFaceMnn { public: static CenterFaceMnn* GetInstance(); int Detect(const cv::Mat& img, std::vector& 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& faces, float scoreThresh, float nmsThresh); void NMS(std::vector& input, std::vector& output, float nmsthreshold); std::vector GetIds(float *heatmap, int h, int w, float thresh); private: static CenterFaceMnn* m_hInstance; std::mutex m_mt; std::shared_ptr 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