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

Function mono_tracking

example/run_slam_planeSeg.cc:55–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53#endif
54
55void mono_tracking(const std::shared_ptr<PLPSLAM::config> &cfg,
56 const std::string &vocab_file_path,
57 const std::string &sequence_dir_path,
58 const unsigned int frame_skip,
59 const bool no_sleep,
60 const bool auto_term,
61 const bool eval_log,
62 const std::string &map_db_path)
63{
64 // FW: here, the second paramter *false* means:
65 // for now we don't have CNN-predicted depth image, leave it false
66 ImageSequence_withPlaneSeg sequence(sequence_dir_path, false);
67 const auto frames = sequence.get_frames();
68
69 // FW: the third parameter *true* means:
70 // we have segmentation mask as auxiliary input -> a boolean variable _b_seg_or_not = true
71 // this boolean variable is passed to system.cc
72 // after that, a planar_mapping module will be activated
73 // after that, a same boolean variable will be set as true in map_db, which used to control all the functionalities related to plane
74 PLPSLAM::system SLAM(cfg, vocab_file_path, true); // build a SLAM system
75
76 // startup the SLAM process, create multi-thread
77 SLAM.startup();
78
79 // create a viewer object
80 // and pass the frame_publisher and the map_publisher
81#ifdef USE_PANGOLIN_VIEWER
82 pangolin_viewer::viewer viewer(cfg, &SLAM, SLAM.get_frame_publisher(), SLAM.get_map_publisher());
83#elif USE_SOCKET_PUBLISHER
84 socket_publisher::publisher publisher(cfg, &SLAM, SLAM.get_frame_publisher(), SLAM.get_map_publisher());
85#endif
86
87 std::vector<double> track_times;
88 track_times.reserve(frames.size());
89
90 // FW: start the SLAM in the main thread (i.e. tracking thread)
91 std::thread thread([&]()
92 {
93 for (unsigned int i = 0; i < frames.size(); ++i)
94 {
95 const auto &frame = frames.at(i);
96 const auto rgb_img = cv::imread(frame.rgb_img_path_, cv::IMREAD_UNCHANGED);
97
98 // FW: read planar segmentation mask
99 const auto seg_mask_img = cv::imread(frame.mask_img_path_, cv::IMREAD_UNCHANGED);
100 assert(rgb_img.rows == seg_mask_img.rows);
101 assert(rgb_img.cols == seg_mask_img.cols);
102
103 const auto tp_1 = std::chrono::steady_clock::now();
104 if (!rgb_img.empty() && (i % frame_skip == 0) && !seg_mask_img.empty())
105 {
106 // input the current frame and estimate the camera pose
107 SLAM.feed_monocular_frame(rgb_img, seg_mask_img, frame.timestamp_);
108 }
109 const auto tp_2 = std::chrono::steady_clock::now();
110
111 const auto track_time = std::chrono::duration_cast<std::chrono::duration<double>>(tp_2 - tp_1).count();
112 if (i % frame_skip == 0)

Callers 1

mainFunction · 0.70

Calls 15

startupMethod · 0.80
get_frame_publisherMethod · 0.80
get_map_publisherMethod · 0.80
feed_monocular_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

Tested by

no test coverage detected