This project implements Visual Odometry using ORB features and the KITTI dataset to estimate camera pose from image sequences.
The VisualOdometry
class provides core functionality:
- Initialization: Loads calibration data, ground truth poses, and images.
- Feature Detection and Matching: Uses ORB to detect features and FLANN matcher for descriptor matching.
- Pose Estimation: Computes the Essential matrix, decomposes it to find rotation and translation, and estimates camera pose.
-
Initialization (
__init__
):- Load calibration (
K
andP
), ground truth poses, and images. - Initialize ORB detector and FLANN matcher.
- Load calibration (
-
Load Calibration Data (
_load_calib
):- Reads calibration file for intrinsic matrix
K
and projection matrixP
.
- Reads calibration file for intrinsic matrix
-
Load Ground Truth Poses (
_load_poses
):- Reads and formats ground truth poses as 4x4 matrices.
-
Load Images (
_load_images
):- Loads grayscale images from the specified directory.
-
Feature Matching (
get_matches
):- Detects and matches ORB keypoints between consecutive frames.
- Filters matches using Lowe's ratio test.
- Displays matches for visualization.
-
Pose Estimation (
get_pose
):- Estimates Essential matrix and decomposes it to retrieve rotation
R
and translationt
. - Constructs a transformation matrix.
- Estimates Essential matrix and decomposes it to retrieve rotation
-
Decompose Essential Matrix (
decomp_essential_mat
):- Decomposes the Essential matrix into possible transformations.
- Triangulates points to select the best transformation.
-
Main Function (
main
):- Initializes
VisualOdometry
with dataset. - Iterates over poses, matches features, and estimates pose for each frame.
- Visualizes estimated path against ground truth.
- Initializes
- Place the KITTI dataset in a directory (e.g.,
VisualSLAM/KITTI_sequence_1
). - Ensure the directory contains
calib.txt
,poses.txt
, and theimage_l
directory. - Run the script:
python your_script_name.py
The system will display feature matches and plot the estimated path against the ground truth.