OpenGV
A library for solving calibrated central and non-central geometric vision problems
Installation

Before you start

If you are only interested in using the library under Matlab, now there is a precompiled mex-library for 64-bit systems available. You can download it from:

Windows: http://laurentkneip.github.io/publications/opengv.mexw64
Mac OSX: http://laurentkneip.github.io/publications/opengv.mexmaci64

These versions have been added around March 2016, so please be aware that later additions may not be included in this distribution. You can go immediately to Use under Matlab to receive further instructions on the Matlab interface.

Downloading the source code

OpenGV is freely available under

https://github.com/laurentkneip/opengv

You may first have to register on github.com. You can just download a zip-file with the code, but we strongly recommend that you make yourself familiar with git. Git is a distributed version-control and source code management system. By using git to clone the repository locally, you can easily get updates at a later stage, and also facilitate the integration of own improvements or extensions into the original repository on github. This is done using the pull-request mechanism.

To clone the library under Mac OSX or Linux, simply type (assuming that git is installed):

git clone https://github.com/laurentkneip/opengv

Under Windows you probably have a similar option. More information about git can be found here:

http://git-scm.com/

Follow the "Try git" link for an amazing interactive tutorial.

Installation under Linux

  • Setup the required tools for compilation of standard libraries under Linux (gcc compiler etc). Type:

    sudo apt-get install build-essential
    

  • Install cmake. CMake is a cross-platform, open-source build system used for pretty much anything in the compilation process for the compilation/linking of the library. Type:

    sudo apt-get install cmake
    

  • Install eigen3. Eigen3 is a powerful linear algebra library used for all computations in OpenGV. You can either use an installed version of a local install (unzipped version of Eigen3 downloaded from Eigen website).

    sudo apt-get install cmake libeigen3-dev
    

  • Go to the top-level directory of OpenGV. Type:

    mkdir build && cd build && cmake .. && make
    

    If a message like "Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR EIGEN_VERSION_OK)" appears. It's certainly because that you does not have Eigen3 installed on your computer system path. You can specify to cmake the path where Eigen is located by adding:

    mkdir build && cd build && cmake .. -DEIGEN_INCLUDE_DIR:STRING="EigenIncludePath" && make
    

  • Done. The default configuration does not build the tests or python-wrappers, please set the according variables in CMakeLists.txt to ON if you desire the tests or python-wrappers to be built as well.

Installation under Windows

  • We need a suitable compiler for C++. We chose Visual Studio Express, which is free. Google for "Microsoft Visual Studio Express", it should be one of the first links. Make sure you download and install the "Windows Desktop version". If you are in a school setting without Administrator rights, just go to your local IT guy and ask him to install Microsoft Visual Studio on your machine.

  • We also need CMake under Windows. Go to:

    http://www.cmake.org/
    

    and download the latest version. In a school setting without administrator rights, chose to download the zip-file. Extract it somewhere.

  • Open a new Developer Command Prompt for VS2012 and make sure all VS path variables are correctly set by checking the output of PATH. We also need to add the cmake-tools to the path. Add it by typing

    cd C:\<path to cmake>\bin
    PATH=%PATH%;%cd%;
    

  • Go to the opengv directory and add a build folder
  • Now go to the

    opengv\build
    

    directory, and setup the build process by typing:

    cmake -G "Visual Studio 11" ..
    

    You need to add the correct generator for your Visual Studio version. I downloaded Visual Studio 2012, so it's 11 :)

  • Now build the library by typing:

    msbuild opengv.sln /p:Configuration=Release
    

    inside the build directory. While there is not a single warning under Linux, there are thousands of warnings under Windows :) If anyone knows the reason, please let us know.

  • Note that we Eigen dependency is not longer included. It is better to get a fresh download of Eigen on your computer, and specify to cmake the Eigen include path with -DEIGEN_INCLUDE_DIR="path".

Installation under OSX

Has been succesfully tested as well.

  • Install homebrew: http://brew.sh/
  • Type: "brew install cmake eigen"
  • Compile using normal cmake procedure.

Installing OpenGV on the host OS

Installation on the host OS (including the headers) can be activated by simply launching the install target. By using "sudo make install" on Linux and OSX and by compiling the install target on the opengv Visual Studio solution in Windows. Sudo is required for system install. You can choose to have a local installation path by setting the cmake variable CMAKE_INSTALL_PREFIX to the path of your choice by using -DCMAKE_INSTALL_PREFIX:STRING="YourInstallPath" in the cmake command line.

cmake ../opengv 
  -DEIGEN_INCLUDE_DIR="EigenIncludePath"
  -DBUILD_TESTS=ON
  -DCMAKE_INSTALL_PREFIX="YourInstallPath"
make
make install #sudo not required since we use a local installation

Installing the Matlab-wrapper (Windows-version)

  • First setup the compiler from Matlab. Go to the matlab console and type

    mex -setup
    

    and chose the right compiler by following the instructions. You will have to chose the same compiler than the one you used for compiling the opengv library before-hand. Under Windows you might also run into the following problem. Depending on the distribution (e.g. R2012b), Matlab does not yet "know" your compiler (e.g. Visual Studio 2012), so you will have to additionally follow the instructions under

    http://jimdavid.blogspot.com.au/2012/12/matlab-2012b-mex-setup-with-vs2012.html
    

    to get things running. Also note that the Express compilers are not supported by Matlab, we ran into some issues when trying to use them. Please report if you have a solution to that.

  • Once this is done, you can compile the mex-file by going to the opengv/matlab folder and typing in the console

    mex -I../include -I../EigenIncludePath -L../build/lib/Release -lopengv opengv.cpp
    

  • An additional note on 64-bit Windows/Matlab systems: If you have a Matlab version that is 64-bit, you will have to also compile OpenGV in 64-bit. You will have to follow two steps for this under Windows. The first one is to make sure that you open an x64 native tools command prompt to make the x64 Visual Studio compiler visible. The second one is to-when running cmake-extend the generator name by " Win64". The final command to run cmake finally looks as follows:

    cmake -G "Visual Studio 11 Win64" ..
    

    The actual build command stays the same.

Installing the Matlab-wrapper (Linux-version)

The following has been tested under Ubuntu 12.04 and a recent Matlab edition (>2013) (thanks to Oliver Dunkley for providing this information).

  • Install Matlab with the provided installer, and then add the matlab-support package through the package-repositories. This basically takes care of setting all the compiler stuff, adding a launcher, etc.
  • In order to make Matlab know about the shared object opengv.so, the path to opengv.so has to be added to LD_LIBRARY_PATH. Open .bashrc and add the line

    export LD_LIBRARY_PATH=<path to OpenGV>/build/lib:$LD_LIBRARY_PATH
    

    and then start Matlab from the terminal, it'll know about opengv ...

  • Go to the opengv/matlab-folder inside Matlab, and issue the command

    mex -I../include -I../EigenIncludePath -L../build/lib -lopengv opengv.cpp -cxx
    

    Note the lib directory does not contain a Release subfolder under linux, and that the -cxx option has to be added.

Installing the Matlab-wrapper (OSX-version)

To compile the Matlab interface under OSX, use the same command as under Windows, with adapted library folder (-L../build/lib instead of -L../build/lib/Release). You of course need to make sure again that Matlab knows where to find the library, and that a suitable compiler is set up in Matlab as well.

Installing the python wrappers

The compliation of the Python wrappers can be enabled by setting the option BUILD_PYTHON to ON. Note that the python wrappers depend additionally on boost, and that the wrapper currently only allows access to the central methods.

Using the OpenGV inside your cmake c++ project

Once your have a system or local install of opengv you can use it in your own project. In your cmake file, add the search for the opengv library:

find_package(opengv REQUIRED)
if (opengv_FOUND)
  add_executable(main_opengv_demo main.cpp)
  target_link_libraries(main_opengv_demo opengv)
endif (opengv_FOUND)

Then run cmake for your project (if you are using a local install of opengv, you can specify where the library is located by using -Dopengv_DIR:

 cmake ../myproject
 -DCMAKE_BUILD_TYPE=RELEASE 
 -Dopengv_DIR:STRING=/home/Foo/Documents/Dev/opengv_Build/install/CMake/