Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter KeyframeInserter::min_distance #545

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/stella_vslam/module/keyframe_inserter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ namespace module {
keyframe_inserter::keyframe_inserter(const double max_interval,
const double min_interval,
const double max_distance,
const double min_distance,
const double lms_ratio_thr_almost_all_lms_are_tracked,
const double lms_ratio_thr_view_changed,
const unsigned int enough_lms_thr,
const bool wait_for_local_bundle_adjustment)
: max_interval_(max_interval),
min_interval_(min_interval),
max_distance_(max_distance),
min_distance_(min_distance),
lms_ratio_thr_almost_all_lms_are_tracked_(lms_ratio_thr_almost_all_lms_are_tracked),
lms_ratio_thr_view_changed_(lms_ratio_thr_view_changed),
enough_lms_thr_(enough_lms_thr),
Expand All @@ -29,6 +31,7 @@ keyframe_inserter::keyframe_inserter(const YAML::Node& yaml_node)
: keyframe_inserter(yaml_node["max_interval"].as<double>(1.0),
yaml_node["min_interval"].as<double>(0.1),
yaml_node["max_distance"].as<double>(-1.0),
yaml_node["min_distance"].as<double>(-1.0),
yaml_node["lms_ratio_thr_almost_all_lms_are_tracked"].as<double>(0.9),
yaml_node["lms_ratio_thr_view_changed"].as<double>(0.5),
yaml_node["enough_lms_thr"].as<unsigned int>(100),
Expand Down Expand Up @@ -77,6 +80,10 @@ bool keyframe_inserter::new_keyframe_is_needed(data::map_database* map_db,
if (max_distance_ > 0.0) {
max_distance_traveled = last_inserted_keyfrm && (last_inserted_keyfrm->get_trans_wc() - curr_frm.get_trans_wc()).norm() > max_distance_;
}
bool min_distance_traveled = true;
if (min_distance_ > 0.0) {
min_distance_traveled = !last_inserted_keyfrm || (last_inserted_keyfrm->get_trans_wc() - curr_frm.get_trans_wc()).norm() > min_distance_;
}
// New keyframe is needed if the field-of-view of the current frame is changed a lot
const bool view_changed = num_reliable_lms < num_reliable_lms_ref * lms_ratio_thr_view_changed_;
// const bool view_changed = num_tracked_lms < num_tracked_lms_on_ref_keyfrm * lms_ratio_thr_view_changed_;
Expand All @@ -100,7 +107,7 @@ bool keyframe_inserter::new_keyframe_is_needed(data::map_database* map_db,
SPDLOG_TRACE("keyframe_inserter: almost_all_lms_are_tracked={}", almost_all_lms_are_tracked);
SPDLOG_TRACE("keyframe_inserter: mapper_is_skipping_localBA={}", mapper_is_skipping_localBA);
return (max_interval_elapsed || max_distance_traveled || view_changed || not_enough_lms)
&& (!enough_keyfrms || min_interval_elapsed)
&& (!enough_keyfrms || (min_interval_elapsed && min_distance_traveled))
&& !tracking_is_unstable
&& !almost_all_lms_are_tracked
&& !mapper_is_skipping_localBA;
Expand Down
2 changes: 2 additions & 0 deletions src/stella_vslam/module/keyframe_inserter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class keyframe_inserter {
explicit keyframe_inserter(const double max_interval = 1.0,
const double min_interval = 0.1,
const double max_distance = -1.0,
const double min_distance = -1.0,
const double lms_ratio_thr_almost_all_lms_are_tracked = 0.9,
const double lms_ratio_thr_view_changed = 0.8,
const unsigned int enough_lms_thr = 100,
Expand Down Expand Up @@ -60,6 +61,7 @@ class keyframe_inserter {
const double max_interval_ = 1.0;
const double min_interval_ = 0.1;
const double max_distance_ = -1.0;
const double min_distance_ = -1.0;

//! Ratio-threshold of "the number of 3D points observed in the current frame" / "that of 3D points observed in the last keyframe"
const double lms_ratio_thr_almost_all_lms_are_tracked_ = 0.9;
Expand Down