Apollo 11.0
自动驾驶开放平台
apollo::planning::BirdviewImgFeatureRenderer类 参考

#include <birdview_img_feature_renderer.h>

apollo::planning::BirdviewImgFeatureRenderer 的协作图:

Public 成员函数

virtual ~BirdviewImgFeatureRenderer ()=default
 Destructor
 
bool Init (const PlanningSemanticMapConfig &config)
 initialize renderer
 
bool RenderMultiChannelEnv (const LearningDataFrame &learning_data_frame, cv::Mat *img_feature)
 generate multi-channel img as input feature for certain model
 
bool RenderBGREnv (const LearningDataFrame &learning_data_frame, cv::Mat *img_feature)
 generate bgr img as input feature for certain model
 
bool RenderCurrentEgoStatus (const LearningDataFrame &learning_data_frame, cv::Mat *img_feature)
 generate a two channel img, one for cur box, one for cur point
 
bool RenderCurrentEgoPoint (const LearningDataFrame &learning_data_frame, cv::Mat *img_feature)
 generate a single channel img
 
bool RenderCurrentEgoBox (const LearningDataFrame &learning_data_frame, cv::Mat *img_feature)
 generate a single channel img
 

详细描述

在文件 birdview_img_feature_renderer.h 第 39 行定义.

构造及析构函数说明

◆ ~BirdviewImgFeatureRenderer()

virtual apollo::planning::BirdviewImgFeatureRenderer::~BirdviewImgFeatureRenderer ( )
virtualdefault

Destructor

成员函数说明

◆ Init()

bool apollo::planning::BirdviewImgFeatureRenderer::Init ( const PlanningSemanticMapConfig &  config)

initialize renderer

参数
configconfiguration

在文件 birdview_img_feature_renderer.cc 第 42 行定义.

42 {
43 config_ = config;
44 ego_vehicle_config_ = common::VehicleConfigHelper::GetConfig();
45
46 // a redundant call to HDMapUtil::BaseMap() to save time for renderering when
47 // the basemap is not yet initialized in HDMapUtil
49
50 const std::string map_name =
51 FLAGS_map_dir.substr(FLAGS_map_dir.find_last_of("/") + 1);
52 if (map_name != "sunnyvale_with_two_offices" && map_name != "sunnyvale") {
53 AERROR << "Map other than sunnyvale_with_two_offices are not supported";
54 }
55 // TODO(Jinyun): add sunnyvale map or draw basemap online
56 if (map_name == "sunnyvale") {
57 AWARN << "use sunnyvale_with_two_offices for sunnyvale for now";
58 }
59
60 // TODO(Jinyun): move to a more managable place
61 map_bottom_left_point_x_ = 585875.3316302994;
62 map_bottom_left_point_y_ = 4139916.6342316796;
63 bool roadmap_img_status = LoadRoadMap(ROADMAP_IMG_PATH);
64 bool speedlimit_img_status = LoadSpeedlimitMap(SPEEDLIMITMAP_IMG_PATH);
65
66 if (!roadmap_img_status || !speedlimit_img_status) {
67 AERROR << "Base map image read failed";
68 return false;
69 }
70
71 ego_cur_point_img_ =
72 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
73 ego_cur_box_img_ =
74 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
75
76 bool render_ego_point_status = RenderEgoCurrentPoint(&ego_cur_point_img_);
77 bool render_ego_box_status = RenderEgoCurrentBox(&ego_cur_box_img_);
78
79 if (!render_ego_point_status || !render_ego_box_status) {
80 AERROR << "Ego point or box img rendering failed";
81 return false;
82 }
83
84 if (base_roadmap_img_.size[0] != base_speedlimit_img_.size[0] ||
85 base_roadmap_img_.size[1] != base_speedlimit_img_.size[1]) {
86 AERROR << "base map sizes doesn't match";
87 return false;
88 }
89
90 std::vector<cv::Mat> merge_imgs = {ego_cur_point_img_, ego_cur_box_img_};
91 cv::merge(merge_imgs, stacked_ego_cur_status_img_);
92
93 return true;
94}
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
static const HDMap & BaseMap()
#define AERROR
Definition log.h:44
#define AWARN
Definition log.h:43

◆ RenderBGREnv()

bool apollo::planning::BirdviewImgFeatureRenderer::RenderBGREnv ( const LearningDataFrame &  learning_data_frame,
cv::Mat *  img_feature 
)

generate bgr img as input feature for certain model

参数
learning_data_framea proto message containing info for renderering
img_featurea pointer to opencv img to render on

在文件 birdview_img_feature_renderer.cc 第 169 行定义.

170 {
171 int ego_trajectory_point_history_size =
172 learning_data_frame.adc_trajectory_point_size();
173 if (ego_trajectory_point_history_size < 1) {
174 AERROR << "Ego past history is empty";
175 return false;
176 }
177
178 cv::Mat bgr_canvas =
179 cv::Mat(config_.height(), config_.width(), CV_8UC3, cv::Scalar(0, 0, 0));
180
181 const auto& current_traj_point = learning_data_frame.adc_trajectory_point(
182 ego_trajectory_point_history_size - 1);
183 const double current_time_sec = current_traj_point.timestamp_sec();
184 const auto& current_path_point =
185 current_traj_point.trajectory_point().path_point();
186 const double current_x = current_path_point.x();
187 const double current_y = current_path_point.y();
188 const double current_heading = current_path_point.theta();
189
190 if (!RenderLocalRoadMap(current_x, current_y, current_heading, &bgr_canvas)) {
191 AERROR << "RenderLocalRoadMap failed";
192 return false;
193 }
194 if (!RenderRouting(learning_data_frame, current_x, current_y, current_heading,
195 &bgr_canvas)) {
196 AERROR << "RenderRouting failed";
197 return false;
198 }
199 if (!RenderTrafficLight(learning_data_frame, current_x, current_y,
200 current_heading, &bgr_canvas)) {
201 AERROR << "RenderTrafficLight failed";
202 return false;
203 }
204 if (!RenderObsPastBox(learning_data_frame, current_time_sec, &bgr_canvas)) {
205 AERROR << "RenderObsPastBox failed";
206 return false;
207 }
208 if (!RenderObsFutureBox(learning_data_frame, current_time_sec, &bgr_canvas)) {
209 AERROR << "RenderObsFutureBox failed";
210 return false;
211 }
212 if (!RenderEgoCurrentBox(&bgr_canvas)) {
213 AERROR << "RenderEgoCurrentBox failed";
214 return false;
215 }
216 if (!RenderEgoPastPoint(learning_data_frame, current_time_sec, current_x,
217 current_y, current_heading, &bgr_canvas)) {
218 AERROR << "RenderEgoPastPoint failed";
219 return false;
220 }
221
222 bgr_canvas.copyTo(*img_feature);
223
224 return true;
225}

◆ RenderCurrentEgoBox()

bool apollo::planning::BirdviewImgFeatureRenderer::RenderCurrentEgoBox ( const LearningDataFrame &  learning_data_frame,
cv::Mat *  img_feature 
)

generate a single channel img

参数
learning_data_framea proto message containing info for renderering
img_featurea pointer to opencv img to render on

在文件 birdview_img_feature_renderer.cc 第 239 行定义.

240 {
241 ego_cur_box_img_.copyTo(*img_feature);
242 return true;
243}

◆ RenderCurrentEgoPoint()

bool apollo::planning::BirdviewImgFeatureRenderer::RenderCurrentEgoPoint ( const LearningDataFrame &  learning_data_frame,
cv::Mat *  img_feature 
)

generate a single channel img

参数
learning_data_framea proto message containing info for renderering
img_featurea pointer to opencv img to render on

在文件 birdview_img_feature_renderer.cc 第 233 行定义.

234 {
235 ego_cur_point_img_.copyTo(*img_feature);
236 return true;
237}

◆ RenderCurrentEgoStatus()

bool apollo::planning::BirdviewImgFeatureRenderer::RenderCurrentEgoStatus ( const LearningDataFrame &  learning_data_frame,
cv::Mat *  img_feature 
)

generate a two channel img, one for cur box, one for cur point

参数
learning_data_framea proto message containing info for renderering
img_featurea pointer to opencv img to render on

在文件 birdview_img_feature_renderer.cc 第 227 行定义.

228 {
229 stacked_ego_cur_status_img_.copyTo(*img_feature);
230 return true;
231}

◆ RenderMultiChannelEnv()

bool apollo::planning::BirdviewImgFeatureRenderer::RenderMultiChannelEnv ( const LearningDataFrame &  learning_data_frame,
cv::Mat *  img_feature 
)

generate multi-channel img as input feature for certain model

参数
learning_data_framea proto message containing info for renderering
img_featurea pointer to opencv img to render on

在文件 birdview_img_feature_renderer.cc 第 96 行定义.

97 {
98 int ego_trajectory_point_history_size =
99 learning_data_frame.adc_trajectory_point_size();
100 if (ego_trajectory_point_history_size < 1) {
101 AERROR << "Ego past history is empty";
102 return false;
103 }
104
105 cv::Mat ego_past =
106 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
107 cv::Mat obs_past =
108 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
109 cv::Mat obs_future =
110 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
111 cv::Mat road_map =
112 cv::Mat(config_.height(), config_.width(), CV_8UC3, cv::Scalar(0, 0, 0));
113 cv::Mat routing =
114 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
115 cv::Mat speed_limit =
116 cv::Mat(config_.height(), config_.width(), CV_8UC3, cv::Scalar(0, 0, 0));
117 cv::Mat traffic_light =
118 cv::Mat(config_.height(), config_.width(), CV_8UC1, cv::Scalar(0));
119
120 const auto& current_traj_point = learning_data_frame.adc_trajectory_point(
121 ego_trajectory_point_history_size - 1);
122 const double current_time_sec = current_traj_point.timestamp_sec();
123 const auto& current_path_point =
124 current_traj_point.trajectory_point().path_point();
125 const double current_x = current_path_point.x();
126 const double current_y = current_path_point.y();
127 const double current_heading = current_path_point.theta();
128
129 if (!RenderEgoPastPoint(learning_data_frame, current_time_sec, current_x,
130 current_y, current_heading, &ego_past)) {
131 AERROR << "RenderEgoPastPoint failed";
132 return false;
133 }
134 if (!RenderObsPastBox(learning_data_frame, current_time_sec, &obs_past)) {
135 AERROR << "RenderObsPastBox failed";
136 return false;
137 }
138 if (!RenderObsFutureBox(learning_data_frame, current_time_sec, &obs_future)) {
139 AERROR << "RenderObsFutureBox failed";
140 return false;
141 }
142 if (!RenderLocalRoadMap(current_x, current_y, current_heading, &road_map)) {
143 AERROR << "RenderLocalRoadMap failed";
144 return false;
145 }
146 if (!RenderRouting(learning_data_frame, current_x, current_y, current_heading,
147 &routing)) {
148 AERROR << "RenderRouting failed";
149 return false;
150 }
151 if (!RenderLocalSpeedlimitMap(current_x, current_y, current_heading,
152 &speed_limit)) {
153 AERROR << "RenderLocalSpeedlimitMap failed";
154 return false;
155 }
156 if (!RenderTrafficLight(learning_data_frame, current_x, current_y,
157 current_heading, &traffic_light)) {
158 AERROR << "RenderTrafficLight failed";
159 return false;
160 }
161
162 std::vector<cv::Mat> merge_imgs = {ego_cur_box_img_, ego_past, obs_past,
163 obs_future, road_map, routing,
164 speed_limit, traffic_light};
165 cv::merge(merge_imgs, *img_feature);
166 return true;
167}

该类的文档由以下文件生成: