#pragma once #include #include #include #include #include #include #include #include class Yolo { public: struct Detection { int class_id = 0; std::string className; float confidence = 0.0; int priority = -1; cv::Scalar color; cv::Rect box; }; private: static constexpr float modelConfidenceThreshold = 0.25; static constexpr float modelScoreThreshold = 0.45; static constexpr float modelNMSThreshold = 0.50; void loadClasses(const std::string& classes); void loadOnnxNetwork(const std::filesystem::path& path); cv::Mat formatToSquare(const cv::Mat &source); std::string modelPath; std::vector> classes; cv::Size2f modelShape; bool letterBoxForSquare = true; cv::dnn::Net net; public: Yolo(const std::filesystem::path &onnxModelPath = "", const cv::Size& modelInputShape = {640, 480}, const std::filesystem::path& classesTxtFilePath = "", bool runWithOCl = true); std::vector runInference(const cv::Mat &input); int getClassForStr(const std::string& str) const; };