71 memset(k_mat_, 0,
sizeof(
float) * 9);
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;
93 void Init(
const float *k_mat,
int width,
int height) {
94 memcpy(k_mat_, k_mat,
sizeof(
float) * 9);
118 FillRyScoreSingleBin(ry);
146 float hwl[3],
float *ry);
162 bool Solve3dBboxGivenOneFullBboxDimensionOrientation(
const float *bbox,
178 bool SolveCenterFromNearestVerticalEdge(
const float *bbox,
const float *hwl,
179 float ry,
float *center,
180 float *center_2d)
const;
182 void UpdateCenterViaBackProjectZ(
const float *bbox,
const float *hwl,
183 const float *center_2d,
184 float *center)
const {
187 center[1] += hwl[0] / 2;
200 float GetProjectionScore(
float ry,
const float *bbox,
const float *hwl,
201 const float *center,
bool check_truncation =
false,
202 float *bbox_res =
nullptr)
const {
205 float *bbox_near =
nullptr;
207 &k_mat_[0], width_, height_, bbox, rot, hwl, center, check_truncation,
208 bbox_res, bbox_near);
223 void PostRefineZ(
const float *bbox,
const float *hwl,
const float *center2d,
224 float ry,
float *center,
float dz = 0.2f,
float rz = 1.0f,
225 bool fix_proj =
true)
const {
227 float score_best = 0.0f;
228 float x[2] = {center2d[0], center2d[1]};
229 float center_best[3] = {center[0], center[1], center[2]};
230 for (
float offset = -rz; offset <= rz; offset += dz) {
231 float z_test = std::max(z + offset, params_.
depth_min);
232 float center_test[3] = {center[0], center[1], z_test};
235 center_test[1] += hwl[0] / 2;
237 float score_test = GetProjectionScore(ry, bbox, hwl, center_test);
238 if (score_best < score_test) {
239 score_best = score_test;
240 memcpy(center_best, center_test,
sizeof(
float) * 3);
243 memcpy(center, center_best,
sizeof(
float) * 3);
253 void PostRefineOrientation(
const float *bbox,
const float *hwl,
254 const float *center,
float *ry);
265 void GetCenter(
const float *bbox,
const float &z_ref,
const float &ry,
266 const float *hwl,
float *center,
float *x)
const;
272 void FillRyScoreSingleBin(
const float &ry) {
273 int nr_bins_ry =
static_cast<int>(ry_score_.size());
274 memset(ry_score_.data(), 0,
sizeof(
float) * nr_bins_ry);
275 const float PI = algorithm::Constant<float>::PI();
276 int index =
static_cast<int>(
277 std::floor((ry +
PI) *
static_cast<float>(nr_bins_ry) / (2.0f *
PI)));
278 ry_score_[index % nr_bins_ry] = 1.0f;
283 float k_mat_[9] = {0};
286 std::vector<float> ry_score_ = {};
287 ObjMapperParams params_;
290 Eigen::Vector3d orientation_variance_;
293 Eigen::Matrix3d position_uncertainty_;
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)