| 200 | } |
| 201 | |
| 202 | void rgbd_tracking(const std::shared_ptr<PLPSLAM::config> &cfg, |
| 203 | const std::string &vocab_file_path, |
| 204 | const std::string &sequence_dir_path, |
| 205 | const unsigned int frame_skip, |
| 206 | const bool no_sleep, |
| 207 | const bool auto_term, |
| 208 | const bool eval_log, |
| 209 | const std::string &map_db_path) |
| 210 | { |
| 211 | // FW: false means: for now we don't have CNN-predicted depth image |
| 212 | ImageSequence_withPlaneSeg sequence(sequence_dir_path, false); |
| 213 | const auto frames = sequence.get_frames(); |
| 214 | |
| 215 | // build a SLAM system |
| 216 | // FW: true means: we have segmentation mask -> _b_seg_or_not = true |
| 217 | PLPSLAM::system SLAM(cfg, vocab_file_path, true); |
| 218 | // startup the SLAM process |
| 219 | SLAM.startup(); |
| 220 | |
| 221 | // create a viewer object |
| 222 | // and pass the frame_publisher and the map_publisher |
| 223 | #ifdef USE_PANGOLIN_VIEWER |
| 224 | pangolin_viewer::viewer viewer(cfg, &SLAM, SLAM.get_frame_publisher(), SLAM.get_map_publisher()); |
| 225 | #elif USE_SOCKET_PUBLISHER |
| 226 | socket_publisher::publisher publisher(cfg, &SLAM, SLAM.get_frame_publisher(), SLAM.get_map_publisher()); |
| 227 | #endif |
| 228 | |
| 229 | std::vector<double> track_times; |
| 230 | track_times.reserve(frames.size()); |
| 231 | |
| 232 | // run the SLAM in another thread |
| 233 | std::thread thread([&]() |
| 234 | { |
| 235 | for (unsigned int i = 0; i < frames.size(); ++i) |
| 236 | { |
| 237 | const auto &frame = frames.at(i); |
| 238 | const auto rgb_img = cv::imread(frame.rgb_img_path_, cv::IMREAD_UNCHANGED); |
| 239 | const auto depth_img = cv::imread(frame.depth_img_path_, cv::IMREAD_UNCHANGED); |
| 240 | |
| 241 | // FW: read segmentation mask |
| 242 | const auto seg_mask_img = cv::imread(frame.mask_img_path_, cv::IMREAD_UNCHANGED); |
| 243 | assert(rgb_img.rows == seg_mask_img.rows); |
| 244 | assert(rgb_img.cols == seg_mask_img.cols); |
| 245 | |
| 246 | const auto tp_1 = std::chrono::steady_clock::now(); |
| 247 | |
| 248 | if (!rgb_img.empty() && !depth_img.empty() && (i % frame_skip == 0)) |
| 249 | { |
| 250 | // input the current frame and estimate the camera pose |
| 251 | SLAM.feed_RGBD_frame(rgb_img, depth_img, seg_mask_img, frame.timestamp_); |
| 252 | } |
| 253 | |
| 254 | const auto tp_2 = std::chrono::steady_clock::now(); |
| 255 | |
| 256 | const auto track_time = std::chrono::duration_cast<std::chrono::duration<double>>(tp_2 - tp_1).count(); |
| 257 | if (i % frame_skip == 0) |
| 258 | { |
| 259 | track_times.push_back(track_time); |
no test coverage detected