-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLFFD_MNN.h
70 lines (54 loc) · 1.63 KB
/
LFFD_MNN.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <opencv2/opencv.hpp>
#include <Interpreter.hpp>
#include <MNNDefine.h>
#include <Tensor.hpp>
#include <ImageProcess.hpp>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <memory>
#define NMS_UNION 1
#define NMS_MIN 2
struct FaceInfo {
float x1;
float y1;
float x2;
float y2;
float score;
float area;
float landmarks[10];
};
class LFFD {
public:
LFFD(int scale_num=5);
~LFFD();
int detect(cv::Mat& img, std::vector<FaceInfo>& face_lis,int resize_h=480,int resize_w=640,
float score_threshold = 0.6, float nms_threshold = 0.4, int top_k = 10000,
std::vector<int> skip_scale_branch_list = {});
private:
void generateBBox(std::vector<FaceInfo>& collection, MNN::Tensor* score_map, MNN::Tensor* box_map, float score_threshold,
int fea_w, int fea_h, int cols, int rows, int scale_id);
void get_topk_bbox(std::vector<FaceInfo>& input, std::vector<FaceInfo>& output, int topk);
void nms(std::vector<FaceInfo>& input, std::vector<FaceInfo>& output,
float threshold, int type = NMS_MIN);
private:
std::shared_ptr<MNN::Interpreter> lffd;
MNN::Session* sess_lffd = nullptr;
MNN::Tensor* input_tensor = nullptr;
std::vector< MNN::Tensor*> outputTensors;
MNN::CV::ImageProcess::Config img_config;
int num_thread;
int num_output_scales;
int image_w;
int image_h;
std::string mnn_model_file;
std::vector<float> receptive_field_list;
std::vector<float> receptive_field_stride;
std::vector<float> bbox_small_list;
std::vector<float> bbox_large_list;
std::vector<float> receptive_field_center_start;
std::vector<float> constant;
std::vector<std::string> output_blob_names;
};