Apollo 10.0
自动驾驶开放平台
apollo::perception::trafficlight::Select类 参考

#include <select.h>

apollo::perception::trafficlight::Select 的协作图:

Public 成员函数

 Select ()=default
 Construct a new select object.
 
bool Init (int rows, int cols)
 Initialize select object parameters.
 
void SelectTrafficLights (const std::vector< base::TrafficLightPtr > &refined_bboxes, std::vector< base::TrafficLightPtr > *hdmap_bboxes)
 Choose traffic lights using Gaussian calculation scores.
 
double Calc2dGaussianScore (base::Point2DI p1, base::Point2DI p2, float sigma1, float sigma2)
 Calculate 2d Gaussian score.
 

详细描述

在文件 select.h 第 29 行定义.

构造及析构函数说明

◆ Select()

apollo::perception::trafficlight::Select::Select ( )
default

Construct a new select object.

成员函数说明

◆ Calc2dGaussianScore()

double apollo::perception::trafficlight::Select::Calc2dGaussianScore ( base::Point2DI  p1,
base::Point2DI  p2,
float  sigma1,
float  sigma2 
)

Calculate 2d Gaussian score.

参数
p1
p2
sigma1
sigma2
返回
double

在文件 select.cc 第 34 行定义.

35 {
36 return std::exp(-0.5 * (static_cast<float>((p1.x - p2.x) * (p1.x - p2.x)) /
37 (sigma1 * sigma1) +
38 (static_cast<float>((p1.y - p2.y) * (p1.y - p2.y)) /
39 (sigma2 * sigma2))));
40}

◆ Init()

bool apollo::perception::trafficlight::Select::Init ( int  rows,
int  cols 
)

Initialize select object parameters.

参数
rows
cols
返回
true
false

在文件 select.cc 第 24 行定义.

24 {
25 if (rows < 0 || cols < 0) {
26 return false;
27 }
28
29 munkres_.costs()->Reserve(rows, cols);
30
31 return true;
32}
void Reserve(const size_t reserve_height, const size_t reserve_width)

◆ SelectTrafficLights()

void apollo::perception::trafficlight::Select::SelectTrafficLights ( const std::vector< base::TrafficLightPtr > &  refined_bboxes,
std::vector< base::TrafficLightPtr > *  hdmap_bboxes 
)

Choose traffic lights using Gaussian calculation scores.

参数
refined_bboxes
hdmap_bboxes

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

44 {
45 std::vector<std::pair<size_t, size_t>> assignments;
46 munkres_.costs()->Resize(hdmap_bboxes->size(), refined_bboxes.size());
47
48 for (size_t row = 0; row < hdmap_bboxes->size(); ++row) {
49 auto center_hd = (*hdmap_bboxes)[row]->region.detection_roi.Center();
50 if ((*hdmap_bboxes)[row]->region.outside_image) {
51 AINFO << "projection_roi outside image, set score to 0.";
52 for (size_t col = 0; col < refined_bboxes.size(); ++col) {
53 (*munkres_.costs())(row, col) = 0.0;
54 }
55 continue;
56 }
57 for (size_t col = 0; col < refined_bboxes.size(); ++col) {
58 float gaussian_score = 100.0f;
59 auto center_refine = refined_bboxes[col]->region.detection_roi.Center();
60 // use gaussian score as metrics of distance and width
61 double distance_score = Calc2dGaussianScore(
62 center_hd, center_refine, gaussian_score, gaussian_score);
63
64 double max_score = 0.9;
65 auto detect_score = refined_bboxes[col]->region.detect_score;
66 double detection_score =
67 detect_score > max_score ? max_score : detect_score;
68
69 double distance_weight = 0.7;
70 double detection_weight = 1 - distance_weight;
71 (*munkres_.costs())(row, col) =
72 static_cast<float>(detection_weight * detection_score +
73 distance_weight * distance_score);
74 const auto &crop_roi = (*hdmap_bboxes)[row]->region.crop_roi;
75 const auto &detection_roi = refined_bboxes[col]->region.detection_roi;
76 if ((detection_roi & crop_roi) != detection_roi) {
77 AINFO << "detection_roi outside crop_roi, set score to 0."
78 << " detection_roi: " << detection_roi.x << " " << detection_roi.y
79 << " " << detection_roi.width << " " << detection_roi.height
80 << " crop_roi: " << crop_roi.x << " " << crop_roi.y << " "
81 << crop_roi.width << " " << crop_roi.height;
82 (*munkres_.costs())(row, col) = 0.0;
83 }
84 AINFO << "score " << (*munkres_.costs())(row, col);
85 }
86 }
87
88 munkres_.Maximize(&assignments);
89
90 for (size_t i = 0; i < hdmap_bboxes->size(); ++i) {
91 (*hdmap_bboxes)[i]->region.is_selected = false;
92 (*hdmap_bboxes)[i]->region.is_detected = false;
93 }
94
95 for (size_t i = 0; i < assignments.size(); ++i) {
96 if (static_cast<size_t>(assignments[i].first) >= hdmap_bboxes->size() ||
97 static_cast<size_t>(
98 assignments[i].second >= refined_bboxes.size() ||
99 (*hdmap_bboxes)[assignments[i].first]->region.is_selected ||
100 refined_bboxes[assignments[i].second]->region.is_selected)) {
101 } else {
102 auto &refined_bbox_region = refined_bboxes[assignments[i].second]->region;
103 auto &hdmap_bbox_region = (*hdmap_bboxes)[assignments[i].first]->region;
104 refined_bbox_region.is_selected = true;
105 hdmap_bbox_region.is_selected = true;
106
107 const auto &crop_roi = hdmap_bbox_region.crop_roi;
108 const auto &detection_roi = refined_bbox_region.detection_roi;
109 bool outside_crop_roi = ((crop_roi & detection_roi) != detection_roi);
110 if (hdmap_bbox_region.outside_image || outside_crop_roi) {
111 hdmap_bbox_region.is_detected = false;
112 } else {
113 hdmap_bbox_region.detection_roi = refined_bbox_region.detection_roi;
114 hdmap_bbox_region.detect_class_id = refined_bbox_region.detect_class_id;
115 hdmap_bbox_region.detect_score = refined_bbox_region.detect_score;
116 hdmap_bbox_region.is_detected = refined_bbox_region.is_detected;
117 hdmap_bbox_region.is_selected = refined_bbox_region.is_selected;
118 }
119 }
120 }
121
122 for (size_t i = 0; i < hdmap_bboxes->size(); ++i) {
123 AINFO << "hdmap_bboxes-" << i << ":"
124 << " projection_roi: "
125 << (*hdmap_bboxes)[i]->region.projection_roi.ToStr()
126 << " detection_roi: "
127 << (*hdmap_bboxes)[i]->region.detection_roi.ToStr();
128 }
129}
void Maximize(std::vector< std::pair< size_t, size_t > > *assignments)
void Resize(const size_t resize_height, const size_t resize_width)
double Calc2dGaussianScore(base::Point2DI p1, base::Point2DI p2, float sigma1, float sigma2)
Calculate 2d Gaussian score.
Definition select.cc:34
#define AINFO
Definition log.h:42

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