forked from RangiLyu/nanodet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnanodet_openvino.h
67 lines (53 loc) · 1.63 KB
/
nanodet_openvino.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
//
// Create by RangiLyu
// 2021 / 1 / 12
//
#ifndef _NANODET_OPENVINO_H_
#define _NANODET_OPENVINO_H_
#include <string>
#include <opencv2/core.hpp>
#include <inference_engine.hpp>
typedef struct HeadInfo
{
std::string cls_layer;
std::string dis_layer;
int stride;
} HeadInfo;
struct CenterPrior
{
int x;
int y;
int stride;
};
typedef struct BoxInfo
{
float x1;
float y1;
float x2;
float y2;
float score;
int label;
} BoxInfo;
class NanoDet
{
public:
NanoDet(const char* param);
~NanoDet();
InferenceEngine::ExecutableNetwork network_;
InferenceEngine::InferRequest infer_request_;
// static bool hasGPU;
// modify these parameters to the same with your config if you want to use your own model
int input_size[2] = {416, 416}; // input height and width
int num_class = 80; // number of classes. 80 for COCO
int reg_max = 7; // `reg_max` set in the training config. Default: 7.
std::vector<int> strides = { 8, 16, 32, 64 }; // strides of the multi-level feature.
std::vector<BoxInfo> detect(cv::Mat image, float score_threshold, float nms_threshold);
private:
void preprocess(cv::Mat& image, InferenceEngine::Blob::Ptr& blob);
void decode_infer(const float*& pred, std::vector<CenterPrior>& center_priors, float threshold, std::vector<std::vector<BoxInfo>>& results);
BoxInfo disPred2Bbox(const float*& dfl_det, int label, float score, int x, int y, int stride);
static void nms(std::vector<BoxInfo>& result, float nms_threshold);
std::string input_name_ = "data";
std::string output_name_ = "output";
};
#endif //_NANODE_TOPENVINO_H_