OpenSfM code is available at Github. The simplest way to get the code is to clone the repository and its submodules with:

git clone --recursive

If you already have the code or you downloaded a release, make sure to update the submodules with:

cd OpenSfM
git submodule update --init --recursive

Install dependencies

OpenSfM depends on the following libraries that need to be installed before building it.

Installing dependencies on Ubuntu

If using Python 3, see this Dockerfile for the commands to install all dependencies on Ubuntu 18.04.

If using Python 2, follow the process here Dockerfile.python2.

The main steps are

  1. Install OpenCV, NumPy, SciPy using apt-get
  2. Install python requirements using pip
  3. Build and Install the Ceres solver from its source using the -fPIC compilation flag.

Installing dependencies on MacOSX

Install OpenCV and the Ceres solver using:

brew install opencv
brew install ceres-solver
sudo pip install -r requirements.txt

Make sure you update your PYTHONPATH to include /usr/local/lib/python2.7/site-packages where OpenCV have been installed. For example with:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH


Note on OpenCV 3 When running OpenSfM on top of OpenCV version 3.0 the OpenCV Contrib modules are required for extracting SIFT or SURF features.

Building the library

Once the dependencies have been installed, you can build OpenSfM by running the following command from the main folder:

python build

or python3 build for a Python 3 build.

Building the documentation

To build the documentation and browse it locally use:

cd doc
make livehtml

and browse http://localhost:8001/