-
Notifications
You must be signed in to change notification settings - Fork 0
/
detector_yolox.h
111 lines (90 loc) · 2.47 KB
/
detector_yolox.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
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* @Author: zhanghao
* @LastEditTime: 2022-09-02 17:20:12
* @FilePath: /sgtls_s_725/detector_yolox.h
* @LastEditors: zhanghao
* @Description:
*/
#pragma once
#include <memory>
#include <string>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <vector>
#include <opencv2/opencv.hpp>
#include <dirent.h>
#include <NvInfer.h>
#include <cuda_runtime_api.h>
#include "logging.h"
#include "base_detector.h"
#include "detector_utils.h"
#include "types/camera_frame.h"
#include "types/object_detected.h"
struct GridAndStride
{
int grid0;
int grid1;
int stride;
};
class DetectorYoloX : public BaseDetector
{
public:
DetectorYoloX();
~DetectorYoloX();
/*
* @description:
* @param {DetectorInitOptions} &options
* @return {Init status}
* @author: zhanghao
*/
virtual bool Init(const DetectorInitOptions &options);
/*
* @description:
* @param {CameraFrame*} camera_frame
* @return {Process status}
* @author: zhanghao
*/
virtual bool Detect(CameraFrame* camera_frame);
/*
* @description:
* @param {Mat*} image_ptr
* @param {DetObjectList&} results
* @return {*}
* @author: zhanghao
*/
virtual bool Detect(cv::Mat* image_ptr, DetObjectList& results);
/*
* @description: Name of this detector
* @return {Detector name}
* @author: zhanghao
*/
virtual std::string Name() const {
return "sgtls_s_725";
};
private:
bool _InitEngine();
bool _DoInference();
void _Preprocess(cv::Mat* img);
void _GetOutputSize();
void _GenerateGridsAndStride();
void _DecodeOutputs(DetObjectList& result_objs);
void _GenerateProposals(DetObjectList& prop_objs);
void _GetAttrsFromFeaturemap(float* prob, DetObject& obj);
private:
int m_output_dim_size_;
unsigned int m_img_channel_;
float* m_input_blob_;
float* m_output_prob_;
unsigned int m_input_w_;
unsigned int m_input_h_;
int m_ori_img_w_;
int m_ori_img_h_;
float m_scale_;
std::vector<int> m_strides_;
std::vector<GridAndStride> m_grid_strides_;
int m_num_classes_;
int m_attr_channel_num_;
std::vector<int> m_attr_num_list_;
};