forked from zeusees/License-Plate-Detector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LPDetector.h
executable file
·97 lines (75 loc) · 1.82 KB
/
LPDetector.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// Created by dl on 19-7-19.
//
#ifndef FACE_DETECTOR_H
#define FACE_DETECTOR_H
#include <opencv2/opencv.hpp>
#include <string>
#include <stack>
#include "net.h"
#include <chrono>
using namespace std::chrono;
class Timer
{
public:
std::stack<high_resolution_clock::time_point> tictoc_stack;
void tic()
{
high_resolution_clock::time_point t1 = high_resolution_clock::now();
tictoc_stack.push(t1);
}
double toc(std::string msg = "", bool flag = true)
{
double diff = duration_cast<milliseconds>(high_resolution_clock::now() - tictoc_stack.top()).count();
if(msg.size() > 0){
if (flag)
printf("%s time elapsed: %f ms\n", msg.c_str(), diff);
}
tictoc_stack.pop();
return diff;
}
void reset()
{
tictoc_stack = std::stack<high_resolution_clock::time_point>();
}
};
struct Point{
float _x;
float _y;
};
struct bbox{
float x1;
float y1;
float x2;
float y2;
float s;
Point point[4];
};
struct box{
float cx;
float cy;
float sx;
float sy;
};
class Detector
{
public:
Detector();
void Init(const std::string &model_param, const std::string &model_bin);
Detector(const std::string &model_param, const std::string &model_bin, bool retinaface = false);
inline void Release();
void nms(std::vector<bbox> &input_boxes, float NMS_THRESH);
void Detect(cv::Mat& bgr, std::vector<bbox>& boxes);
void create_anchor(std::vector<box> &anchor, int w, int h);
void create_anchor_retinaface(std::vector<box> &anchor, int w, int h);
inline void SetDefaultParams();
static inline bool cmp(bbox a, bbox b);
~Detector();
public:
float _nms;
float _threshold;
float _mean_val[3];
bool _retinaface;
ncnn::Net *Net;
};
#endif //