22 #include "cyber/common/log.h" 27 namespace perception {
69 memset(k_mat_, 0,
sizeof(
float) * 9);
70 resize_ry_score(params_.nr_bins_ry);
71 set_default_variance();
77 orientation_variance_(0) = 1.0f;
78 orientation_variance_(1) = orientation_variance_(2) = 0.0f;
79 position_uncertainty_ << 1, 0, 0, 0, 0, 0, 0, 0, 1;
82 void Init(
const float *k_mat,
int width,
int height) {
83 memcpy(k_mat_, k_mat,
sizeof(
float) * 9);
86 object_template_manager_ = ObjectTemplateManager::Instance();
94 FillRyScoreSingleBin(ry);
104 float hwl[3],
float *
ry);
107 bool Solve3dBboxGivenOneFullBboxDimensionOrientation(
const float *
bbox,
112 bool SolveCenterFromNearestVerticalEdge(
const float *bbox,
const float *hwl,
113 float ry,
float *center,
114 float *center_2d)
const;
116 void UpdateCenterViaBackProjectZ(
const float *bbox,
const float *hwl,
117 const float *center_2d,
118 float *center)
const {
121 center[1] += hwl[0] / 2;
124 float GetProjectionScore(
float ry,
const float *bbox,
const float *hwl,
125 const float *center,
bool check_truncation =
false,
126 float *bbox_res =
nullptr)
const {
129 float *bbox_near =
nullptr;
131 &k_mat_[0], width_, height_, bbox, rot, hwl, center, check_truncation,
132 bbox_res, bbox_near);
136 void PostRefineZ(
const float *bbox,
const float *hwl,
const float *center2d,
137 float ry,
float *center,
float dz = 0.2f,
float rz = 1.0f,
138 bool fix_proj =
true)
const {
140 float score_best = 0.0f;
141 float x[2] = {center2d[0], center2d[1]};
142 float center_best[3] = {center[0], center[1], center[2]};
143 for (
float offset = -rz; offset <= rz; offset += dz) {
144 float z_test = std::max(z + offset, params_.depth_min);
145 float center_test[3] = {center[0], center[1], z_test};
148 center_test[1] += hwl[0] / 2;
150 float score_test = GetProjectionScore(ry, bbox, hwl, center_test);
151 if (score_best < score_test) {
152 score_best = score_test;
153 memcpy(center_best, center_test,
sizeof(
float) * 3);
156 memcpy(center, center_best,
sizeof(
float) * 3);
159 void PostRefineOrientation(
const float *bbox,
const float *hwl,
160 const float *center,
float *ry);
162 void GetCenter(
const float *bbox,
const float &z_ref,
const float &ry,
163 const float *hwl,
float *center,
166 void FillRyScoreSingleBin(
const float &ry) {
167 int nr_bins_ry =
static_cast<int>(ry_score_.size());
168 memset(ry_score_.data(), 0,
sizeof(float) * nr_bins_ry);
170 int index =
static_cast<int>(
171 std::floor((ry + PI) * static_cast<float>(nr_bins_ry) / (2.0f * PI)));
172 ry_score_[index % nr_bins_ry] = 1.0f;
177 float k_mat_[9] = {0};
180 std::vector<float> ry_score_ = {};
184 Eigen::Vector3d orientation_variance_;
187 Eigen::Matrix3d position_uncertainty_;
float iou_suc
Definition: obj_mapper.h:61
Definition: obj_mapper.h:66
float occ_ratio
Definition: obj_mapper.h:57
float eps_mapper
Definition: obj_mapper.h:60
std::vector< float > get_ry_score()
Definition: obj_mapper.h:91
float dist_far
Definition: obj_mapper.h:59
const double PI
Definition: types.h:22
float reproj_err
Definition: obj_mapper.h:53
float bbox[4]
Definition: obj_mapper.h:32
float angle_resolution_degree
Definition: obj_mapper.h:63
Eigen::Vector3d get_orientation_var()
Definition: obj_mapper.h:98
int boundary_len
Definition: obj_mapper.h:47
float iou_high
Definition: obj_mapper.h:62
Definition: obj_mapper.h:30
int type_min_vol_index
Definition: obj_mapper.h:36
float depth_min
Definition: obj_mapper.h:58
bool check_dimension
Definition: obj_mapper.h:35
void set_default_variance()
Definition: obj_mapper.h:76
float factor_small
Definition: obj_mapper.h:51
float small_bbox_height
Definition: obj_mapper.h:50
Definition: object_template_manager.h:49
void GenRotMatrix(const T &ry, T *rot)
Definition: twod_threed_util.h:101
float stable_w
Definition: obj_mapper.h:56
float rz_ratio
Definition: obj_mapper.h:54
void resize_ry_score(int size)
Definition: obj_mapper.h:89
float learning_r
Definition: obj_mapper.h:52
int nr_bins_z
Definition: obj_mapper.h:45
~ObjMapper()
Definition: obj_mapper.h:74
int max_nr_iter
Definition: obj_mapper.h:48
ObjMapperParams()
Definition: obj_mapper.h:41
T GetScoreViaRotDimensionCenter(const T *k_mat, int width, int height, const T *bbox, const T *rot, const T *hwl, const T *location, const bool &check_truncation, T *bbox_res=nullptr, T *bbox_near=nullptr)
Definition: twod_threed_util.h:177
float abnormal_h_veh
Definition: obj_mapper.h:55
std::vector< float > get_ry_score(float ry)
Definition: obj_mapper.h:93
void Init(const float *k_mat, int width, int height)
Definition: obj_mapper.h:82
Definition: obj_mapper.h:40
float hwl[3]
Definition: obj_mapper.h:31
int nr_bins_ry
Definition: obj_mapper.h:46
bool is_veh
Definition: obj_mapper.h:34
ObjMapper()
Definition: obj_mapper.h:68
void IBackprojectCanonical(const T *x, const T *K, T depth, T *X)
Definition: i_util.h:164
float ry
Definition: obj_mapper.h:33
Eigen::Matrix3d get_position_uncertainty()
Definition: obj_mapper.h:100