forked from wang-xinyu/tensorrtx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psenet.h
39 lines (36 loc) · 1.23 KB
/
psenet.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
#ifndef TENSORRTX_PSENET_H
#define TENSORRTX_PSENET_H
#include <memory>
#include <vector>
#include <chrono>
#include <opencv2/opencv.hpp>
#include "utils.h"
#include "layers.h"
class PSENet
{
public:
PSENet(int max_side_len, int min_side_len, float threshold, int num_kernel, int stride);
~PSENet();
ICudaEngine* createEngine(IBuilder* builder, IBuilderConfig* config);
void serializeEngine();
void deserializeEngine();
void init();
void inferenceOnce(IExecutionContext& context, float* input, float* output, int input_h, int input_w);
void detect(std::string image_path);
float* preProcess(cv::Mat image, int& resize_h, int& resize_w, float& ratio_h, float& ratio_w);
std::vector<cv::RotatedRect> postProcess(float* origin_output, int resize_h, int resize_w);
private:
Logger gLogger;
std::shared_ptr<nvinfer1::IRuntime> mRuntime;
std::shared_ptr<nvinfer1::ICudaEngine> mCudaEngine;
std::shared_ptr<nvinfer1::IExecutionContext> mContext;
DataType dt = DataType::kFLOAT;
const char* input_name_ = "input";
const char* output_name_ = "output";
int max_side_len_ = 1024;
int min_side_len_ = 640;
float post_threshold_ = 0.9;
int num_kernels_ = 6;
int stride_ = 4;
};
#endif // TENSORRTX_PSENET_H