127 {
128
130 float var_yaw = 0.0f;
131 float var_z = 0.0f;
132
133
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
142 if (options.is_veh && check_dimension) {
143 assert(type_min_vol_index >= 0);
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];
149 shrink_ratio_vol *= shrink_ratio_vol;
150
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
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 ==
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
182 bool success =
183 Solve3dBboxGivenOneFullBboxDimensionOrientation(bbox, hwl, ry, center);
184
185
186 float yaw_score_mean =
188 float yaw_score_sdv =
algorithm::ISdv(ry_score_.data(), yaw_score_mean,
189 static_cast<int>(ry_score_.size()));
190 var_yaw =
192
193 float z = center[2];
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]};
206 float score_test = GetProjectionScore(*ry, bbox, hwl, center_test);
207 score_z[count_z_test++] = score_test;
208 }
210 float z_score_sdv =
algorithm::ISdv(score_z, z_score_mean, count_z_test);
212
213
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;
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()
const int NrDimPerTmplt()
float VehObjHwlBySearchTemplates(float *hwl, int *index=nullptr, bool *is_flip=nullptr)
const std::vector< float > & VehHwl()
T IMean(const T *x, int n)
T ISdv(const T *x, T mean, int n)
void IScale3(T x[3], T sf)