31 #ifndef TRT_INFERENCE_H_
32 #define TRT_INFERENCE_H_
37 #include <opencv2/objdetect/objdetect.hpp>
38 using namespace nvinfer1;
42 #define GOOGLENET_SINGLE_CLASS 0
43 #define GOOGLENET_THREE_CLASS 1
44 #define RESNET_THREE_CLASS 2
54 int getNetWidth()
const;
56 int getNetHeight()
const;
58 uint32_t getBatchSize()
const;
60 int getChannel()
const;
62 int getModelClassCnt()
const;
64 void* getScales()
const;
66 void* getOffsets()
const;
70 void*& getBuffer(
const int& index);
72 float*& getInputBuf();
74 uint32_t getNumTrtInstances()
const;
76 void setBatchSize(
const uint32_t& batchsize);
78 void setDumpResult(
const bool& dump_result);
80 void setTrtProfilerEnabled(
const bool& enable_trt_profiler);
82 int getFilterNum()
const;
83 void setFilterNum(
const unsigned int& filter_num);
87 void setModelIndex(
int modelIndex);
89 void buildTrtContext(
const string& modelfile,
bool bUseCPUBuf =
false);
92 queue< vector<cv::Rect> >* rectList_queue,
95 void destroyTrtContext(
bool bUseCPUBuf =
false);
105 float *output_cov_buf;
106 float *output_bbox_buf;
109 float helnet_scale[4];
112 IExecutionContext *context;
113 uint32_t *pResultArray;
121 bool enable_trt_profiler;
122 IHostMemory *trtModelStream{
nullptr};
123 vector<string> outputs;
128 uint64_t elapsed_frame_num;
129 uint64_t elapsed_time;
135 Dims3 outputDimsBBOX;
138 size_t outputSizeBBOX;
149 float input_scale[3];
150 float bbox_output_scales[4];
152 } *g_pModelNetAttr, gModelNetAttr[4] = {
179 {-640, -368, 640, 368},
193 {0.0039215697906911373, 0.0039215697906911373, 0.0039215697906911373},
194 {-640, -368, 640, 368},
198 void parseBbox(vector<cv::Rect>* rectList,
int batch_th);
199 void ParseResnet10Bbox(vector<cv::Rect>* rectList,
int batch_th);
200 void allocateMemory(
bool bUseCPUBuf);
201 void releaseMemory(
bool bUseCPUBuf);