You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB
C

#pragma once
#include "MF_ImageClassificationBase.h"
#include <mutex>
#define NUMCLASSES 5 // Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define IMGS_IDX 3
class MF_Resnet34Infer : public MF_ImageClassificationBase
{
public:
1 year ago
MF_Resnet34Infer(const trtUtils::InitParameter& param);
~MF_Resnet34Infer();
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> engine
bool initEngine(const std::string& _onnxFileName);
// <20><><EFBFBD><EFBFBD>
1 year ago
bool doTRTInfer(const std::vector<MN_VisionImage::MS_ImageParam>& _bufImgs, std::vector<trtUtils::MR_Result>* _detectRes, int* _user);
// <20><><EFBFBD><EFBFBD>
1 year ago
bool doTRTInfer(const std::vector<cv::Mat>& _matImgs, std::vector<trtUtils::MR_Result>* _detectRes, int* _user);
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
static std::string getError();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F>ڴ<EFBFBD>
void freeMemeory();
protected:
// ͨ<><CDA8>onnx<6E><78>ʽ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>engine
int buildModel(const std::string& _onnxFile);
// Ԥ<><D4A4><EFBFBD><EFBFBD>
int preProcess(const std::vector<cv::Mat>& _imgsBatch);
// <20><><EFBFBD><EFBFBD>
int infer();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int postProcess(const std::vector<cv::Mat>& _imgsBatch);
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
1 year ago
int getDetectResult(std::vector<trtUtils::MR_Result>& _result);
private:
std::vector<float> softmax(std::vector<float> _input);
std::vector<std::string> load_labels(const std::string& _labelPath);
std::string UTF8_2_GB(const char* str);
private:
int input_numel;
nvinfer1::Dims input_dims; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><CEAC>
1 year ago
trtUtils::ME_DetectRes detectRes; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float confidence; // <20><><EFBFBD>Ŷ<EFBFBD>
std::string predictName; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::mutex m_mutex;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float* input_data_host{ nullptr };
float* input_data_device{ nullptr };
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float output_data_host[NUMCLASSES];
float* output_data_device{ nullptr };
};