inference.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef INFERENCE_H
  2. #define INFERENCE_H
  3. // Cpp native
  4. #include <fstream>
  5. #include <vector>
  6. #include <string>
  7. #include <random>
  8. // OpenCV / DNN / Inference
  9. #include <opencv2/imgproc.hpp>
  10. #include <opencv2/opencv.hpp>
  11. #include <opencv2/dnn.hpp>
  12. //struct Detection
  13. //{
  14. // int class_id{0};
  15. // std::string className{};
  16. // float confidence{0.0};
  17. // cv::Scalar color{};
  18. // cv::Rect box{};
  19. //};
  20. //
  21. //class Inference
  22. //{
  23. //public:
  24. // Inference(const std::string &onnxModelPath, const cv::Size2f &modelInputShape, const std::string &classesTxtFile, const bool &runWithCuda = true);
  25. // std::vector<Detection> runInference(const cv::Mat &input);
  26. //
  27. //private:
  28. // void loadClassesFromFile();
  29. // void loadOnnxNetwork();
  30. // cv::Mat formatToSquare(const cv::Mat &source);
  31. //
  32. // std::string modelPath{};
  33. // std::string classesPath{};
  34. // bool cudaEnabled{};
  35. //
  36. // std::vector<std::string> classes{};
  37. // cv::Size2f modelShape{};
  38. //
  39. // float modelConfidenseThreshold {0.25};
  40. // float modelScoreThreshold {0.45};
  41. // float modelNMSThreshold {0.50};
  42. //
  43. // bool letterBoxForSquare = true;
  44. //
  45. // cv::dnn::Net net;
  46. //};
  47. #endif // INFERENCE_H