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

Method SetReferenceKeyframe

src/database/Frame.cpp:278–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278void Frame::SetReferenceKeyframe(std::shared_ptr<Frame> reference_kf) {
279 std::lock_guard<std::mutex> lock(m_pose_mutex);
280 m_reference_keyframe = reference_kf;
281
282 // Calculate relative transformation at the time of setting reference keyframe
283 if (reference_kf) {
284 // Current frame pose (direct from m_rotation, m_translation)
285 Eigen::Matrix4f T_wb_current = Eigen::Matrix4f::Identity();
286 T_wb_current.block<3, 3>(0, 0) = m_rotation;
287 T_wb_current.block<3, 1>(0, 3) = m_translation;
288
289 // Reference keyframe pose - need to unlock before calling GetTwb on another frame
290 // to avoid potential issues, we get pose components directly
291 Eigen::Matrix4f T_wb_ref = Eigen::Matrix4f::Identity();
292 T_wb_ref.block<3, 3>(0, 0) = reference_kf->GetRotation();
293 T_wb_ref.block<3, 1>(0, 3) = reference_kf->GetTranslation();
294
295 // Calculate relative transformation: T_rel = T_ref^-1 * T_current
296 m_T_relative_from_ref = T_wb_ref.inverse() * T_wb_current;
297 } else {
298 // No reference keyframe, set to identity
299 m_T_relative_from_ref = Eigen::Matrix4f::Identity();
300 }
301}
302
303std::shared_ptr<Frame> Frame::GetReferenceKeyframe() const {
304 return m_reference_keyframe.lock();

Callers 4

ProcessFrameMethod · 0.45
CreateKeyframeMethod · 0.45
ShrinkWindowAfterInitMethod · 0.45

Calls 3

GetRotationMethod · 0.80
GetTranslationMethod · 0.80
inverseMethod · 0.80

Tested by

no test coverage detected