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

Method ImageSequence_withPlaneSeg

example/util/planeSeg_util.cc:35–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#include <spdlog/spdlog.h>
34
35ImageSequence_withPlaneSeg::ImageSequence_withPlaneSeg(const std::string &seq_dir_path,
36 bool b_predicted_depth,
37 const double min_timediff_thr) : b_predicted_depth_(b_predicted_depth)
38{
39 // listing up the files in rgb/ and depth/ directories
40 const auto rgb_img_infos = acquire_image_information(seq_dir_path, seq_dir_path + "/rgb.txt");
41 const auto mask_img_infos = acquire_image_information(seq_dir_path, seq_dir_path + "/mask.txt"); // add plane seg_mask
42
43 // spdlog::info("data path: {}", seq_dir_path);
44
45 if (!b_predicted_depth_)
46 {
47 // !use depth from the dataset
48 const auto depth_img_infos = acquire_image_information(seq_dir_path, seq_dir_path + "/depth.txt");
49
50 // find the nearest depth frame for each of the RGB frames
51 for (const auto &rgb_img_info : rgb_img_infos)
52 {
53 // untie RGB frame information
54 const auto &rgb_img_timestamp = rgb_img_info.timestamp_;
55 const auto &rgb_img_file_path = rgb_img_info.img_file_path_;
56
57 // nearest depth frame information
58 auto nearest_depth_img_timestamp = depth_img_infos.begin()->timestamp_;
59 auto nearest_depth_img_file_path = depth_img_infos.begin()->img_file_path_;
60 double min_timediff = std::abs(rgb_img_timestamp - nearest_depth_img_timestamp);
61
62 // calc time diff and find the nearest depth frame
63 for (const auto &depth_img_info : depth_img_infos)
64 {
65 // untie RGB frame information
66 const auto &depth_img_timestamp = depth_img_info.timestamp_;
67 const auto &depth_img_file_path = depth_img_info.img_file_path_;
68 // calc time diff
69 const auto timediff = std::abs(rgb_img_timestamp - depth_img_timestamp);
70 // find the nearest depth frame
71 if (timediff < min_timediff)
72 {
73 min_timediff = timediff;
74 nearest_depth_img_timestamp = depth_img_timestamp;
75 nearest_depth_img_file_path = depth_img_file_path;
76 }
77 }
78
79 // reject if the time diff is over the threshold
80 if (min_timediff_thr < min_timediff)
81 {
82 continue;
83 }
84
85 timestamps_.push_back((rgb_img_timestamp + nearest_depth_img_timestamp) / 2.0);
86 rgb_img_file_paths_.push_back(rgb_img_file_path);
87 depth_img_file_paths_.push_back(nearest_depth_img_file_path);
88 }
89 }
90 else
91 {
92 // !use depth predicted from CNN

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected