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

Method triangulate_with_two_keyframes

src/PLPSLAM/mapping_module.cc:420–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418 }
419
420 void mapping_module::triangulate_with_two_keyframes(data::keyframe *cur_keyfrm, data::keyframe *ngh_keyfrm)
421 {
422 // lowe's_ratio will not be used
423 match::robust robust_matcher(0.0, false);
424 // estimate matches between the current and neighbor keyframes,
425 // then reject outliers using Essential matrix computed from the two camera poses
426
427 // (cur bearing) * E_ngh_to_cur * (ngh bearing) = 0
428 // const Mat33_t E_ngh_to_cur = solve::essential_solver::create_E_21(ngh_keyfrm, cur_keyfrm_);
429 const Mat33_t E_ngh_to_cur = solve::essential_solver::create_E_21(ngh_keyfrm->get_rotation(), ngh_keyfrm->get_translation(),
430 cur_keyfrm->get_rotation(), cur_keyfrm->get_translation());
431
432 // vector of matches (idx in the current, idx in the neighbor)
433 std::vector<std::pair<unsigned int, unsigned int>> matches;
434 robust_matcher.match_for_triangulation(cur_keyfrm, ngh_keyfrm, E_ngh_to_cur, matches);
435
436 // FW: initialize the two view triangulator -> pass the keyframe pointer to that object, with poses information
437 const module::two_view_triangulator triangulator(cur_keyfrm, ngh_keyfrm, 1.0);
438
439#ifdef USE_OPENMP
440#pragma omp parallel for
441#endif
442 for (unsigned int i = 0; i < matches.size(); ++i)
443 {
444 const auto idx_1 = matches.at(i).first;
445 const auto idx_2 = matches.at(i).second;
446
447 // triangulate between idx_1 and idx_2
448 Vec3_t pos_w;
449
450 // FW: triangulation + check positive depth + check reprojection error + check scale consistency
451 if (!triangulator.triangulate(idx_1, idx_2, pos_w))
452 {
453 // failed
454 continue;
455 }
456 // succeeded
457
458 // create a landmark object
459 auto lm = new data::landmark(pos_w, cur_keyfrm, map_db_);
460
461 lm->add_observation(cur_keyfrm, idx_1);
462 lm->add_observation(ngh_keyfrm, idx_2);
463
464 cur_keyfrm->add_landmark(lm, idx_1);
465 ngh_keyfrm->add_landmark(lm, idx_2);
466
467 lm->compute_descriptor();
468 lm->update_normal_and_depth();
469
470 map_db_->add_landmark(lm);
471 // wait for redundancy check
472#ifdef USE_OPENMP
473#pragma omp critical
474#endif
475 {
476 local_map_cleaner_->add_fresh_landmark(lm);
477 }

Callers

nothing calls this directly

Calls 10

get_rotationMethod · 0.80
get_translationMethod · 0.80
add_fresh_landmarkMethod · 0.80
sizeMethod · 0.45
triangulateMethod · 0.45
add_observationMethod · 0.45
add_landmarkMethod · 0.45
compute_descriptorMethod · 0.45

Tested by

no test coverage detected