MCPcopy Create free account
hub / github.com/93won/360_visual_inertial_odometry / ProcessFrame

Method ProcessFrame

src/processing/Estimator.cpp:209–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209Estimator::EstimationResult Estimator::ProcessFrame(const cv::Mat& image, double timestamp) {
210 auto frame_start = std::chrono::high_resolution_clock::now();
211 EstimationResult result;
212
213 // Create new frame
214 m_current_frame = CreateFrame(image, timestamp);
215
216 // =========================================================================
217 // State Machine: NOT_INITIALIZED -> VISUAL_ONLY -> VIO (without IMU data)
218 // =========================================================================
219
220 switch (m_tracking_state) {
221 case TrackingState::NOT_INITIALIZED: {
222 if (m_previous_frame) {
223 result.num_tracked = TrackFeatures();
224 } else {
225 DetectFeatures();
226 }
227
228 m_frame_window.push_back(m_current_frame);
229
230 if (static_cast<int>(m_frame_window.size()) > m_window_size) {
231 m_frame_window.erase(m_frame_window.begin());
232 }
233
234 LOG_DEBUG(" Window size: {}/{}, trying init...", m_frame_window.size(), m_window_size);
235
236 if (static_cast<int>(m_frame_window.size()) == m_window_size) {
237 bool init_result = TryInitialize();
238
239 if (init_result) {
240 result.init_success = true;
241 m_tracking_state = TrackingState::VISUAL_ONLY;
242
243 // Switch to tracking window size (smaller than init window)
244 m_window_size = m_tracking_window_size;
245 LOG_INFO("Initialization SUCCESS! Switching to tracking window size: {}", m_window_size);
246
247 auto first_frame = m_frame_window.front();
248 auto last_frame = m_frame_window.back();
249
250 first_frame->SetKeyframe(true);
251 last_frame->SetKeyframe(true);
252
253 m_first_keyframe_time = first_frame->GetTimestamp();
254 m_last_keyframe_time = last_frame->GetTimestamp();
255
256 m_keyframes.push_back(first_frame);
257 m_keyframes.push_back(last_frame);
258 m_last_keyframe = last_frame;
259
260 m_current_pose = last_frame->GetTwb();
261 } else {
262 if (m_frame_window.size() >= 2) {
263 auto first_frame = m_frame_window.front();
264 auto last_frame = m_frame_window.back();
265 float parallax = m_initializer->ComputeParallax(first_frame, last_frame);
266

Callers 1

mainFunction · 0.80

Calls 15

SetKeyframeMethod · 0.80
GetTimestampMethod · 0.80
GetTwbMethod · 0.80
GetMapPointMethod · 0.80
IsBadMethod · 0.80
SetTwbMethod · 0.80
SetCameraMethod · 0.80
GetPixelCoordMethod · 0.80
GetPositionMethod · 0.80
IsMarginalizedMethod · 0.80
SolvePnPWithSnapshotMethod · 0.80
IsKeyframeMethod · 0.80

Tested by

no test coverage detected