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

#include <obj_mapper.h>

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

Public 成员函数

 ObjMapper ()
 
 ~ObjMapper ()=default
 
void set_default_variance ()
 Set the default variance object
 
void Init (const float *k_mat, int width, int height)
 Init for ObjectTemplateManager
 
void resize_ry_score (int size)
 Split the ry_score_ accoring to the specified nr_bins_ry.
 
std::vector< float > get_ry_score ()
 Get the ry score object
 
std::vector< float > get_ry_score (float ry)
 Get the ry score object
 
Eigen::Vector3d get_orientation_var ()
 Get the orientation var object
 
Eigen::Matrix3d get_position_uncertainty ()
 Get the position uncertainty object
 
bool Solve3dBbox (const ObjMapperOptions &options, float center[3], float hwl[3], float *ry)
 Calculate 3d result
 

Protected 属性

ObjectTemplateManagerobject_template_manager_ = nullptr
 

详细描述

在文件 obj_mapper.h68 行定义.

构造及析构函数说明

◆ ObjMapper()

apollo::perception::camera::ObjMapper::ObjMapper ( )
inline

在文件 obj_mapper.h70 行定义.

70 : width_(0), height_(0) {
71 memset(k_mat_, 0, sizeof(float) * 9);
74 }
void set_default_variance()
Set the default variance object
Definition obj_mapper.h:81
void resize_ry_score(int size)
Split the ry_score_ accoring to the specified nr_bins_ry.
Definition obj_mapper.h:104

◆ ~ObjMapper()

apollo::perception::camera::ObjMapper::~ObjMapper ( )
default

成员函数说明

◆ get_orientation_var()

Eigen::Vector3d apollo::perception::camera::ObjMapper::get_orientation_var ( )
inline

Get the orientation var object

返回
Eigen::Vector3d

在文件 obj_mapper.h126 行定义.

126{ return orientation_variance_; }

◆ get_position_uncertainty()

Eigen::Matrix3d apollo::perception::camera::ObjMapper::get_position_uncertainty ( )
inline

Get the position uncertainty object

返回
Eigen::Matrix3d

在文件 obj_mapper.h132 行定义.

132{ return position_uncertainty_; }

◆ get_ry_score() [1/2]

std::vector< float > apollo::perception::camera::ObjMapper::get_ry_score ( )
inline

Get the ry score object

返回
std::vector<float>

在文件 obj_mapper.h110 行定义.

110{ return ry_score_; }

◆ get_ry_score() [2/2]

std::vector< float > apollo::perception::camera::ObjMapper::get_ry_score ( float  ry)
inline

Get the ry score object

参数
ry
返回
std::vector<float>

在文件 obj_mapper.h117 行定义.

117 {
118 FillRyScoreSingleBin(ry);
119 return ry_score_;
120 }

◆ Init()

void apollo::perception::camera::ObjMapper::Init ( const float *  k_mat,
int  width,
int  height 
)
inline

Init for ObjectTemplateManager

参数
k_matK matrix
widthwidth of image
heightheight of image

在文件 obj_mapper.h93 行定义.

93 {
94 memcpy(k_mat_, k_mat, sizeof(float) * 9);
95 width_ = width;
96 height_ = height;
97 object_template_manager_ = ObjectTemplateManager::Instance();
98 }
ObjectTemplateManager * object_template_manager_
Definition obj_mapper.h:296
uint32_t height
Height of point cloud
uint32_t width
Width of point cloud

◆ resize_ry_score()

void apollo::perception::camera::ObjMapper::resize_ry_score ( int  size)
inline

Split the ry_score_ accoring to the specified nr_bins_ry.

参数
size

在文件 obj_mapper.h104 行定义.

104{ ry_score_.resize(size); }

◆ set_default_variance()

void apollo::perception::camera::ObjMapper::set_default_variance ( )
inline

Set the default variance object

在文件 obj_mapper.h81 行定义.

81 {
82 orientation_variance_(0) = 1.0f;
83 orientation_variance_(1) = orientation_variance_(2) = 0.0f;
84 position_uncertainty_ << 1, 0, 0, 0, 0, 0, 0, 0, 1;
85 }

◆ Solve3dBbox()

bool apollo::perception::camera::ObjMapper::Solve3dBbox ( const ObjMapperOptions options,
float  center[3],
float  hwl[3],
float *  ry 
)

Calculate 3d result

参数
optionsoptions contains hyper parameters
center3d center of the object
hwl3d w h l of the object
ryrotation y of the object
返回
true
false

在文件 obj_mapper.cc126 行定义.

127 {
128 // set default value for variance
130 float var_yaw = 0.0f;
131 float var_z = 0.0f;
132
133 // get input from options
134 memcpy(hwl, options.hwl, sizeof(float) * 3);
135 float bbox[4] = {0};
136 memcpy(bbox, options.bbox, sizeof(float) * 4);
137 *ry = options.ry;
138 bool check_dimension = options.check_dimension;
139 int type_min_vol_index = options.type_min_vol_index;
140
141 // check input hwl insanity
142 if (options.is_veh && check_dimension) {
143 assert(type_min_vol_index >= 0);
144 const std::vector<float> &kVehHwl = object_template_manager_->VehHwl();
145 const float *tmplt_with_min_vol = &kVehHwl[type_min_vol_index];
146 float min_tmplt_vol =
147 tmplt_with_min_vol[0] * tmplt_with_min_vol[1] * tmplt_with_min_vol[2];
148 float shrink_ratio_vol = algorithm::ISqr(sqrtf(params_.iou_high));
149 shrink_ratio_vol *= shrink_ratio_vol;
150 // float shrink_ratio_vol = sqrt(params_.iou_high);
151 if (hwl[0] < params_.abnormal_h_veh ||
152 hwl[0] * hwl[1] * hwl[2] < min_tmplt_vol * shrink_ratio_vol) {
153 memcpy(hwl, tmplt_with_min_vol, sizeof(float) * 3);
154 } else {
155 float hwl_tmplt[3] = {hwl[0], hwl[1], hwl[2]};
156 int tmplt_index = -1;
158 hwl_tmplt, &tmplt_index);
159 float thres_min_score = shrink_ratio_vol;
160
161 const int kNrDimPerTmplt = object_template_manager_->NrDimPerTmplt();
162 bool search_success = score > thres_min_score;
163 bool is_same_type = (type_min_vol_index / kNrDimPerTmplt) == tmplt_index;
164 const std::map<TemplateIndex, int> &kLookUpTableMinVolumeIndex =
166 bool is_car_pred =
167 type_min_vol_index ==
168 kLookUpTableMinVolumeIndex.at(TemplateIndex::CAR_MIN_VOLUME_INDEX);
169
170 bool hwl_is_reliable = search_success && is_same_type;
171 if (hwl_is_reliable) {
172 memcpy(hwl, hwl_tmplt, sizeof(float) * 3);
173 } else if (is_car_pred) {
174 const float *tmplt_with_median_vol =
175 tmplt_with_min_vol + kNrDimPerTmplt;
176 memcpy(hwl, tmplt_with_median_vol, sizeof(float) * 3);
177 }
178 }
179 }
180
181 // call 3d solver
182 bool success =
183 Solve3dBboxGivenOneFullBboxDimensionOrientation(bbox, hwl, ry, center);
184
185 // calculate variance for yaw & z
186 float yaw_score_mean =
187 algorithm::IMean(ry_score_.data(), static_cast<int>(ry_score_.size()));
188 float yaw_score_sdv = algorithm::ISdv(ry_score_.data(), yaw_score_mean,
189 static_cast<int>(ry_score_.size()));
190 var_yaw =
191 algorithm::ISqrt(algorithm::IRec(yaw_score_sdv + params_.eps_mapper));
192
193 float z = center[2];
194 float rz = z * params_.rz_ratio;
195 float nr_bins_z = static_cast<float>(params_.nr_bins_z);
196 std::vector<float> buffer(static_cast<size_t>(2 * nr_bins_z), 0);
197 float *score_z = buffer.data();
198 float dz = 2 * rz / nr_bins_z;
199 float z_start = std::max(z - rz, params_.depth_min);
200 float z_end = z + rz;
201 int count_z_test = 0;
202 for (float z_test = z_start; z_test <= z_end; z_test += dz) {
203 float center_test[3] = {center[0], center[1], center[2]};
204 float sf = z_test * algorithm::IRec(center_test[2]);
205 algorithm::IScale3(center_test, sf);
206 float score_test = GetProjectionScore(*ry, bbox, hwl, center_test);
207 score_z[count_z_test++] = score_test;
208 }
209 float z_score_mean = algorithm::IMean(score_z, count_z_test);
210 float z_score_sdv = algorithm::ISdv(score_z, z_score_mean, count_z_test);
211 var_z = algorithm::ISqr(algorithm::IRec(z_score_sdv + params_.eps_mapper));
212
213 // fill the position_uncertainty_ and orientation_variance_
214 orientation_variance_(0) = var_yaw;
215 float bbox_cx = (bbox[0] + bbox[2]) / 2;
216 float focal = (k_mat_[0] + k_mat_[4]) / 2;
217 float sf_z_to_x = fabsf(bbox_cx - k_mat_[2]) * algorithm::IRec(focal);
218 float var_x = var_z * algorithm::ISqr(sf_z_to_x);
219 float var_xz = sf_z_to_x * var_z;
220 position_uncertainty_(0, 0) = var_x;
221 position_uncertainty_(2, 2) = var_z;
222 position_uncertainty_(0, 2) = position_uncertainty_(2, 0) = var_xz;
223 return success;
224}
const std::map< TemplateIndex, int > & LookUpTableMinVolumeIndex()
float VehObjHwlBySearchTemplates(float *hwl, int *index=nullptr, bool *is_flip=nullptr)
T IMean(const T *x, int n)
Definition i_blas.h:2434
T ISdv(const T *x, T mean, int n)
Definition i_blas.h:2500
void IScale3(T x[3], T sf)
Definition i_blas.h:1868

类成员变量说明

◆ object_template_manager_

ObjectTemplateManager* apollo::perception::camera::ObjMapper::object_template_manager_ = nullptr
protected

在文件 obj_mapper.h296 行定义.


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