Steps of the algorithm are taken from Avi Singh's blog post mentioned above.
- Capture images: It and It + 1
- Undistort the captured images (not necessary for KITTI dataset)
- Use FAST algorithm to detect features in image It. Track these features using an optical flow methodology, remove points that fall out of frame or are not visible in It + 1. Trigger a new detection of points if the number of tracked points falls behind a threshold. Set to 2000 in this implementation.
- Apply Nister's 5-point algorithm with RANSAC to find the essential matrix.
- Estimate R, t from the essential matrix that was computed from Nister's algorithm.
- Obtain scale information from an external source and concatenate translation vectors t and rotation matrices R.
For each of the steps above, the line of code is provided to the exact location where this step is preformed in the code for easy understanding. Steps 1 and 2 are skipped as they are not necessary in the KITTI dataset.
The dataset used is: KITTI Visual Odometry
Or you can use this link to download this dataset link
- Python 3.**
- opencv-python
- numpy
- First clone repository
$ git clone https://github.com/aji-ptn/Mono_odometry.git
- In
main.pychangeimg_pathandpose_pathto correct image sequences and pose file paths in line 7 and 8
img_path = '/home/aji/Documents/Dataset/data_odometry_gray/dataset/sequences/00/image_0/'
pose_path = '/home/aji/Documents/Dataset/data_odometry_poses/dataset/poses/00.txt'
- Ensure focal length and principal point information is correct
focal = 718.8560 # focal length
pp = (607.1928, 185.2157) # principal point
- Adjust Lucas Kanade Parameters as needed (line 16 in main.py)
lk_params = dict(winSize=(21, 21), criteria=(cv.TERM_CRITERIA_EPS | cv.TERM_CRITERIA_COUNT, 30, 0.01))
- Run command
main.py
You can click this video
An invaluable resource I used in building the visual odometry system was Avi Singh's blog post: http://avisingh599.github.io/vision/monocular-vo/ as well as his C++ implementation found here.


