#pragma once #include "MF_ObjectDetectBase.h" class MF_Yolov8Infer : public MF_ObjectDetectBase { public: MF_Yolov8Infer(const trtUtils::InitParameter& param); ~MF_Yolov8Infer(); // 初始化引擎 engine bool initEngine(const std::string& _onnxFileName); // 推理 bool doTRTInfer(const std::vector& _bufImgs, std::vector* _detectRes, int* _user); // 推理 bool doTRTInfer(const std::vector& _matImgs, std::vector* _detectRes, int* _user); // 获取错误信息 static std::string getError(); // 清理数据/内存 void freeMemeory(); protected: // 将图像数据拷贝到显存 int copyToDevice(const std::vector& _imgsBatch); // 预处理 int preProcess(const std::vector& _imgsBatch); // 推理 int infer(); // 将推理结果从显存拷贝到cpu int copyFromDevice(const std::vector& _imgsBatch); // 后处理 int postProcess(const std::vector& _imgsBatch); // 获取最终检测结果 int getDetectResult(std::vector& _result); private: float* m_output_src_transpose_device; };