Structure-from-Motion (SFM) is genuinely an interesting topic in computer vision, Basically making 3D structure from something 2D is absolutely mesmerizing 🙂
There two open source yet very robust tools for SFM, which sometimes compiling them might be complicated, here I will share my experience with you.
1)VisualSFM
Prerequisite:
1)Glew
Download the glew from SF at http://glew.sourceforge.net/. Do NOT get it from Github as to seems to have some problems.
1 2 3 |
cd build/cmake/ && mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=~/usr .. && make -j8 all install |
2)SiftGPU
Prerequisite:
Install DevIl Image library
1 |
sudo apt-get install libdevil-dev |
1 |
git clone https://github.com/pitzer/SiftGPU |
open makefile and enable siftgpu_enable_cuda
1 |
siftgpu_enable_cuda=1 |
1 |
make -j8 |
now go to bin directory and libsiftgpu.so to your vsfm bin directory
VSFM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
1) Download the <a href="http://ccwu.me/vsfm/download/VisualSFM_linux_64bit.zip">vsfm</a> program 1-1)cd vsfm 1-2)make 2) Download <a href="https://grail.cs.washington.edu/projects/mcba/pba_v1.0.5.zip">PBA</a> 2-1)If you have no GPU rename makefile_no_gpu to makefie 2-2)make 2-3)rename bin/libpba_no_gpu.so to libpba.so and copy it in the vsfm/bin 3) Download <a href="https://github.com/pmoulon/CMVS-PMVS">CMVS-PMVS</a> 3-1)cd CMVS-PMVS-master/program 3-2)mkdir build && cd build 3-3)cmake ../ && make -j8 3-4)copy cmvs, genOption, pmvs2 from build/main into vsfm/bin 4) copy libsiftgpu.so from previous section to vsfm/bin 5) Run: export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH ./VisualSFM |
you can see the some of my results here:
Note: if you don’t have cuda or Nvidia driver you can use your CPU but then you have to limit your file image size and sift binary should be available in your vsfm/bin directory.
Download http://www.cs.ubc.ca/~lowe/keypoints/siftDemoV4.zip and make it and copy the sift binary to vsfm/bin.
2)Colmap
The installation fo this one is almost straightforward except you need the latest version of Ceres Solver (do not use the one binary package from Ubuntu they are old and they won’t work). So download and make and install the Ceres Solver using the following:
1 |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=~/usr .. && make -j8 all install |
Now in the colmap CMakeList.txt add the following line:
1 |
set(Ceres_DIR "$ENV{HOME}/usr/lib/cmake/Ceres") |
just before “find_package(Ceres REQUIRED)”
and now you can make and install it. You can see some of my results here:
In the next post, I will show you how can you do that in OpenCV.