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

Method validate_candidates

src/PLPSLAM/module/loop_detector.cc:129–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127 }
128
129 bool loop_detector::validate_candidates()
130 {
131 // disallow the removal of the candidates
132 for (const auto candidate : loop_candidates_to_validate_)
133 {
134 candidate->set_not_to_be_erased();
135 }
136
137 // [1] for each of the candidates, estimate and validate the Sim3 between it and the current keyframe using the observed landmarks
138 // then, select ONE candidate
139
140 const bool candidate_is_found = select_loop_candidate_via_Sim3(loop_candidates_to_validate_, selected_candidate_,
141 g2o_Sim3_world_to_curr_, curr_match_lms_observed_in_cand_);
142
143 Sim3_world_to_curr_ = util::converter::to_eigen_mat(g2o_Sim3_world_to_curr_);
144
145 if (!candidate_is_found)
146 {
147 for (const auto loop_candidate : loop_candidates_to_validate_)
148 {
149 loop_candidate->set_to_be_erased();
150 }
151 return false;
152 }
153
154 spdlog::debug("detect loop candidate via Sim3 estimation: keyframe {} - keyframe {}", selected_candidate_->id_, cur_keyfrm_->id_);
155
156 // [2] reproject the landmarks observed in covisibilities of the selected candidate to the current keyframe,
157 // then acquire the extra 2D-3D matches
158
159 // matches between the keypoints in the current and the landmarks observed in the covisibilities of the selected candidate
160 curr_match_lms_observed_in_cand_covis_.clear();
161
162 auto cand_covisibilities = selected_candidate_->graph_node_->get_covisibilities();
163 cand_covisibilities.push_back(selected_candidate_);
164
165 // acquire all of the landmarks observed in the covisibilities of the candidate
166 // check the already inserted landmarks
167 std::unordered_set<data::landmark *> already_inserted;
168 for (const auto covisibility : cand_covisibilities)
169 {
170 const auto lms_in_covisibility = covisibility->get_landmarks();
171 for (const auto lm : lms_in_covisibility)
172 {
173 if (!lm)
174 {
175 continue;
176 }
177 if (lm->will_be_erased())
178 {
179 continue;
180 }
181
182 if (already_inserted.count(lm))
183 {
184 continue;
185 }
186 curr_match_lms_observed_in_cand_covis_.push_back(lm);

Callers 1

runMethod · 0.80

Calls 11

debugFunction · 0.85
set_not_to_be_erasedMethod · 0.80
set_to_be_erasedMethod · 0.80
get_covisibilitiesMethod · 0.80
clearMethod · 0.45
push_backMethod · 0.45
get_landmarksMethod · 0.45
will_be_erasedMethod · 0.45
countMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected