Skip to content

Commit 55d3282

Browse files
author
wangfanghao
committed
fix(perception): fix lane detection offline tool
Change-Id: I0a99c0602c82c85e94663b139fd3a218b3838e7f
1 parent ea9d6a3 commit 55d3282

File tree

5 files changed

+168
-156
lines changed

5 files changed

+168
-156
lines changed

modules/perception/camera/tools/lane_detection/BUILD_ renamed to modules/perception/camera/tools/lane_detection/BUILD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ cc_binary(
2626
"//modules/perception/camera/common",
2727
"//modules/perception/camera/lib/calibration_service/online_calibration_service",
2828
"//modules/perception/camera/lib/interface",
29+
"//modules/perception/camera/lib/lane/detector/darkSCNN:darkSCNN_lane_detector",
2930
"//modules/perception/camera/lib/lane/detector/denseline:denseline_lane_detector",
31+
"//modules/perception/camera/lib/lane/postprocessor/darkSCNN:darkSCNN_lane_postprocessor",
3032
"//modules/perception/camera/lib/lane/postprocessor/denseline:denseline_lane_postprocessor",
33+
"//modules/perception/camera/tools/common",
34+
"//modules/perception/common:perception_gflags",
3135
"//modules/perception/common/io:io_util",
3236
"@com_github_gflags_gflags//:gflags",
33-
"@opencv",
37+
"@opencv//:imgproc",
3438
],
3539
)
3640

modules/perception/camera/tools/lane_detection/lane_common.cc

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,20 @@
1717

1818
#include "cyber/common/log.h"
1919

20+
DEFINE_bool(lane_line_debug, true, "draw the lane line result");
21+
DEFINE_bool(lane_cc_debug, true, "show lane cc image");
22+
DEFINE_bool(lane_result_output, true, "output the lane result");
23+
DEFINE_int32(height, 1080, "image height");
24+
DEFINE_int32(width, 1920, "image width");
25+
DEFINE_string(image_dir, "./image/", "test image directory");
26+
DEFINE_string(camera_intrinsics_yaml, "params/front_6mm_intrinsics.yaml",
27+
"camera intrinsics_yaml");
2028
DEFINE_string(list, "test.list", "test file title");
2129
DEFINE_string(file_title, "", "test file title");
2230
DEFINE_string(debug_file, "", "debug file title");
2331
DEFINE_string(save_dir, "./result/", "test file title");
2432
DEFINE_string(file_ext_name, "", "file extension name");
2533
DEFINE_string(file_debug_list, "", "file extension name");
26-
DEFINE_bool(lane_line_debug, false, "draw the lane line result");
27-
DEFINE_bool(lane_cc_debug, false, "show lane cc image");
28-
DEFINE_bool(lane_center_debug, false, "draw the lane center result");
29-
DEFINE_bool(lane_ego_debug, false, "lane ego debug");
30-
DEFINE_bool(lane_result_output, false, "output the lane result");
31-
DEFINE_bool(lane_points_output, false, "output the detected lane points");
32-
DEFINE_string(image_dir, "./image/", "test image directory");
33-
DEFINE_string(camera_intrinsics_yaml, "params/front_6mm_intrinsics.yaml",
34-
"camera intrinsics_yaml");
3534

3635
namespace apollo {
3736
namespace perception {
@@ -66,6 +65,44 @@ void show_detect_point_set(
6665
cv::imwrite(save_path, draw_mat);
6766
}
6867

68+
void show_detect_point_set(
69+
const cv::Mat& image,
70+
const std::vector<base::Point2DF>& img_laneline_point_set,
71+
const std::string& save_path) {
72+
cv::Scalar color = cv::Scalar(0, 255, 0);
73+
int draw_size = 2;
74+
75+
cv::Mat draw_mat = image.clone();
76+
for (size_t i = 0; i < img_laneline_point_set.size(); ++i) {
77+
const base::Point2DF& point = img_laneline_point_set[i];
78+
cv::circle(draw_mat,
79+
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
80+
draw_size, color, 4);
81+
}
82+
cv::imwrite(save_path, draw_mat);
83+
}
84+
85+
void show_detect_point_set(
86+
const cv::Mat& image,
87+
const std::vector<base::Point2DF>& img_laneline_point_set,
88+
const std::vector<float>& point_score_vec, const std::string& save_path) {
89+
cv::Scalar color = cv::Scalar(0, 255, 0);
90+
int draw_size = 2;
91+
92+
cv::Mat draw_mat = image.clone();
93+
for (size_t i = 0; i < img_laneline_point_set.size(); ++i) {
94+
const base::Point2DF& point = img_laneline_point_set[i];
95+
std::string label = cv::format("%.2f", point_score_vec[i]);
96+
cv::putText(draw_mat, label,
97+
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
98+
cv::FONT_HERSHEY_PLAIN, 1.0, cv::Scalar(255, 255, 255));
99+
cv::circle(draw_mat,
100+
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
101+
draw_size, color, 4);
102+
}
103+
cv::imwrite(save_path, draw_mat);
104+
}
105+
69106
void show_all_infer_point_set(const cv::Mat& image,
70107
const std::vector<LanePointInfo>& infer_point_set,
71108
const std::string& save_path) {
@@ -149,7 +186,7 @@ void show_lane_lines(const cv::Mat& image,
149186
cv::line(draw_ipm, cv::Point(0, y), cv::Point(ipm_width, y),
150187
cv::Scalar(255, 255, 255));
151188
std::string label = cv::format("%d", i);
152-
cv::putText(draw_ipm, label, cv::Point(x, y), CV_FONT_HERSHEY_COMPLEX_SMALL,
189+
cv::putText(draw_ipm, label, cv::Point(x, y), cv::FONT_HERSHEY_PLAIN,
153190
1.0, cv::Scalar(255, 255, 255));
154191
}
155192
cv::Rect roi(0, 0, ipm_width, ipm_height);
@@ -326,23 +363,6 @@ void output_laneline_to_txt(const std::vector<base::LaneLine>& lane_objects,
326363
fclose(file_save);
327364
}
328365

329-
void show_detect_point_set(
330-
const cv::Mat& image,
331-
const std::vector<base::Point2DF>& img_laneline_point_set,
332-
const std::string& save_path) {
333-
cv::Scalar color = cv::Scalar(0, 255, 0);
334-
int draw_size = 2;
335-
336-
cv::Mat draw_mat = image.clone();
337-
for (size_t i = 0; i < img_laneline_point_set.size(); ++i) {
338-
const base::Point2DF& point = img_laneline_point_set[i];
339-
cv::circle(draw_mat,
340-
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
341-
draw_size, color, 4);
342-
}
343-
cv::imwrite(save_path, draw_mat);
344-
}
345-
346366
void show_neighbor_point_set(
347367
const cv::Mat& image,
348368
const std::vector<base::Point2DF>& img_laneline_point_set,
@@ -371,31 +391,11 @@ void show_neighbor_point_set(
371391
std::string label = cv::format("%d", pass_point_num);
372392
cv::putText(draw_mat, label,
373393
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
374-
CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(255, 255, 255));
394+
cv::FONT_HERSHEY_PLAIN, 1.0, cv::Scalar(255, 255, 255));
375395
}
376396
cv::imwrite(save_path, draw_mat);
377397
}
378398

379-
void show_detect_point_set(
380-
const cv::Mat& image,
381-
const std::vector<base::Point2DF>& img_laneline_point_set,
382-
const std::vector<float>& point_score_vec, const std::string& save_path) {
383-
cv::Scalar color = cv::Scalar(0, 255, 0);
384-
int draw_size = 2;
385-
386-
cv::Mat draw_mat = image.clone();
387-
for (size_t i = 0; i < img_laneline_point_set.size(); ++i) {
388-
const base::Point2DF& point = img_laneline_point_set[i];
389-
std::string label = cv::format("%.2f", point_score_vec[i]);
390-
cv::putText(draw_mat, label,
391-
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
392-
CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(255, 255, 255));
393-
cv::circle(draw_mat,
394-
cv::Point(static_cast<int>(point.x), static_cast<int>(point.y)),
395-
draw_size, color, 4);
396-
}
397-
cv::imwrite(save_path, draw_mat);
398-
}
399399

400400
} // namespace camera
401401
} // namespace perception

modules/perception/camera/tools/lane_detection/lane_common.h

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,25 @@
1818
#include <string>
1919
#include <vector>
2020

21-
#include <opencv2/opencv.hpp>
21+
#include "gflags/gflags.h"
22+
#include "opencv2/opencv.hpp"
2223

2324
#include "modules/perception/base/lane_struct.h"
2425
#include "modules/perception/base/point.h"
2526
#include "modules/perception/camera/lib/lane/common/common_functions.h"
2627

28+
DECLARE_bool(lane_line_debug);
29+
DECLARE_bool(lane_cc_debug);
30+
DECLARE_bool(lane_result_output);
31+
DECLARE_int32(height);
32+
DECLARE_int32(width);
2733
DECLARE_string(list);
2834
DECLARE_string(file_title);
2935
DECLARE_string(debug_file);
3036
DECLARE_string(save_dir);
3137
DECLARE_string(file_ext_name);
3238
DECLARE_string(file_debug_list);
33-
DECLARE_bool(lane_line_debug);
34-
DECLARE_bool(lane_cc_debug);
35-
#if 0
36-
DECLARE_bool(lane_center_debug);
37-
DECLARE_bool(lane_ego_debug);
38-
#endif
39-
DECLARE_bool(lane_result_output);
40-
#if 0
41-
DECLARE_bool(lane_points_output);
4239
DECLARE_string(image_dir);
43-
#endif
4440
DECLARE_string(camera_intrinsics_yaml);
4541

4642
namespace apollo {
@@ -52,6 +48,16 @@ void show_detect_point_set(
5248
const std::vector<std::vector<LanePointInfo>>& detect_laneline_point_set,
5349
const std::string& save_path);
5450

51+
void show_detect_point_set(
52+
const cv::Mat& image,
53+
const std::vector<base::Point2DF>& img_laneline_point_set,
54+
const std::string& save_path);
55+
56+
void show_detect_point_set(
57+
const cv::Mat& image,
58+
const std::vector<base::Point2DF>& img_laneline_point_set,
59+
const std::vector<float>& point_score_vec, const std::string& save_path);
60+
5561
void show_all_infer_point_set(const cv::Mat& image,
5662
const std::vector<LanePointInfo>& infer_point_set,
5763
const std::string& save_path);
@@ -67,6 +73,12 @@ void show_lane_ccs(const std::vector<unsigned char>& lane_map,
6773
const std::vector<ConnectedComponent>& lane_ccs,
6874
const std::vector<ConnectedComponent>& select_lane_ccs,
6975
const std::string& save_path);
76+
77+
void show_neighbor_point_set(
78+
const cv::Mat& image,
79+
const std::vector<base::Point2DF>& img_laneline_point_set,
80+
const std::vector<int>& neighbor_point_info, const std::string& save_path);
81+
7082
//
7183
// save the lane line and points to json format
7284
void output_laneline_to_json(const std::vector<base::LaneLine>& lane_objects,

0 commit comments

Comments
 (0)