AutoCar  v1.0.0
armor_detect.h
1 #ifndef __ARMOR_H__
2 #define __ARMOR_H__
3 
4 #include <opencv2/opencv.hpp>
5 #include <vector>
6 #include <list>
7 #include <tuple>
8 #include <chrono>
9 #include "detect_factory.h"
10 
11 namespace autocar
12 {
13 namespace vision_mul
14 {
16 {
17 public:
18  armor_info(int type_, cv::RotatedRect armor_, std::vector<cv::Point2f> points_, cv::RotatedRect left_=cv::RotatedRect(), cv::RotatedRect right_=cv::RotatedRect())
19  {
20  type = type_;
21  armor = armor_;
22  points = points_;
23  left_light = left_;
24  right_light = right_;
25  score = 0.0f;
26  }
27  armor_info();
28 
29  int type;
30  cv::RotatedRect armor;
31  std::vector<cv::Point2f> points;
32  cv::RotatedRect left_light;
33  cv::RotatedRect right_light;
34  float score;
35 };
36 
38 {
39 private:
40 
41  const static float m_threshold_max_angle;
42  const static float m_threshold_min_area;
43  const static float m_threshold_dis_lower;
44  const static float m_threshold_dis_upper;
45  const static float m_threshold_len;
46  const static float m_threshold_height;
47  const static float m_threshold_gray;
48 
49 public:
50 
54  armor_detecter(bool debug_on);
61  cv::Mat highlight_blue_or_red(const cv::Mat &image, bool detect_blue);
67  std::vector<std::vector<cv::Point>> find_contours(const cv::Mat &binary);
74  std::vector<cv::RotatedRect> to_light_rects(const std::vector<std::vector<cv::Point>> &contours_light, const std::vector<std::vector<cv::Point>> &contours_brightness);
80  std::vector<cv::RotatedRect> detect_lights(bool detect_blue);
88  std::vector<cv::RotatedRect> filter_lights(const std::vector<cv::RotatedRect> &lights, float thresh_max_angle, float thresh_min_area);
101  std::vector<armor_info> possible_armors(const std::vector<cv::RotatedRect> &lights, float thres_max_angle, float thres_dis_lower, \
102  float thres_dis_upper, float thres_len, float thres_height, float thres_gray, bool detect_blue);
103  void cal_armor_info(std::vector<cv::Point2f> &armor_points, cv::RotatedRect left_light, cv::RotatedRect right_light);
109  std::vector<armor_info> filter_by_features(std::vector<armor_info> &armors);
115  bool detect(const cv::Mat &image, bool detect_blue);
121  void slect_final_armor(std::vector<armor_info> all_armors);
126  armor_info* get_armor();
130  void debug_vision();
131 
132 private:
133 
134  cv::Mat m_common;
135  cv::Mat m_image;
136  cv::Mat m_show;
137  cv::Mat m_gray;
138  cv::Mat possible_armor;
139  cv::Mat light_img;
140  cv::Mat m_binary_brightness;
141  cv::Mat m_binary_color;
142  cv::Mat m_binary_light;
143  bool debug_on_;
144 
145  std::chrono::system_clock::time_point speed_test_start_begin_time;
146  armor_info *armor;
147  armor_info *old_armor;
148 };
149 }
150 }
151 
152 
153 #endif // !__ARMOR_H__
Definition: armor_detect.h:15
Definition: vel2odom.h:5
Definition: armor_detect.h:37
Definition: detect_factory.h:8