forked from linghu8812/tensorrt_inference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCenterFace.h
48 lines (42 loc) · 1.48 KB
/
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
#ifndef CENTERFACE_CENTERFACE_H
#define CENTERFACE_CENTERFACE_H
#include <opencv2/opencv.hpp>
#include "NvInfer.h"
class CenterFace{
struct FaceBox{
float x;
float y;
float w;
float h;
};
struct FaceRes{
float confidence;
FaceBox face_box;
std::vector<cv::Point2f> keypoints;
};
public:
explicit CenterFace(const std::string &config_file);
~CenterFace();
void LoadEngine();
bool InferenceFolder(const std::string &folder_name);
private:
void EngineInference(const std::vector<std::string> &image_list, const int *outSize,void **buffers,
const std::vector<int64_t> &bufferSize, cudaStream_t stream);
std::vector<float> prepareImage(std::vector<cv::Mat> & vec_img);
std::vector<std::vector<FaceRes>> postProcess(const std::vector<cv::Mat> &vec_Mat,
float *output_1, float *output_2, float *output_3, float *output_4,
const int &outSize_1, const int &outSize_2, const int &outSize_3, const int &outSize_4);
void NmsDetect(std::vector<FaceRes> &detections);
static float IOUCalculate(const FaceBox &det_a, const FaceBox &det_b);
std::string onnx_file;
std::string engine_file;
nvinfer1::ICudaEngine *engine = nullptr;
nvinfer1::IExecutionContext *context = nullptr;
int BATCH_SIZE;
int INPUT_CHANNEL;
int IMAGE_WIDTH;
int IMAGE_HEIGHT;
float obj_threshold;
float nms_threshold;
};
#endif //CENTERFACE_CENTERFACE_H