Sunday, 20 September 2015

The Basic Build

Install OpenMVG

The openMVG library contains and rebuilds almost all of the dependencies required during a source install, so simply clone it using:

git clone --recursive https://github.com/openMVG/openMVG.git 
cd openMVG 
git submodule init
git submodule update
cd .. 
Then build it in a separate directory with:

mkdir openMVG_Build
cd openMVG_Build/ 
cmake \ 
  -DCMAKE_BUILD_TYPE=DEBUG \
  -DOpenMVG_BUILD_TESTS=ON \
  -DopenMVG_BUILD_EXAMPLES=ON \
  -DCMAKE_INSTALL_PREFIX:STRING="/usr/local/openMVG_install" \
  -G "CodeBlocks - Unix Makefiles" . ../openMVG/src/ 

make clean 
make -j4 
sudo make install 
Note the custom install directory – this can be changed fairly easily, since the application will use the supplied cmake files in the install to locate the headers & libraries.

Adding the Library to an Application

This is all driven through cmake, with the target CmakeLists.txt containing the following fragment to locate the openMVG libraries and headers.

set(OpenMVG_DIR "/usr/local/openMVG_install/share/openMVG/cmake") 
set(CMAKE_BUILD_TYPE "Debug") 
ADD_DEFINITIONS(
    -std=c++11
)
It's actually slightly painful to use anything other than cmake here; the library include and link paths are rather verbose.
Note that C++ 11 is required for the smart pointers used by the openSfM library.