Inferensys

Glossary

Keyframe

A keyframe is a selectively chosen representative frame from a sensor stream (e.g., a camera image) that is stored for long-term mapping and optimization in SLAM systems, reducing computational load while preserving essential information.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
SLAM AND ROBOTICS

What is a Keyframe?

In Simultaneous Localization and Mapping (SLAM) and computer vision, a keyframe is a selectively stored representative frame from a sensor stream that anchors long-term mapping and optimization.

A keyframe is a sparsely selected, information-rich frame from a continuous sensor stream—typically a camera image or LiDAR scan—that is retained as a definitive map anchor. Instead of processing every frame, SLAM systems identify keyframes based on criteria like significant scene change, sufficient parallax, or tracking quality. This selective retention drastically reduces computational load and memory usage while preserving the essential geometric and visual information needed for global map consistency and loop closure detection.

During back-end optimization, such as bundle adjustment or pose graph optimization, only these keyframes and their associated 3D landmarks are adjusted. This creates a sparse but highly accurate skeletal representation of the environment and trajectory. The process of keyframe selection is therefore critical; poor selection can lead to map degradation or optimization failure. In modern systems like ORB-SLAM, keyframes also store feature descriptors (e.g., ORB features) for robust place recognition, enabling the system to recognize revisited locations and correct accumulated drift.

SLAM FUNDAMENTALS

Core Characteristics of a Keyframe

In Simultaneous Localization and Mapping (SLAM), a keyframe is not merely a stored image. It is a strategically selected data anchor that balances computational efficiency with mapping accuracy. These cards detail its defining technical attributes.

01

Representative Data Selection

A keyframe is a selectively chosen frame from a continuous sensor stream (e.g., camera, LiDAR) that meets specific criteria for long-term retention. It is not every frame.

  • Selection Criteria: Frames are chosen based on metrics like sufficient parallax (camera motion), number of new observed landmarks, or information gain relative to existing keyframes.
  • Purpose: This selection drastically reduces the number of states to optimize in the back-end, turning an intractable problem of optimizing every frame into a sparse, manageable one.
  • Example: In ORB-SLAM, a new keyframe is created when tracking quality is good and the camera has moved a significant baseline from the last keyframe, ensuring new 3D points can be triangulated.
02

Anchor for 3D Map Points

A keyframe serves as the primary observational anchor for a set of 3D landmarks (map points). It stores the descriptors and pixel coordinates of features associated with these landmarks.

  • Data Association: The feature descriptors (e.g., ORB, SIFT) stored in the keyframe are used for matching against current frames for tracking and for loop closure detection against past keyframes.
  • Observation Database: Each keyframe maintains a list of which 3D map points it observes and their 2D projections. This creates the essential projection factors used in bundle adjustment or graph optimization.
  • Implication: Deleting a keyframe often requires culling or re-triangulating its associated map points, affecting map density.
03

Node in the Pose Graph

In modern graph-based SLAM systems like g2o or GTSAM, each keyframe becomes a node in a pose graph or factor graph.

  • Node State: The node contains the 6-DoF pose (position and orientation) of the sensor at the time the keyframe was captured.
  • Constraint Edges: Edges between keyframe nodes represent spatial constraints. These can be from odometry (between consecutive keyframes), loop closures (between non-consecutive keyframes), or relative pose measurements from sensor fusion.
  • Optimization: The back-end optimization solves for the most probable configuration of all keyframe poses given this network of constraints, minimizing drift.
04

Computational Load Management

The core rationale for keyframes is to manage computational and memory resources in long-term, large-scale SLAM.

  • Memory Efficiency: Storing full sensor data for every frame is prohibitive. Keyframes provide a sparse yet information-rich summary of the trajectory and environment.
  • Optimization Scalability: Bundle adjustment complexity grows non-linearly with the number of frames. By limiting optimization to keyframes, real-time performance is maintained over extended operations.
  • Culling Strategies: Systems implement keyframe culling policies to prevent unbounded growth. A keyframe may be removed if over 90% of its map points are seen in three other keyframes, ensuring sparsity without information loss.
05

Temporal and Spatial Sparsity

Keyframes are inherently sparse in time but dense in information. Their distribution along the trajectory is non-uniform and adaptive.

  • Temporal Sparsity: Keyframes are not captured at fixed time intervals. The rate adapts to motion and scene change. In fast motion, keyframes may be created more frequently to maintain tracking.
  • Spatial Coverage: The set of keyframes should provide overlapping observational coverage of the environment to support robust triangulation and loop closure. The baseline between keyframes is critical for accurate 3D reconstruction.
  • Metric: A common measure is the median scene depth or the parallax angle to previous keyframes to decide creation.
06

Role in Loop Closure

Keyframes are the fundamental unit for place recognition and loop closure, which are essential for correcting accumulated drift.

  • Query Database: When the system enters a previously visited area, the current frame is matched against a database of keyframe descriptors (often using a Bag-of-Words model like DBoW2) to find candidate matches.
  • Geometric Verification: A candidate loop closure keyframe undergoes rigorous geometric verification (e.g., using RANSAC with a fundamental or homography matrix) to reject false positives.
  • Constraint Addition: A validated loop closure creates a new constraint edge in the pose graph between the current keyframe and the past keyframe, triggering a global optimization to correct the entire map and trajectory.
CORE MECHANISM

How Keyframe Selection Works in a SLAM Pipeline

Keyframe selection is a critical throttling mechanism in SLAM systems that balances map accuracy against computational load by strategically deciding which sensor frames to retain for long-term optimization.

A keyframe is a selectively chosen, representative sensor frame (e.g., a camera image or LiDAR scan) stored permanently within the SLAM map. The selection algorithm acts as a gatekeeper, deciding if a new frame provides sufficient novel information—measured by factors like baseline distance, visual overlap, and tracked feature count—to warrant the computational cost of inclusion. This prevents redundant data from overwhelming the system's back-end optimization.

Effective selection maintains map sparsity while preserving observability for bundle adjustment or pose graph optimization. By retaining only geometrically informative frames, the system mitigates drift and enables efficient loop closure detection. Poor selection can cause map collapse from insufficient constraints or computational intractability from an oversized factor graph. The strategy is thus foundational to real-time, large-scale SLAM performance.

SLAM DATA MANAGEMENT

Keyframe vs. Regular Frame

A comparison of how representative frames (keyframes) and all sensor frames are processed and stored within a Simultaneous Localization and Mapping (SLAM) pipeline.

Feature / MetricKeyframeRegular Frame

Primary Purpose

Long-term map representation and global optimization anchor

Short-term tracking and immediate motion estimation

Storage Duration

Persistent; retained for the duration of the mapping session or permanently

Temporary; often discarded after processing for tracking (e.g., after 1-5 frames)

Processing Intensity

High; undergoes feature extraction, descriptor computation, candidate matching for loop closure, and inclusion in bundle adjustment

Low to Medium; used for fast feature matching and pose estimation relative to the last keyframe

Contribution to Map

Direct; its associated 3D landmarks are added to the global map

Indirect; used to estimate motion which informs keyframe creation and pose-graph edges

Selection Criteria

Based on heuristics: significant baseline/motion from last keyframe, tracking quality drop, or high information content

Automatic; every captured sensor reading (image, point cloud) is a regular frame

Density in Trajectory

Sparse (e.g., 1-5% of total frames)

Dense (100% of captured frames)

Role in Optimization

Node in the pose graph and/or bundle adjustment

Provides measurements that create constraints between keyframes or between a keyframe and the immediate state

Memory Footprint

High; stores full image/point cloud, extracted features, descriptors, and associated 3D landmarks

Very Low; often only feature coordinates and descriptors are cached briefly for tracking

Impact on Drift

Reduces drift via loop closure and global bundle adjustment

Contributes to drift if used exclusively for odometry (dead reckoning)

KEYFRAME

Frequently Asked Questions

Keyframes are a fundamental data structure in SLAM and computer vision, acting as efficient memory anchors for long-term mapping. These FAQs address their core function, selection, and role in modern robotic perception systems.

A keyframe is a selectively chosen, representative frame from a continuous sensor stream (like a camera image or LiDAR scan) that is stored for long-term mapping and optimization in a Simultaneous Localization and Mapping (SLAM) system. Instead of processing every single frame, the system identifies and retains only these information-rich keyframes, drastically reducing computational load and memory usage while preserving the essential geometric and visual information needed to build a consistent map and track the agent's pose. Keyframes serve as stable reference points against which new sensor data can be compared for loop closure and bundle adjustment.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.