detect_obstacle.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef DETECT_TURNSTILE_H
  2. #define DETECT_TURNSTILE_H
  3. #include "Hungarian.h"
  4. #include "KalmanTracker.h"
  5. namespace od{
  6. const int COLOR_MAP[2][3]={{0, 0, 255},{255, 0, 0}};
  7. const int max_age = 3;
  8. const int min_hits = 3;
  9. const double iouThreshold = 0.5;
  10. struct bbox_t {
  11. unsigned int x, y, w, h; // (x,y) - top-left corner, (w, h) - width & height of bounded box
  12. float prob; // confidence - probability that the object was found correctly
  13. unsigned int obj_id; // class of object - from range [0, classes-1]
  14. unsigned int track_id; // tracking id for video (0 - untracked, 1 - inf - tracked object)
  15. unsigned int frames_counter; // counter of frames on which the object was detected
  16. float x_3d, y_3d, z_3d; // center of object (in Meters) if ZED 3D Camera is used
  17. };
  18. typedef struct TrackingBox
  19. {
  20. int frame;
  21. int id;
  22. int class_id;
  23. float prob;
  24. Rect_<float> box;
  25. vector<int> class_history;
  26. }TrackingBox;
  27. //yolo data o DetectBox
  28. typedef struct DetectBox
  29. {
  30. int class_id;
  31. float prob;
  32. Rect_<float> box;
  33. }DetectBox;
  34. //Computes IOU between two bounding boxes
  35. double GetIOU(Rect_<float> bb_test, Rect_<float> bb_gt);
  36. //画出检测框和相关信息
  37. void DrawBoxes(Mat &frame, vector<string> classes, int classId, int turnstileId,float conf, int left, int top, int right, int bottom);
  38. //画出检测结果,image
  39. void Drawer(Mat &frame, vector<bbox_t> outs, vector<string> classes);
  40. //画出检测结果,video
  41. void Drawer(Mat &frame, vector<od::TrackingBox> &track_result, vector<string> &classes);
  42. //tracking obstacle
  43. bool TrackObstacle(int frame_count,vector<KalmanTracker> &trackers,vector<bbox_t> &outs,vector<od::TrackingBox> &track_result);
  44. }
  45. #endif // DETECT_TURNSTILE_H