MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / update_normal_and_depth

Method update_normal_and_depth

src/PLPSLAM/data/landmark.cc:249–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247 }
248
249 void landmark::update_normal_and_depth()
250 {
251 std::map<keyframe *, unsigned int> observations;
252 keyframe *ref_keyfrm;
253 Vec3_t pos_w;
254 {
255 std::lock_guard<std::mutex> lock1(mtx_observations_);
256 std::lock_guard<std::mutex> lock2(mtx_position_);
257 if (will_be_erased_)
258 {
259 return;
260 }
261 observations = observations_;
262 ref_keyfrm = ref_keyfrm_;
263 pos_w = pos_w_;
264 }
265
266 if (observations.empty())
267 {
268 return;
269 }
270
271 // FW: calculate the average viewing direction for this map point
272 Vec3_t mean_normal = Vec3_t::Zero();
273 unsigned int num_observations = 0;
274 for (const auto &observation : observations)
275 {
276 auto keyfrm = observation.first;
277 const Vec3_t cam_center = keyfrm->get_cam_center();
278 const Vec3_t normal = pos_w_ - cam_center;
279 mean_normal = mean_normal + normal.normalized();
280 ++num_observations;
281 }
282
283 const Vec3_t cam_to_lm_vec = pos_w - ref_keyfrm->get_cam_center();
284 const auto dist = cam_to_lm_vec.norm();
285 const auto scale_level = ref_keyfrm->undist_keypts_.at(observations.at(ref_keyfrm)).octave; // which level of image pyramid the keypoint is extracted
286 const auto scale_factor = ref_keyfrm->scale_factors_.at(scale_level); // the scale factor = pow(1.2, scale_level) corresponding to the level of image pyramid
287 const auto num_scale_levels = ref_keyfrm->num_scale_levels_; // = 8
288
289 {
290 std::lock_guard<std::mutex> lock3(mtx_position_);
291 max_valid_dist_ = dist * scale_factor;
292 min_valid_dist_ = max_valid_dist_ / ref_keyfrm->scale_factors_.at(num_scale_levels - 1);
293 mean_normal_ = mean_normal.normalized();
294 }
295 }
296
297 float landmark::get_min_valid_distance() const
298 {

Callers 14

store_new_keyframeMethod · 0.80
update_new_keyframeMethod · 0.80
optimizeMethod · 0.80
optimizeMethod · 0.80
optimizeMethod · 0.80
optimizeMethod · 0.80
optimizeMethod · 0.80
insert_new_keyframeMethod · 0.80
create_map_for_stereoMethod · 0.80

Calls 3

normalizedMethod · 0.80
emptyMethod · 0.45
get_cam_centerMethod · 0.45

Tested by

no test coverage detected