// YOLOV3检测器 #ifndef __DETECTOR_YOLOV3_H__ #define __DETECTOR_YOLOV3_H__ #include #include #include #include #include #include "CommonUtils.h" #include "Queuethread.h" #include "Decoder.h" using namespace std; using namespace cv; typedef struct _ResultOfDetection { Rect boundingBox; float confidence; int classID; string className; bool exist; _ResultOfDetection():confidence(0.0f),classID(0),exist(true){} }ResultOfDetection; class DetectorYOLOV3 { public: ~DetectorYOLOV3(); void setNumThread(int numOfThread); void setGpuIndex(int gpuIndex); void initModel(const std::string &pathStr, const std::string &pathOfClassNameFile); void Detect(cv::Mat srcImage); private: Ort::Session *session; Ort::Env env = Ort::Env(ORT_LOGGING_LEVEL_ERROR, "Yolov3"); Ort::SessionOptions sessionOptions = Ort::SessionOptions(); int numThread = 0; vector classNames; std::vector inputDim; std::vector inputNamesPtr; std::vector outputNamesPtr; const float meanValues[3] = {0, 0, 0}; const float normValues[3] = {1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0}; }; #endif