Oct 17

Structure-from-Motion Toy Lib Upgrades to OpenCV 3

sfm toy lib
Hello again!

After a long hiatus I'm back with an update. Recently I've been upgrading the Structure-from-Motion Toy Library (https://github.com/royshil/SfM-Toy-Library/) to OpenCV 3.x from OpenCV 2.4.x.

OpenCV 3 introduced some additional functions in the API that make it even easier to do SfM, such as:

  • findEssentialMat - to find the Essential matrix, whereas before we only had a function for the Fundamental matrix.
  • recoverPose - that basically retires the old decomposeEssentialMat, which saves the trouble of decomposing the Essential matrix to rotation and translation and looking for the right solution using a chirality check.
  • solvePnPRansac - adds a RANSAC version for the old solvePnP

In this new version I am making use of these functions, as well as making tons of updates and simplifications to the core. It's basically a complete re-write, since I threw away most if not all of the old code and wrote it essentially from scratch. I'm also now relying more on a C++11 coding style, as well as just more structured better-documented coding style.

One major point I was trying to pursue is simplicity. Since far better and more flexible SfM libraries are already out there, I wanted to make this more of what it was originally designed to be - a soft tutorial to SfM using OpenCV. So I chucked all the GPU code paths, and the optical flow "feature detection", and kept it simple with an ORB detector. I also got rid of the visualization, now just outputting PLY files that can be visualized with any other software (e.g. MeshLab).

I hope you guys like and learn from it...

Get the code on GitHub: https://github.com/royshil/SfM-Toy-Library/


  • airyym

    Wow, Roy your project is very helpful to understand how SFM works.
    It's very simple and intuitive. Do you have any concern to make other subject such as Visual SLAM? Anyway, thank you so much your posting.