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

#include <object_template_manager.h>

apollo::perception::camera::ObjectTemplateManager 的协作图:

Public 成员函数

bool Init ()
 
float VehObjHwlBySearchTemplates (float *hwl, int *index=nullptr, bool *is_flip=nullptr)
 
const int NrDimPerTmplt ()
 
const std::vector< float > & VehHwl ()
 
const std::map< TemplateIndex, int > & LookUpTableMinVolumeIndex ()
 
const std::map< base::ObjectSubType, float > & TypeSpeedLimit ()
 
const std::vector< base::ObjectSubType > & TypeRefinedByTemplate ()
 
const std::vector< base::ObjectSubType > & TypeRefinedByRef ()
 
const std::vector< base::ObjectSubType > & TypeCanBeRef ()
 
const TemplateMapMinTemplateHWL ()
 
const TemplateMapMidTemplateHWL ()
 
const TemplateMapMaxTemplateHWL ()
 
const std::vector< TemplateMap > & TemplateHWL ()
 

详细描述

在文件 object_template_manager.h45 行定义.

成员函数说明

◆ Init()

bool apollo::perception::camera::ObjectTemplateManager::Init ( )

在文件 object_template_manager.cc54 行定义.

54 {
55 lib::MutexLock lock(&mutex_);
56 if (inited_) {
57 return true;
58 }
59
60 nr_dim_per_tmplt_ = 3;
61
62 std::string config_file = GetCommonConfigFile(FLAGS_object_template_file);
63 ObjectTemplateMeta proto;
64 if (!cyber::common::GetProtoFromFile(config_file, &proto)) {
65 AERROR << "Read config failed: " << config_file;
66 return false;
67 }
68
69 ACHECK(proto.has_max_dim_change_ratio());
70
71 ACHECK(proto.has_unknown());
72 ACHECK(proto.has_unknown_movable());
73 ACHECK(proto.has_unknown_unmovable());
74 ACHECK(proto.has_car());
75 ACHECK(proto.has_van());
76 ACHECK(proto.has_truck());
77 ACHECK(proto.has_bus());
78 ACHECK(proto.has_cyclist());
79 ACHECK(proto.has_motorcyclist());
80 ACHECK(proto.has_tricyclist());
81 ACHECK(proto.has_pedestrian());
82 ACHECK(proto.has_trafficcone());
83
84 CHECK_LE(proto.car().dim_size(), 3);
85 CHECK_LE(proto.van().dim_size(), 3);
86 CHECK_LE(proto.truck().dim_size(), 3);
87 CHECK_LE(proto.bus().dim_size(), 3);
88 CHECK_LE(proto.cyclist().dim_size(), 3);
89 CHECK_LE(proto.motorcyclist().dim_size(), 3);
90 CHECK_LE(proto.tricyclist().dim_size(), 3);
91 CHECK_LE(proto.pedestrian().dim_size(), 3);
92 CHECK_LE(proto.trafficcone().dim_size(), 3);
93
94 ACHECK(proto.unknown().has_speed_limit());
95 ACHECK(proto.unknown_movable().has_speed_limit());
96 ACHECK(proto.unknown_unmovable().has_speed_limit());
97 ACHECK(proto.car().has_speed_limit());
98 ACHECK(proto.van().has_speed_limit());
99 ACHECK(proto.truck().has_speed_limit());
100 ACHECK(proto.bus().has_speed_limit());
101 ACHECK(proto.cyclist().has_speed_limit());
102 ACHECK(proto.motorcyclist().has_speed_limit());
103 ACHECK(proto.tricyclist().has_speed_limit());
104 ACHECK(proto.pedestrian().has_speed_limit());
105 ACHECK(proto.trafficcone().has_speed_limit());
106
107 max_dim_change_ratio_ = proto.max_dim_change_ratio();
108
109 total_nr_tmplts_veh_ = proto.car().dim_size() + proto.van().dim_size() +
110 proto.truck().dim_size() + proto.bus().dim_size();
111
112 look_up_table_min_volume_index_.clear();
113 veh_hwl_.resize(0);
114 look_up_table_min_volume_index_[TemplateIndex::CAR_MIN_VOLUME_INDEX] =
115 static_cast<int>(veh_hwl_.size());
116 LoadVehTemplates(proto.car());
117 look_up_table_min_volume_index_[TemplateIndex::VAN_MIN_VOLUME_INDEX] =
118 static_cast<int>(veh_hwl_.size());
119 LoadVehTemplates(proto.van());
120 look_up_table_min_volume_index_[TemplateIndex::TRUCK_MIN_VOLUME_INDEX] =
121 static_cast<int>(veh_hwl_.size());
122 LoadVehTemplates(proto.truck());
123 look_up_table_min_volume_index_[TemplateIndex::BUS_MIN_VOLUME_INDEX] =
124 static_cast<int>(veh_hwl_.size());
125 LoadVehTemplates(proto.bus());
126
127 min_template_hwl_.clear();
128 mid_template_hwl_.clear();
129 max_template_hwl_.clear();
130 LoadVehMinMidMaxTemplates(base::ObjectSubType::CAR, proto.car());
131 LoadVehMinMidMaxTemplates(base::ObjectSubType::VAN, proto.van());
132 LoadVehMinMidMaxTemplates(base::ObjectSubType::TRUCK, proto.truck());
133 LoadVehMinMidMaxTemplates(base::ObjectSubType::BUS, proto.bus());
134 LoadVehMinMidMaxTemplates(base::ObjectSubType::CYCLIST, proto.cyclist());
135 LoadVehMinMidMaxTemplates(base::ObjectSubType::MOTORCYCLIST,
136 proto.motorcyclist());
137 LoadVehMinMidMaxTemplates(base::ObjectSubType::TRICYCLIST,
138 proto.tricyclist());
139 LoadVehMinMidMaxTemplates(base::ObjectSubType::PEDESTRIAN,
140 proto.pedestrian());
141 LoadVehMinMidMaxTemplates(base::ObjectSubType::TRAFFICCONE,
142 proto.trafficcone());
143
144 template_hwl_.resize(0);
145 template_hwl_.push_back(min_template_hwl_);
146 template_hwl_.push_back(mid_template_hwl_);
147 template_hwl_.push_back(max_template_hwl_);
148
149 type_speed_limit_.clear();
150 type_speed_limit_[base::ObjectSubType::UNKNOWN] =
151 proto.unknown().speed_limit();
152 type_speed_limit_[base::ObjectSubType::UNKNOWN_MOVABLE] =
153 proto.unknown_movable().speed_limit();
154 type_speed_limit_[base::ObjectSubType::UNKNOWN_UNMOVABLE] =
155 proto.unknown_unmovable().speed_limit();
156 type_speed_limit_[base::ObjectSubType::CAR] = proto.car().speed_limit();
157 type_speed_limit_[base::ObjectSubType::VAN] = proto.van().speed_limit();
158 type_speed_limit_[base::ObjectSubType::TRUCK] = proto.truck().speed_limit();
159 type_speed_limit_[base::ObjectSubType::BUS] = proto.bus().speed_limit();
160 type_speed_limit_[base::ObjectSubType::CYCLIST] =
161 proto.cyclist().speed_limit();
162 type_speed_limit_[base::ObjectSubType::MOTORCYCLIST] =
163 proto.motorcyclist().speed_limit();
164 type_speed_limit_[base::ObjectSubType::TRICYCLIST] =
165 proto.tricyclist().speed_limit();
166 type_speed_limit_[base::ObjectSubType::PEDESTRIAN] =
167 proto.pedestrian().speed_limit();
168 type_speed_limit_[base::ObjectSubType::TRAFFICCONE] =
169 proto.trafficcone().speed_limit();
170
171 type_can_be_ref_ = kTypeCanBeRef;
172 type_refined_by_template_ = kTypeRefinedByTemplate;
173 type_refined_by_ref_ = kTypeRefinedByRef;
174
175 inited_ = true;
176 AINFO << "Init object_template_manager success.";
177 return true;
178}
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
std::vector< base::ObjectSubType > kTypeRefinedByTemplate
std::vector< base::ObjectSubType > kTypeCanBeRef
std::vector< base::ObjectSubType > kTypeRefinedByRef
std::string GetCommonConfigFile(const std::string &config_file)
Get the perception common config path
Definition util.cc:28

◆ LookUpTableMinVolumeIndex()

const std::map< TemplateIndex, int > & apollo::perception::camera::ObjectTemplateManager::LookUpTableMinVolumeIndex ( )
inline

在文件 object_template_manager.h59 行定义.

59 {
60 ACHECK(inited_);
61 return look_up_table_min_volume_index_;
62 }

◆ MaxTemplateHWL()

const TemplateMap & apollo::perception::camera::ObjectTemplateManager::MaxTemplateHWL ( )
inline

在文件 object_template_manager.h87 行定义.

87 {
88 ACHECK(inited_);
89 return max_template_hwl_;
90 }

◆ MidTemplateHWL()

const TemplateMap & apollo::perception::camera::ObjectTemplateManager::MidTemplateHWL ( )
inline

在文件 object_template_manager.h83 行定义.

83 {
84 ACHECK(inited_);
85 return mid_template_hwl_;
86 }

◆ MinTemplateHWL()

const TemplateMap & apollo::perception::camera::ObjectTemplateManager::MinTemplateHWL ( )
inline

在文件 object_template_manager.h79 行定义.

79 {
80 ACHECK(inited_);
81 return min_template_hwl_;
82 }

◆ NrDimPerTmplt()

const int apollo::perception::camera::ObjectTemplateManager::NrDimPerTmplt ( )
inline

在文件 object_template_manager.h51 行定义.

51 {
52 ACHECK(inited_);
53 return nr_dim_per_tmplt_;
54 }

◆ TemplateHWL()

const std::vector< TemplateMap > & apollo::perception::camera::ObjectTemplateManager::TemplateHWL ( )
inline

在文件 object_template_manager.h91 行定义.

91 {
92 ACHECK(inited_);
93 return template_hwl_;
94 }

◆ TypeCanBeRef()

const std::vector< base::ObjectSubType > & apollo::perception::camera::ObjectTemplateManager::TypeCanBeRef ( )
inline

在文件 object_template_manager.h75 行定义.

75 {
76 ACHECK(inited_);
77 return type_can_be_ref_;
78 }

◆ TypeRefinedByRef()

const std::vector< base::ObjectSubType > & apollo::perception::camera::ObjectTemplateManager::TypeRefinedByRef ( )
inline

在文件 object_template_manager.h71 行定义.

71 {
72 ACHECK(inited_);
73 return type_refined_by_ref_;
74 }

◆ TypeRefinedByTemplate()

const std::vector< base::ObjectSubType > & apollo::perception::camera::ObjectTemplateManager::TypeRefinedByTemplate ( )
inline

在文件 object_template_manager.h67 行定义.

67 {
68 ACHECK(inited_);
69 return type_refined_by_template_;
70 }

◆ TypeSpeedLimit()

const std::map< base::ObjectSubType, float > & apollo::perception::camera::ObjectTemplateManager::TypeSpeedLimit ( )
inline

在文件 object_template_manager.h63 行定义.

63 {
64 ACHECK(inited_);
65 return type_speed_limit_;
66 }

◆ VehHwl()

const std::vector< float > & apollo::perception::camera::ObjectTemplateManager::VehHwl ( )
inline

在文件 object_template_manager.h55 行定义.

55 {
56 ACHECK(inited_);
57 return veh_hwl_;
58 }

◆ VehObjHwlBySearchTemplates()

float apollo::perception::camera::ObjectTemplateManager::VehObjHwlBySearchTemplates ( float *  hwl,
int *  index = nullptr,
bool *  is_flip = nullptr 
)

在文件 object_template_manager.cc244 行定义.

245 {
246 ACHECK(inited_);
247 ACHECK(hwl != nullptr);
248
249 float hwl_flip[3] = {hwl[0], hwl[2], hwl[1]};
250 float score_best = -std::numeric_limits<float>::max();
251 int i_best = -1;
252 int i3 = 0;
253 bool from_flip = false;
254 for (int i = 0; i < total_nr_tmplts_veh_; ++i) {
255 float score = Get3dDimensionSimilarity(hwl, &veh_hwl_[i3]);
256 float score_flip = Get3dDimensionSimilarity(hwl_flip, &veh_hwl_[i3]);
257 bool from_flip_cur = false;
258 if (score_flip > score) {
259 score = score_flip;
260 from_flip_cur = true;
261 }
262 if (score > score_best) {
263 score_best = score;
264 i_best = i;
265 from_flip = from_flip_cur;
266 }
267 i3 += 3;
268 }
269 int i_best_by_3 = i_best * 3;
270 float hwl_tmplt_matched[3] = {veh_hwl_[i_best_by_3],
271 veh_hwl_[i_best_by_3 + 1],
272 veh_hwl_[i_best_by_3 + 2]};
273 if (from_flip) {
274 std::swap(hwl_tmplt_matched[1], hwl_tmplt_matched[2]);
275 }
276
277 float dh = fabsf(hwl[0] - hwl_tmplt_matched[0]);
278 float dh_ratio = dh / hwl_tmplt_matched[0];
279 float dw = fabsf(hwl[1] - hwl_tmplt_matched[1]);
280 float dw_ratio = dw / hwl_tmplt_matched[1];
281 float dl = fabsf(hwl[2] - hwl_tmplt_matched[2]);
282 float dl_ratio = dl / hwl_tmplt_matched[2];
283 float dh_dw_dl_ratio_mean = (dh_ratio + dw_ratio + dl_ratio) / 3;
284 float dh_ratio_check = std::min(dh_ratio, dh_dw_dl_ratio_mean);
285 if (score_best < kFloatEpsilon || dh_ratio_check > max_dim_change_ratio_) {
286 return -1.0f;
287 }
288 ADEBUG << dh_ratio << ", " << dw_ratio << ", " << dl_ratio;
289
290 hwl[0] = veh_hwl_[i_best_by_3];
291 hwl[1] = veh_hwl_[i_best_by_3 + 1];
292 hwl[2] = veh_hwl_[i_best_by_3 + 2];
293 if (index != nullptr) {
294 *index = i_best;
295 }
296 if (is_flip != nullptr) {
297 *is_flip = from_flip;
298 }
299 return score_best;
300}
#define ADEBUG
Definition log.h:41

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