YoloFeatureExtractor.h 757 B

123456789101112131415161718192021222324252627
  1. 
  2. #pragma once
  3. #include <opencv2/opencv.hpp>
  4. #include <opencv2/dnn.hpp>
  5. #include <vector>
  6. #include <string>
  7. class YoloFeatureExtractor
  8. {
  9. private:
  10. cv::dnn::Net net;
  11. int inputWidth;
  12. int inputHeight;
  13. std::vector<std::string> classNames;
  14. public:
  15. YoloFeatureExtractor(const std::string & modelPath, const std::string & classesPath);
  16. ~YoloFeatureExtractor() = default;
  17. void loadClassNames(const std::string & file);
  18. std::vector<float> globalAveragePooling(const cv::Mat & featureMap);
  19. void normalizeL2(cv::Mat& feat);
  20. std::vector<float> extractFeatures(const std::string & imagePath);
  21. std::vector<float> extractBackboneFeatures(const std::string & imagePath);
  22. std::vector<std::vector<float>> extractROIFeatures(const std::string & imagePath);
  23. };