This is a monocular visual odometry implementation using OpenCV and c++. Steps involved in the implementation are:
- Feature detection using FAST
- Feature tracking using Lucas-Kanade Optical Flow
- Compute Essential Matrix using tracked features and recover pose
- Estimate absolute scale using GPS data.
The scale information is obtained from GPS data. The GPS data is in the form of latitude, longitude and altitude. The GPS data is converted to UTM coordinates and the distance between two consecutive UTM coordinates is calculated. This distance is used to estimate the scale factor.
The code is tested on the KITTI dataset. The dataset can be downloaded from here. The code is tested on the sequence 00. The ground truth data is provided in the dataset. The estimated trajectory is compared with the ground truth data to evaluate the performance of the algorithm.
- Clone the repository
- Download the KITTI dataset
- Run the following commands:
mkdir build
cd build
cmake ..
make
./vo
Make sure to change the path of the dataset, gps data and ground truth data in the comfig.yaml file.
- Clone the repository
- Download the KITTI dataset
- Run the following commands:
docker build -t vo_image . // build the docker image
xhost +local:root // allow the docker container to display the output
docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /path/to/dataset:/app/data_dir vo_image // run the docker container
Don't forget to change the path to the dataset when running the docker container.
The estimated trajectory is shown below. The red line represents the ground truth trajectory and the blue line represents the estimated trajectory.
Demo video is shown below:
The code is inspired from the following sources:
- Avi Singh's blog on Monocular Visual Odometry using OpenCV
- The UTM conversion code is taken from here

