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

Method from_json

src/PLPSLAM/data/map_database.cc:181–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 }
180
181 void map_database::from_json(camera_database *cam_db, bow_vocabulary *bow_vocab, bow_database *bow_db,
182 const nlohmann::json &json_keyfrms, const nlohmann::json &json_landmarks)
183 {
184 std::lock_guard<std::mutex> lock(mtx_map_access_);
185
186 // Step 1. delete all the data in map database
187 for (auto &lm : landmarks_)
188 {
189 delete lm.second;
190 lm.second = nullptr;
191 }
192
193 for (auto &keyfrm : keyframes_)
194 {
195 delete keyfrm.second;
196 keyfrm.second = nullptr;
197 }
198
199 landmarks_.clear();
200 keyframes_.clear();
201 max_keyfrm_id_ = 0;
202 local_landmarks_.clear();
203 origin_keyfrm_ = nullptr;
204
205 // Step 2. Register keyframes
206 // If the object does not exist at this step, the corresponding pointer is set as nullptr.
207 spdlog::info("decoding {} keyframes to load", json_keyfrms.size());
208 for (const auto &json_id_keyfrm : json_keyfrms.items())
209 {
210 const auto id = std::stoi(json_id_keyfrm.key());
211 assert(0 <= id);
212 const auto json_keyfrm = json_id_keyfrm.value();
213
214 register_keyframe(cam_db, bow_vocab, bow_db, id, json_keyfrm);
215 }
216
217 // Step 3. Register 3D landmark point
218 // If the object does not exist at this step, the corresponding pointer is set as nullptr.
219 spdlog::info("decoding {} landmarks to load", json_landmarks.size());
220 for (const auto &json_id_landmark : json_landmarks.items())
221 {
222 const auto id = std::stoi(json_id_landmark.key());
223 assert(0 <= id);
224 const auto json_landmark = json_id_landmark.value();
225
226 register_landmark(id, json_landmark);
227 }
228
229 // Step 4. Register graph information
230 spdlog::info("registering essential graph");
231 for (const auto &json_id_keyfrm : json_keyfrms.items())
232 {
233 const auto id = std::stoi(json_id_keyfrm.key());
234 assert(0 <= id);
235 const auto json_keyfrm = json_id_keyfrm.value();
236
237 register_graph(id, json_keyfrm);
238 }

Callers 1

load_message_packMethod · 0.45

Calls 11

infoFunction · 0.85
update_connectionsMethod · 0.80
update_informationMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45
countMethod · 0.45
compute_descriptorMethod · 0.45

Tested by

no test coverage detected