-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathncnn_centerface.h
57 lines (45 loc) · 1.17 KB
/
ncnn_centerface.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
#pragma once
#include<vector>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<map>
#include<string>
#include "net.h"
#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 Centerface {
public:
Centerface();
~Centerface();
int init(void);
//You can change the shape of input image by setting params :resized_w and resized_h
int detect(ncnn::Mat &inblob, std::vector<FaceInfo>&faces, int resized_w,int resized_h,
float scoreThresh = 0.5, float nmsThresh = 0.3);
private:
void dynamicScale(float in_w, float in_h);
void squareBox(std::vector<FaceInfo> &faces);
void genIds(float *heatmap, int h, int w, float thresh, std::vector<int> &ids);
void nms(std::vector<FaceInfo>& input, std::vector<FaceInfo>& output, float nmsthreshold = 0.3,int type=NMS_MIN);
void decode(ncnn::Mat &heatmap, ncnn::Mat &scale, ncnn::Mat &offset, ncnn::Mat &landmarks,
std::vector<FaceInfo>&faces, float scoreThresh, float nmsThresh);
private:
ncnn::Net net;
int d_h;
int d_w;
float d_scale_h;
float d_scale_w;
float scale_h;
float scale_w;
int image_h;
int image_w;
};