61 lines
2.0 KiB
C++
61 lines
2.0 KiB
C++
#ifndef __YOLOV5_FACE_H__
|
|
#define __YOLOV5_FACE_H__
|
|
/*************************************************************************
|
|
*
|
|
* deepCam Shenzhen CONFIDENTIAL
|
|
* FILE: <tag>
|
|
*
|
|
* [2016] - [2019] DeepCam Shenzhen
|
|
* All Rights Reserved.
|
|
|
|
NOTICE:
|
|
* All information contained herein is, and remains the property of DeepCam Shenzhen.
|
|
* The intellectual and technical concepts contained herein are proprietary to DeepCam
|
|
* Shenzhen and may be covered by China 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 Shenzhen.
|
|
*
|
|
*
|
|
* Written: Jing.Yi 2021-01-6
|
|
* Updated:
|
|
**************************************************************************/
|
|
#include "ncnn/net.h"
|
|
#include "opencv2/opencv.hpp"
|
|
//#include "common/Extractor.h"
|
|
#include "anchor.h"
|
|
#include "dims.h"
|
|
#include <memory>
|
|
|
|
class yoloV5_face_ncnn
|
|
{
|
|
public:
|
|
static yoloV5_face_ncnn* getInstance();
|
|
S32 loadModel(std::string model_path, DimsNCHW dim_ifm = DimsNCHW(1,3,320,320));
|
|
// S32 loadModel(std::string model_path, DimsNCHW dim_ifm = DimsNCHW(1,3,192,256));
|
|
std::vector<Anchor>& Detect(cv::Mat &image);
|
|
|
|
private:
|
|
yoloV5_face_ncnn() {};
|
|
~yoloV5_face_ncnn() {};
|
|
yoloV5_face_ncnn(const yoloV5_face_ncnn&) = delete;
|
|
yoloV5_face_ncnn& operator=(const yoloV5_face_ncnn&) = delete;
|
|
|
|
std::vector<float> LetterboxImage(const cv::Mat& src, cv::Mat& dst, const cv::Size& out_size);
|
|
void decode(ncnn::Mat& output, std::vector<float>& info, std::vector<int> anchor,int net_w, int net_h, std::vector<Anchor>& result);
|
|
void nms(std::vector<Anchor> &input_boxes, float NMS_THRESH);
|
|
|
|
private:
|
|
std::shared_ptr<ncnn::Net> m_net;
|
|
DimsNCHW m_dimIfm;
|
|
std::vector<Anchor> m_result;
|
|
// float m_confThreshold = 0.4;
|
|
std::vector<int> m_anchor8 = { 4,5, 8,10, 13,16 };
|
|
std::vector<int> m_anchor16 = { 23,29, 43,55, 73,105 };
|
|
std::vector<int> m_anchor32 = { 146,217, 231,300, 335,433 };
|
|
};
|
|
|
|
|
|
#endif
|