114 const std::vector<std::string> &camera_names,
115 const std::string &visual_camera,
118 const Eigen::Matrix4d &ex_lidar2imu,
const double pitch_adj_degree,
119 const double yaw_adj_degree,
const double roll_adj_degree,
120 const int image_height,
const int image_width) {
121 image_height_ = image_height;
122 image_width_ = image_width;
123 intrinsic_map_ = intrinsic_map;
124 extrinsic_map_ = extrinsic_map;
125 ex_lidar2imu_ = ex_lidar2imu;
126 camera_names_ = camera_names;
129 small_h_ =
static_cast<int>(image_height_ * scale_ratio_);
130 small_w_ =
static_cast<int>(image_width_ * scale_ratio_);
131 world_h_ = 2 * small_h_;
133 world_image_ = cv::Mat(world_h_, wide_pixel_, CV_8UC3,
black_color);
139 AINFO <<
"world_h_: " << world_h_;
140 AINFO <<
"wide_pixel_: " << wide_pixel_;
141 AINFO <<
"small_h_: " << small_h_;
142 AINFO <<
"small_w_: " << small_w_;
144 visual_camera_ = visual_camera;
146 for (
auto camera_name : camera_names) {
147 camera_image_[camera_name] =
149 camera_image_[camera_name] =
153 ex_camera2lidar_[camera_name] = extrinsic_map_.at(camera_name);
154 AINFO <<
"ex_camera2lidar_ = " << extrinsic_map_.at(camera_name);
156 AINFO <<
"ex_lidar2imu_ =" << ex_lidar2imu_;
159 ex_camera2imu_ = ex_lidar2imu_ * ex_camera2lidar_[camera_name];
160 AINFO <<
"ex_camera2imu_ =" << ex_camera2imu_;
163 K_[camera_name] = intrinsic_map_.at(camera_name).cast<
double>();
164 AINFO <<
"intrinsic K_ =" << K_[camera_name];
170 ex_imu2car_ << 0, 1, 0, 0,
176 ex_camera2car_ = ex_imu2car_ * ex_camera2imu_;
178 AINFO <<
"ex_camera2car_ =" << ex_camera2car_;
184 AINFO <<
"homography_image2ground_ ="
186 AINFO <<
"homography_ground2image_ ="
191 p_fov_1_.y =
static_cast<int>(image_height_ * fov_cut_ratio_);
193 p_fov_2_.x = image_width_ - 1;
194 p_fov_2_.y =
static_cast<int>(image_height_ * fov_cut_ratio_);
197 p_fov_3_.y = image_height_ - 1;
199 p_fov_4_.x = image_width_ - 1;
200 p_fov_4_.y = image_height_ - 1;
202 AINFO <<
"p_fov_1_ =" << p_fov_1_;
203 AINFO <<
"p_fov_2_ =" << p_fov_2_;
204 AINFO <<
"p_fov_3_ =" << p_fov_3_;
205 AINFO <<
"p_fov_4_ =" << p_fov_4_;
207 vp1_[camera_name](0) = 1024.0;
208 if (K_[camera_name](0, 0) >= 1.0) {
209 vp1_[camera_name](1) =
210 (image_width_ >> 1) * vp1_[camera_name](0) / K_[camera_name](0, 0);
212 AWARN <<
"Focal length (" << K_[camera_name](0, 0)
213 <<
" in pixel) is incorrect. "
214 <<
" Please check camera intrinsic parameters.";
215 vp1_[camera_name](1) = vp1_[camera_name](0) * 0.25;
218 vp2_[camera_name](0) = vp1_[camera_name](0);
219 vp2_[camera_name](1) = -vp1_[camera_name](1);
221 AINFO <<
"vanishing point 1:" << vp1_[camera_name];
222 AINFO <<
"vanishing point 2:" << vp2_[camera_name];
224 pitch_adj_degree_[camera_name] = pitch_adj_degree;
225 yaw_adj_degree_[camera_name] = yaw_adj_degree;
226 roll_adj_degree_[camera_name] = roll_adj_degree;
231 all_camera_recieved_ = 0x0;
237 const double pitch_adj_degree,
238 const double yaw_adj_degree,
239 const double roll_adj_degree) {
241 double pitch_adj_radian = pitch_adj_degree * degree_to_radian_factor_;
242 double yaw_adj_radian = yaw_adj_degree * degree_to_radian_factor_;
243 double roll_adj_radian = roll_adj_degree * degree_to_radian_factor_;
254 Rx << 1, 0, 0, 0, 0, cos(pitch_adj_radian), -sin(pitch_adj_radian), 0, 0,
255 sin(pitch_adj_radian), cos(pitch_adj_radian), 0, 0, 0, 0, 1;
257 Ry << cos(yaw_adj_radian), 0, sin(yaw_adj_radian), 0, 0, 1, 0, 0,
258 -sin(yaw_adj_radian), 0, cos(yaw_adj_radian), 0, 0, 0, 0, 1;
260 Rz << cos(roll_adj_radian), -sin(roll_adj_radian), 0, 0, sin(roll_adj_radian),
261 cos(roll_adj_radian), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1;
263 adjusted_camera2car_ = ex_camera2car_ * Rz * Ry * Rx;
264 AWARN <<
"adjusted_camera2car_: " << adjusted_camera2car_;
271 Eigen::Matrix3d R = adjusted_camera2car_.block(0, 0, 3, 3);
272 Eigen::Vector3d T = adjusted_camera2car_.block(0, 3, 3, 1);
274 Eigen::Matrix3d H_inv;
276 H.block(0, 0, 3, 2) = (K_[camera_name] * R.transpose()).block(0, 0, 3, 2);
277 H.block(0, 2, 3, 1) = -K_[camera_name] * R.transpose() * T;
616 AINFO <<
"Pressed Key: " << key;
622 show_associate_color_ = !show_associate_color_;
625 show_camera_box2d_ = !show_camera_box2d_;
628 show_camera_box3d_ = !show_camera_box3d_;
632 capture_video_ = !capture_video_;
636 show_box_ = (show_box_ + 1) % 2;
640 use_class_color_ = !use_class_color_;
644 show_radar_pc_ = !show_radar_pc_;
648 draw_lane_objects_ = !draw_lane_objects_;
652 show_fusion_ = !show_fusion_;
656 show_vp_grid_ = !show_vp_grid_;
660 show_help_text_ = !show_help_text_;
664 show_type_id_label_ = !show_type_id_label_;
668 show_verbose_ = !show_verbose_;
672 show_camera_bdv_ = !show_camera_bdv_;
676 show_lane_count_ = (show_lane_count_ + 1) % 3;
684 capture_screen_ =
true;
688 show_trajectory_ = !show_trajectory_;
692 show_velocity_ = (show_velocity_ + 1) % 2;
696 if (manual_calibration_mode_ &&
697 pitch_adj_degree_[camera_name] + 0.05 <= max_pitch_degree_) {
698 pitch_adj_degree_[camera_name] -= 0.05;
700 visual_camera_ = camera_names_[0];
702 AINFO <<
"Current pitch: " << pitch_adj_degree_[camera_name];
706 if (manual_calibration_mode_ &&
707 pitch_adj_degree_[camera_name] - 0.05 >= min_pitch_degree_) {
708 pitch_adj_degree_[camera_name] += 0.05;
710 visual_camera_ = camera_names_[1];
712 AINFO <<
"Current pitch: " << pitch_adj_degree_[camera_name];
716 if (manual_calibration_mode_ &&
717 yaw_adj_degree_[camera_name] + 0.05 <= max_yaw_degree_) {
718 yaw_adj_degree_[camera_name] -= 0.05;
720 AINFO <<
"Current yaw: " << yaw_adj_degree_[camera_name];
724 if (manual_calibration_mode_ &&
725 yaw_adj_degree_[camera_name] - 0.05 >= min_yaw_degree_) {
726 yaw_adj_degree_[camera_name] += 0.05;
728 AINFO <<
"Current yaw: " << yaw_adj_degree_[camera_name];
732 if (manual_calibration_mode_ &&
733 roll_adj_degree_[camera_name] + 0.05 <= max_roll_degree_) {
734 roll_adj_degree_[camera_name] -= 0.05;
736 AINFO <<
"Current roll: " << roll_adj_degree_[camera_name];
740 if (manual_calibration_mode_ &&
741 roll_adj_degree_[camera_name] - 0.05 >= min_roll_degree_) {
742 roll_adj_degree_[camera_name] += 0.05;
744 AINFO <<
"Current roll: " << roll_adj_degree_[camera_name];
748 if (manual_calibration_mode_) {
750 visual_camera_, pitch_adj_degree_[camera_name],
751 yaw_adj_degree_[camera_name], roll_adj_degree_[camera_name]);
752 AINFO <<
"Saved calibration parameters(pyr): ("
753 << pitch_adj_degree_[camera_name] <<
", "
754 << yaw_adj_degree_[camera_name] <<
", "
755 << roll_adj_degree_[camera_name] <<
")";
760 manual_calibration_mode_ = !manual_calibration_mode_;
766 help_str_ =
"H: show help";
767 if (show_help_text_) {
768 absl::StrAppend(&help_str_,
" (ON)\nR: reset matrxi\nB: show box");
770 absl::StrAppend(&help_str_,
"(ON)");
772 absl::StrAppend(&help_str_,
"\nV: show velocity");
773 if (show_velocity_) {
774 absl::StrAppend(&help_str_,
" (ON)");
776 absl::StrAppend(&help_str_,
"\nC: use class color");
777 if (use_class_color_) {
778 absl::StrAppend(&help_str_,
" (ON)");
780 absl::StrAppend(&help_str_,
"\nS: capture screen",
"\nA: capture video",
781 "\nI: show type id label");
782 if (show_type_id_label_) {
783 absl::StrAppend(&help_str_,
" (ON)");
785 absl::StrAppend(&help_str_,
"\nQ: show lane");
786 if (show_lane_count_ > 0) {
787 absl::StrAppend(&help_str_,
" (ON)");
789 absl::StrAppend(&help_str_,
"\nE: draw lane objects");
790 if (draw_lane_objects_) {
791 absl::StrAppend(&help_str_,
" (ON)");
793 absl::StrAppend(&help_str_,
"\nF: show fusion");
795 absl::StrAppend(&help_str_,
" (ON)");
797 absl::StrAppend(&help_str_,
"\nD: show radar pc");
798 if (show_radar_pc_) {
799 absl::StrAppend(&help_str_,
" (ON)");
801 absl::StrAppend(&help_str_,
"\nT: show trajectory");
802 if (show_trajectory_) {
803 absl::StrAppend(&help_str_,
" (ON)");
805 absl::StrAppend(&help_str_,
"\nO: show camera bdv");
806 if (show_camera_bdv_) {
807 absl::StrAppend(&help_str_,
" (ON)");
809 absl::StrAppend(&help_str_,
"\n2: show camera box2d");
810 if (show_camera_box2d_) {
811 absl::StrAppend(&help_str_,
" (ON)");
813 absl::StrAppend(&help_str_,
"\n3: show camera box3d");
814 if (show_camera_box3d_) {
815 absl::StrAppend(&help_str_,
" (ON)");
817 absl::StrAppend(&help_str_,
"\n0: show associate color");
818 if (show_associate_color_) {
819 absl::StrAppend(&help_str_,
" (ON)");
821 absl::StrAppend(&help_str_,
822 "\nG: show vanishing point and ground plane grid");
824 absl::StrAppend(&help_str_,
" (ON)");
826 absl::StrAppend(&help_str_,
"\nT: show verbose");
828 absl::StrAppend(&help_str_,
" (ON)");
844 if (manual_calibration_mode_) {
846 yaw_adj_degree_[camera_name],
847 roll_adj_degree_[camera_name]);
848 if (show_help_text_) {
849 absl::StrAppend(&help_str_,
850 "\nAdjusted Pitch: ", pitch_adj_degree_[camera_name]);
851 absl::StrAppend(&help_str_,
852 "\nAdjusted Yaw: ", yaw_adj_degree_[camera_name]);
853 absl::StrAppend(&help_str_,
854 "\nAdjusted Roll: ", roll_adj_degree_[camera_name]);
1012 const std::string &camera_name,
const cv::Mat &img,
1013 const CameraFrame &frame,
const Eigen::Matrix3d &intrinsic,
1014 const Eigen::Matrix4d &extrinsic,
const Eigen::Affine3d &world2camera,
1016 cv::Mat image_2D = img.clone();
1035 if (show_vp_grid_) {
1036 cv::line(image_2D,
ground2image(camera_name, vp1_[camera_name]),
1040 if (show_lane_count_ > 0) {
1043 if (show_lane_count_ == 1) {
1045 p_prev.x =
static_cast<int>(
object.curve_image_point_set[0].x);
1046 p_prev.y =
static_cast<int>(
object.curve_image_point_set[0].y);
1047 Eigen::Vector2d p_prev_ground =
image2ground(camera_name, p_prev);
1048 for (
unsigned i = 1; i <
object.curve_image_point_set.size(); i++) {
1050 p_cur.x =
static_cast<int>(
object.curve_image_point_set[i].x);
1051 p_cur.y =
static_cast<int>(
object.curve_image_point_set[i].y);
1052 Eigen::Vector2d p_cur_ground =
image2ground(camera_name, p_cur);
1054 if (p_cur.x >= 0 && p_cur.y >= 0 && p_prev.x >= 0 && p_prev.y >= 0 &&
1055 p_cur.x < image_width_ && p_cur.y < image_height_ &&
1056 p_prev.x < image_width_ && p_prev.y < image_height_) {
1057 cv::line(image_2D, p_prev, p_cur, lane_color, line_thickness_);
1062 p_prev_ground = p_cur_ground;
1064 }
else if (show_lane_count_ == 2) {
1066 Eigen::Vector2d p_prev_ground;
1068 std::max(std::abs(curve_coord.
x_end - curve_coord.
x_start) /
1069 static_cast<float>(lane_step_num_),
1071 float x = curve_coord.
x_start;
1072 p_prev_ground(0) = x;
1073 p_prev_ground(1) = curve_coord.
a * x * x * x + curve_coord.
b * x * x +
1074 curve_coord.
c * x + curve_coord.
d;
1075 cv::Point p_prev =
ground2image(camera_name, p_prev_ground);
1077 for (
unsigned int i = 0; x < curve_coord.
x_end && i < lane_step_num_;
1079 Eigen::Vector2d p_cur_ground;
1080 p_cur_ground(0) = x;
1081 p_cur_ground(1) = curve_coord.
a * x * x * x + curve_coord.
b * x * x +
1082 curve_coord.
c * x + curve_coord.
d;
1083 cv::Point p_cur =
ground2image(camera_name, p_cur_ground);
1084 if (p_cur.x >= 0 && p_cur.y >= 0 && p_prev.x >= 0 && p_prev.y >= 0 &&
1085 p_cur.x < image_width_ && p_cur.y < image_height_ &&
1086 p_prev.x < image_width_ && p_prev.y < image_height_) {
1087 cv::line(image_2D, p_prev, p_cur, lane_color, line_thickness_);
1092 p_prev_ground = p_cur_ground;
1102 cv::Rect r(
static_cast<int>(rect.x),
static_cast<int>(rect.y),
1103 static_cast<int>(rect.width),
static_cast<int>(rect.height));
1110 cv::Point(
static_cast<int>(rect.x),
static_cast<int>(rect.y) + 30),
1111 cv::FONT_HERSHEY_DUPLEX, 1,
red_color, 1);
1114 Eigen::Vector3d pos;
1116 ADEBUG <<
"object->track_id: " <<
object->track_id;
1121 Eigen::Vector2d c_2D_l;
1122 if (show_homography_object_) {
1123 pos <<
object->camera_supplement.local_center(0),
1124 object->camera_supplement.local_center(1),
1125 object->camera_supplement.local_center(2);
1126 ADEBUG <<
"Camera pos: (" << pos(0) <<
", " << pos(1) <<
", " << pos(2)
1128 theta_ray = atan2(pos(0), pos(2));
1129 theta =
object->camera_supplement.alpha + theta_ray;
1131 c_2D.x =
static_cast<int>(rect.x + rect.width / 2);
1132 c_2D.y =
static_cast<int>(rect.y + rect.height);
1133 ADEBUG <<
"Image Footprint c_2D: (" << c_2D.x <<
", " << c_2D.y <<
")";
1135 ADEBUG <<
"Image Footprint position: (" << c_2D_l(0) <<
", " << c_2D_l(1)
1138 pos = world2camera *
object->center;
1139 theta_ray = atan2(pos(0), pos(2));
1140 theta =
object->camera_supplement.alpha + theta_ray;
1141 ADEBUG <<
"Direct pos: (" << pos(0) <<
", " << pos(1) <<
", " << pos(2)
1146 c_2D_l(1) = -pos(0);
1147 ADEBUG <<
"Direct center position: (" << c_2D_l(0) <<
", " << c_2D_l(1)
1150 ADEBUG <<
"theta_ray: " << theta_ray * 180 / M_PI <<
" degree";
1151 ADEBUG <<
"object->camera_supplement.alpha: "
1152 <<
object->camera_supplement.alpha * 180 / M_PI <<
" degree";
1153 ADEBUG <<
"theta: " << theta * 180 / M_PI <<
" = "
1154 <<
object->camera_supplement.alpha * 180 / M_PI <<
" + "
1155 << theta_ray * 180 / M_PI;
1158 static_cast<float>(sqrt(c_2D_l(0) * c_2D_l(0) + c_2D_l(1) * c_2D_l(1)));
1159 char dist_string[100];
1160 snprintf(dist_string,
sizeof(dist_string),
"%.1fm", distance);
1163 image_2D, dist_string,
1164 cv::Point(
static_cast<int>(rect.x),
static_cast<int>(rect.y - 10)),
1167 if (show_camera_box3d_) {
1168 Eigen::Matrix3d rotate_ry;
1169 rotate_ry << cos(theta), 0, sin(theta), 0, 1, 0, -sin(theta), 0,
1173 std::vector<cv::Point> p_proj(8);
1174 p[0] <<
object->size(0) * 0.5,
object->size(2) * 0.5,
1175 object->size(1) * 0.5;
1176 p[1] << -
object->size(0) * 0.5,
object->size(2) * 0.5,
1177 object->size(1) * 0.5;
1178 p[2] << -
object->size(0) * 0.5,
object->size(2) * 0.5,
1179 -
object->size(1) * 0.5;
1180 p[3] <<
object->size(0) * 0.5,
object->size(2) * 0.5,
1181 -
object->size(1) * 0.5;
1182 p[4] <<
object->size(0) * 0.5, -
object->size(2) * 0.5,
1183 object->size(1) * 0.5;
1184 p[5] << -
object->size(0) * 0.5, -
object->size(2) * 0.5,
1185 object->size(1) * 0.5;
1186 p[6] << -
object->size(0) * 0.5, -
object->size(2) * 0.5,
1187 -
object->size(1) * 0.5;
1188 p[7] <<
object->size(0) * 0.5, -
object->size(2) * 0.5,
1189 -
object->size(1) * 0.5;
1191 for (uint i = 0; i < p.size(); i++) {
1192 proj[i] = intrinsic * (rotate_ry * p[i] + pos);
1193 if (fabs(p[i](2)) > std::numeric_limits<double>::min()) {
1194 p_proj[i].x =
static_cast<int>(proj[i](0) / proj[i](2));
1195 p_proj[i].y =
static_cast<int>(proj[i](1) / proj[i](2));
1198 if (object->b_cipv) {
1199 cv::line(image_2D, p_proj[0], p_proj[1], color_cipv_,
1200 cipv_line_thickness_);
1201 cv::line(image_2D, p_proj[1], p_proj[2], color_cipv_,
1202 cipv_line_thickness_);
1203 cv::line(image_2D, p_proj[2], p_proj[3], color_cipv_,
1204 cipv_line_thickness_);
1205 cv::line(image_2D, p_proj[3], p_proj[0], color_cipv_,
1206 cipv_line_thickness_);
1207 cv::line(image_2D, p_proj[4], p_proj[5], color_cipv_,
1208 cipv_line_thickness_);
1209 cv::line(image_2D, p_proj[5], p_proj[6], color_cipv_,
1210 cipv_line_thickness_);
1211 cv::line(image_2D, p_proj[6], p_proj[7], color_cipv_,
1212 cipv_line_thickness_);
1213 cv::line(image_2D, p_proj[7], p_proj[4], color_cipv_,
1214 cipv_line_thickness_);
1215 cv::line(image_2D, p_proj[0], p_proj[4], color_cipv_,
1216 cipv_line_thickness_);
1217 cv::line(image_2D, p_proj[1], p_proj[5], color_cipv_,
1218 cipv_line_thickness_);
1219 cv::line(image_2D, p_proj[2], p_proj[6], color_cipv_,
1220 cipv_line_thickness_);
1221 cv::line(image_2D, p_proj[3], p_proj[7], color_cipv_,
1222 cipv_line_thickness_);
1225 cv::line(image_2D, p_proj[0], p_proj[1], color, line_thickness_);
1226 cv::line(image_2D, p_proj[1], p_proj[2], color, line_thickness_);
1227 cv::line(image_2D, p_proj[2], p_proj[3], color, line_thickness_);
1228 cv::line(image_2D, p_proj[3], p_proj[0], color, line_thickness_);
1229 cv::line(image_2D, p_proj[4], p_proj[5], color, line_thickness_);
1230 cv::line(image_2D, p_proj[5], p_proj[6], color, line_thickness_);
1231 cv::line(image_2D, p_proj[6], p_proj[7], color, line_thickness_);
1232 cv::line(image_2D, p_proj[7], p_proj[4], color, line_thickness_);
1233 cv::line(image_2D, p_proj[0], p_proj[4], color, line_thickness_);
1234 cv::line(image_2D, p_proj[1], p_proj[5], color, line_thickness_);
1235 cv::line(image_2D, p_proj[2], p_proj[6], color, line_thickness_);
1236 cv::line(image_2D, p_proj[3], p_proj[7], color, line_thickness_);
1238 if (object->b_cipv) {
1239 cv::rectangle(image_2D, r, color_cipv_, cipv_line_thickness_);
1241 cv::rectangle(image_2D, r, color, 2);
1245 Eigen::Matrix2d rotate_rz;
1246 theta = theta - M_PI_2;
1247 rotate_rz << cos(theta), sin(theta), -sin(theta), cos(theta);
1249 p1 <<
object->size(0) * 0.5,
object->size(1) * 0.5;
1250 p1 = rotate_rz * p1 + c_2D_l;
1252 p2 << -
object->size(0) * 0.5,
object->size(1) * 0.5;
1253 p2 = rotate_rz * p2 + c_2D_l;
1255 p3 << -
object->size(0) * 0.5, -
object->size(1) * 0.5;
1256 p3 = rotate_rz * p3 + c_2D_l;
1258 p4 <<
object->size(0) * 0.5, -
object->size(1) * 0.5;
1259 p4 = rotate_rz * p4 + c_2D_l;
1261 Eigen::Vector2d pos_2d;
1262 pos_2d << c_2D_l(0), c_2D_l(1);
1264 v <<
object->velocity(0),
object->velocity(1),
object->velocity(2);
1265 v = world2camera.linear() * v;
1266 Eigen::Vector2d v_2d;
1267 v_2d << v(0) + pos_2d(0), v(1) + pos_2d(1);
1269 AINFO <<
"v.norm: " << v.norm();
1270 if (show_trajectory_ && motion_buffer !=
nullptr &&
1271 motion_buffer->size() > 0 && v.norm() > speed_limit_) {
1274 if (object->b_cipv) {
1288 color, line_thickness_);
1290 color, line_thickness_);
1292 color, line_thickness_);
1294 color, line_thickness_);
1300 if (show_virtual_egolane_) {
1301 EgoLane virtual_egolane_ground;
1302 virtual_egolane_ground.
left_line.line_point.clear();
1303 virtual_egolane_ground.
right_line.line_point.clear();
1305 if (motion_buffer ==
nullptr || motion_buffer->size() == 0) {
1306 AWARN <<
"motion_buffer_ is empty";
1310 cipv_options.
velocity = motion_buffer->back().velocity;
1311 cipv_options.
yaw_rate = motion_buffer->back().yaw_rate;
1318 Eigen::Vector2d p_prev_ground;
1319 p_prev_ground(0) = virtual_egolane_ground.
left_line.line_point[0](0);
1320 p_prev_ground(1) = virtual_egolane_ground.
left_line.line_point[0](1);
1321 cv::Point p_prev =
ground2image(camera_name, p_prev_ground);
1322 for (
unsigned i = 1; i < virtual_egolane_ground.
left_line.line_point.size();
1324 Eigen::Vector2d p_cur_ground;
1325 p_cur_ground(0) = virtual_egolane_ground.
left_line.line_point[i](0);
1326 p_cur_ground(1) = virtual_egolane_ground.
left_line.line_point[i](1);
1327 cv::Point p_cur =
ground2image(camera_name, p_cur_ground);
1328 if (p_cur.x >= 0 && p_cur.y >= 0 && p_prev.x >= 0 && p_prev.y >= 0 &&
1329 p_cur.x < image_width_ && p_cur.y < image_height_ &&
1330 p_prev.x < image_width_ && p_prev.y < image_height_) {
1331 cv::line(image_2D, p_prev, p_cur, virtual_lane_color_, line_thickness_);
1336 p_prev_ground = p_cur_ground;
1340 p_prev_ground(0) = virtual_egolane_ground.
right_line.line_point[0](0);
1341 p_prev_ground(1) = virtual_egolane_ground.
right_line.line_point[0](1);
1343 for (
unsigned i = 1;
1344 i < virtual_egolane_ground.
right_line.line_point.size(); i++) {
1345 Eigen::Vector2d p_cur_ground;
1346 p_cur_ground(0) = virtual_egolane_ground.
right_line.line_point[i](0);
1347 p_cur_ground(1) = virtual_egolane_ground.
right_line.line_point[i](1);
1348 cv::Point p_cur =
ground2image(camera_name, p_cur_ground);
1350 if (p_cur.x >= 0 && p_cur.y >= 0 && p_prev.x >= 0 && p_prev.y >= 0 &&
1351 p_cur.x < image_width_ && p_cur.y < image_height_ &&
1352 p_prev.x < image_width_ && p_prev.y < image_height_) {
1353 cv::line(image_2D, p_prev, p_cur, virtual_lane_color_, line_thickness_);
1358 p_prev_ground = p_cur_ground;
1363 camera_image_[frame.
data_provider->sensor_name()] = image_2D;
1364 cv::resize(image_2D, camera_image_[frame.
data_provider->sensor_name()],
1365 cv::Size(small_w_, small_h_));
1371 const Eigen::Affine3d &world2camera) {
1372 if (frame.
timestamp - last_timestamp_ < 0.02)
return;
1374 world_image_ = cv::Mat(world_h_, wide_pixel_, CV_8UC3,
black_color);
1376 cv::imwrite(
"./test.png", img);
1380 cv::Mat image = img.clone();
1381 std::string camera_name = frame.
data_provider->sensor_name();
1382 if (manual_calibration_mode_) {
1385 "Manual Calibration: Pitch(up/down) Yaw(left/right) "
1386 "Roll(SH+left/right)",
1387 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
1391 cv::putText(image, camera_name, cv::Point(10, line_pos),
1392 cv::FONT_HERSHEY_DUPLEX, 1.3,
red_color, 3);
1394 cv::putText(image, absl::StrCat(
"frame id: ", frame.
frame_id),
1395 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
red_color,
1398 if (motion_buffer !=
nullptr) {
1400 image, absl::StrCat(
"yaw rate: ", motion_buffer->back().yaw_rate),
1401 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
red_color, 3);
1404 image, absl::StrCat(
"pitch rate: ", motion_buffer->back().pitch_rate),
1405 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
red_color, 3);
1408 image, absl::StrCat(
"roll rate: ", motion_buffer->back().roll_rate),
1409 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
red_color, 3);
1412 image, absl::StrCat(
"velocity: ", motion_buffer->back().velocity),
1413 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
red_color, 3);
1424 cv::Point(
static_cast<int>(image_width_ >> 1),
1425 static_cast<int>(frame.
pred_vpt[1])),
1430 if (object->b_cipv) {
1432 cv::putText(image, absl::StrCat(
"CIPV: ", object->track_id),
1433 cv::Point(10, line_pos), cv::FONT_HERSHEY_DUPLEX, 1.3,
1438 if (intrinsic_map_.find(camera_name) != intrinsic_map_.end() &&
1439 extrinsic_map_.find(camera_name) != extrinsic_map_.end()) {
1441 camera_name, image, frame,
1442 intrinsic_map_.at(camera_name).cast<
double>(),
1443 extrinsic_map_.at(camera_name), world2camera, motion_buffer);
1445 AERROR <<
"Failed to find necessuary intrinsic or extrinsic params.";
1450 if (camera_name == camera_names_[0]) {
1451 all_camera_recieved_ |= 0x1;
1452 }
else if (camera_name == camera_names_[1]) {
1453 all_camera_recieved_ |= 0x2;
1455 if (all_camera_recieved_ == 0x3) {
1456 if (camera_name == visual_camera_) {
1459 &(camera_image_[visual_camera_]));
1460 cv::Mat bigimg(world_h_, small_w_ + wide_pixel_, CV_8UC3);
1461 camera_image_[camera_names_[0]].copyTo(
1462 bigimg(cv::Rect(0, 0, small_w_, small_h_)));
1463 camera_image_[camera_names_[1]].copyTo(
1464 bigimg(cv::Rect(0, small_h_, small_w_, small_h_)));
1465 world_image_.copyTo(
1466 bigimg(cv::Rect(small_w_, 0, wide_pixel_, world_h_)));
1478 snprintf(path,
sizeof(path),
"%s/%06d.jpg", path_.c_str(), k++);
1479 AINFO <<
"snapshot is saved at " << path;
1480 cv::imwrite(path, bigimg);
1482 all_camera_recieved_ = 0x0;