Building OpenSFM from OpenDroneMap

I am trying to study OpenSFM.

So, to build OpenSFM, I have tried reading the CMake files under ODM/SuperBuild/cmake at master · OpenDroneMap/ODM · GitHub.

After reading https://github.com/OpenDroneMap/ODM/blob/master/SuperBuild/cmake/External-OpenSfM.cmake,I found that we need OpenCV and Ceres to install OpenSFM.

Then I followed ODM/External-Ceres.cmake at master · OpenDroneMap/ODM · GitHub and ODM/External-OpenCV.cmake at master · OpenDroneMap/ODM · GitHub and built the libraries successfully.

I have even built the opensfm Successfully using the command

cmake /home/hemant/OpenSfM/opensfm/src \
>     -DCERES_ROOT_DIR=/usr/local \
>     -DOpenCV_DIR=/usr/local/lib/cmake/opencv4 \
>     -DADDITIONAL_INCLUDE_DIRS=/usr/local/include \
>     -DYET_ADDITIONAL_INCLUDE_DIRS= \
>     -DOPENSFM_BUILD_TESTS=off \
>     -DPYTHON_EXECUTABLE=/usr/bin/python3 ..

And I got the output as

-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Looking for sgemm_
-- Looking for sgemm_ - not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /usr/lib/x86_64-linux-gnu/libopenblas.so  
-- Looking for cheev_
-- Looking for cheev_ - found
-- A library with LAPACK API found.
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found AMD header in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CAMD header in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found COLAMD header in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CCOLAMD header in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found CHOLMOD header in: /usr/include/suitesparse
-- Found CXSPARSE library: /usr/lib/x86_64-linux-gnu/libcxsparse.so
-- Found SuiteSparseQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found SuiteSparseQR header in: /usr/include/suitesparse
-- Found Intel Thread Building Blocks (TBB) library: /usr/lib/x86_64-linux-gnu/libtbb.so, assuming SuiteSparseQR was compiled with TBB.
-- Found Intel Thread Building Blocks (TBB) Malloc library: /usr/lib/x86_64-linux-gnu/libtbbmalloc.so
-- Found SuiteSparse_config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found SuiteSparse_config header in: /usr/include/suitesparse
-- Adding librt: /usr/lib/x86_64-linux-gnu/librt.so to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Did not find METIS library (optional SuiteSparse dependency)
-- Found SuiteSparse: TRUE (found version "5.7.1") 
-- Found ceres: /usr/local/lib/libceres.a  
-- Found OpenCV: /usr/local (found version "4.5.0") 
-- Found OpenCV: /usr/local (found version "4.5.0") found components: core imgproc calib3d imgcodecs 
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
-- pybind11 v2.2.4
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hemant/OpenSfM/build

Then I run the command make -j32. It gets built successfully and I get the output as

[  5%] Built target akaze
[ 41%] Built target vl
[ 45%] Built target foundation
[ 47%] Built target dense
[ 50%] Built target geo
[ 52%] Built target bundle
[ 56%] Built target features
[ 63%] Built target geometry
[ 65%] Built target pydense
[ 67%] Built target pygeo
[ 69%] Built target pyfeatures
[ 71%] Built target pygeometry
[ 73%] Built target pybundle
[ 81%] Built target robust
[ 89%] Built target map
[ 91%] Built target pyrobust
[ 93%] Built target pymap
[ 97%] Built target sfm
[100%] Built target pysfm

After that, I am clueless what to do. I am bit new to cmake stuffs. I want to run the opensfm with different commands like extract_metadata, feature_detection, etc. from this OpenSFM library and explore few areas in the code.

If someone could help, it would be much appreciated. Thanks!

3 Likes

Hey there!

I am also exploring OpenSfM, what I did is that I build it from source from the github repo. See the docs at Building — OpenSfM 0.5.2 documentation , the steps are:

# install these libraries (I used paru)
# * [OpenCV](http://opencv.org/)
# * [Ceres Solver](http://ceres-solver.org/)

# cwd: /source
git clone --recursive https://github.com/mapillary/OpenSfM

cd OpenSfM
pip install -r requirements
python3 setup.py build

Still trying to install OpenSfM in a virtual env, but no luck with conda for now.

And then you could try the commands you want to try using:

# cwd: /source/OpenSfM
bin/opensfm detect_features data/banana 

Happy hacking!

4 Likes

I want to explore particulary OpenSFM library developed by OpenDroneMap as there are other functionalities like Rolling Shutter, Feature Detection & Matching using GPU, etc.

2 Likes

Hey!
Yes, GitHub - OpenDroneMap/OpenSfM: Open source Structure from Motion pipeline is a fork of the OpenSfM from Mapillary with some changes specific to ODM.
So if I’m getting this right, it seems like when going through the building process, a bin folder should be created that’ll hold all the “scripts” you need to use.
But just to be sure, could someone confirm this for us?
Thank you!

1 Like