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

Function rgbd_tracking

example/run_tum_rgbd_slam.cc:185–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185void rgbd_tracking(const std::shared_ptr<PLPSLAM::config> &cfg,
186 const std::string &vocab_file_path,
187 const std::string &sequence_dir_path,
188 const unsigned int frame_skip,
189 const bool no_sleep,
190 const bool auto_term,
191 const bool eval_log,
192 const std::string &map_db_path)
193{
194 tum_rgbd_sequence sequence(sequence_dir_path);
195 const auto frames = sequence.get_frames();
196
197 // build a SLAM system
198 PLPSLAM::system SLAM(cfg, vocab_file_path);
199 // startup the SLAM process
200 SLAM.startup();
201
202 // create a viewer object
203 // and pass the frame_publisher and the map_publisher
204#ifdef USE_PANGOLIN_VIEWER
205 pangolin_viewer::viewer viewer(cfg, &SLAM, SLAM.get_frame_publisher(), SLAM.get_map_publisher());
206#elif USE_SOCKET_PUBLISHER
207 socket_publisher::publisher publisher(cfg, &SLAM, SLAM.get_frame_publisher(), SLAM.get_map_publisher());
208#endif
209
210 std::vector<double> track_times;
211 track_times.reserve(frames.size());
212
213 // run the SLAM in another thread
214 std::thread thread([&]()
215 {
216 for (unsigned int i = 0; i < frames.size(); ++i)
217 {
218 const auto &frame = frames.at(i);
219 const auto rgb_img = cv::imread(frame.rgb_img_path_, cv::IMREAD_UNCHANGED);
220 const auto depth_img = cv::imread(frame.depth_img_path_, cv::IMREAD_UNCHANGED);
221
222 const auto tp_1 = std::chrono::steady_clock::now();
223
224 if (!rgb_img.empty() && !depth_img.empty() && (i % frame_skip == 0))
225 {
226 // input the current frame and estimate the camera pose
227 SLAM.feed_RGBD_frame(rgb_img, depth_img, frame.timestamp_);
228 }
229
230 const auto tp_2 = std::chrono::steady_clock::now();
231
232 const auto track_time = std::chrono::duration_cast<std::chrono::duration<double>>(tp_2 - tp_1).count();
233 if (i % frame_skip == 0)
234 {
235 track_times.push_back(track_time);
236 }
237
238 // wait until the timestamp of the next frame
239 if (!no_sleep && i < frames.size() - 1)
240 {
241 const auto wait_time = frames.at(i + 1).timestamp_ - (frame.timestamp_ + track_time);
242 if (0.0 < wait_time)

Callers 1

mainFunction · 0.70

Calls 15

startupMethod · 0.80
get_frame_publisherMethod · 0.80
get_map_publisherMethod · 0.80
feed_RGBD_frameMethod · 0.80
closeMethod · 0.80
save_map_databaseMethod · 0.80
get_framesMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
countMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected