yolocrowd.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef YOLO_CROWD_HPP
  2. #define YOLO_CROWD_HPP
  3. #include "trt_tensor.hpp"
  4. #include "object_detector.hpp"
  5. #include <opencv2/opencv.hpp>
  6. #include <vector>
  7. #include <memory>
  8. #include <string>
  9. #include <future>
  10. namespace YoloCrowd
  11. {
  12. using namespace std;
  13. using namespace ObjectDetector;
  14. enum class Type : int
  15. {
  16. V5 = 0,
  17. X = 1,
  18. V3 = 2,
  19. V7 = 3
  20. };
  21. enum class NMSMethod : int
  22. {
  23. CPU = 0, // General, for estimate mAP
  24. FastGPU = 1 // Fast NMS with a small loss of accuracy in corner cases
  25. };
  26. void image_to_tensor(const cv::Mat &image, shared_ptr<TRT::Tensor> &tensor, Type type, int ibatch);
  27. class Infer
  28. {
  29. public:
  30. virtual shared_future<BoxArray> commit(const cv::Mat &image) = 0;
  31. virtual std::vector<shared_future<BoxArray>> commits(const std::vector<cv::Mat> &images) = 0;
  32. };
  33. shared_ptr<Infer> create_infer(
  34. const string &engine_file, Type type, int gpuid,
  35. float confidence_threshold = 0.25f, float nms_threshold = 0.5f,
  36. NMSMethod nms_method = NMSMethod::FastGPU, int max_objects = 1024,
  37. bool use_multi_preprocess_stream = false);
  38. const char *type_name(Type type);
  39. }; // namespace YoloCrowd
  40. #endif // YOLO_CROWD_HPP