LoginSignup
1

More than 3 years have passed since last update.

posted at

updated at

VisualSFM

VisualSFMの概要

インストール

以下install-vsfm.shの内容

インストールのおおまかな流れ

  1. CUDAのインストール(オプション)
  2. 要求パッケージのインストール
  3. VisualSFMのインストール
  4. SiftGPUのインストール
  5. Multicore Bundle Adjustment(a.k.a. “pba”)のインストール
  6. PMVSのインストール
  7. Graclus1.2のダウンロードとインストール
  8. CMVSのインストール

CUDA

ここの記事のCUDAの説明がわかり易い。
https://qiita.com/Keech/items/381495ed90e012d69f1a

マシーンのCUDAを使えるGPUが搭載されていればCUDAをインストールする、
Install Nvidia CUDA if you have an CUDA capable Nvidia GPU (optional) CUDA documentation -> https://docs.nvidia.com/cuda/ Check compatibility -> https://developer.nvidia.com/cuda-gpus
Download the CUDA toolkit -> http://developer.nvidia.com/cuda/cuda-downloads

$ sudo dpkg -i cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
$ sudo apt-key adv --fetch-keys 
$ http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
$ sudo apt update
$sudo apt install cuda nvidia-cuda-dev nvidia-cuda-toolkit

Maybe add this to your ~/.bashrc

$ export PATH=/usr/local/cuda/bin:$PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH

Install dependencies

要求パッケージのインストール

$ sudo apt install libgtk2.0-dev libglew-dev libdevil-dev libboost-all-dev libatlas-cpp-0.6-dev libatlas-dev imagemagick libatlas3-base libcminpack-dev libgfortran3 libmetis-edf-dev libparmetis-dev freeglut3-dev libgsl-dev glew-utils

Download and extract VisualSFM

ここからVisualSFMをダウンロードする。
http://ccwu.me/vsfm/index.html

$ wget http://ccwu.me/vsfm/download/VisualSFM_linux_64bit.zip
$ unzip VisualSFM_linux_64bit.zip
$ rm VisualSFM_linux_64bit.zip

Download and install SiftGPU in the appropriate directory

SiftGPUのダウンロードとインストール
https://github.com/pitzer/SiftGPU

$ cd ~/vsfm
$ wget https://github.com/pitzer/SiftGPU/archive/master.zip
$ unzip master.zip
$ rm master.zip
$ mv SiftGPU-master SiftGPU
$ cd ~/vsfm/SiftGPU
$ make
$ cp ~/vsfm/SiftGPU/bin/libsiftgpu.so ~/vsfm/bin

Download and install Multicore Bundle Adjustment (A.K.A'pba') in the appropriate directory

$ cd ~/vsfm
$ wget http://grail.cs.washington.edu/projects/mcba/pba_v1.0.5.zip
$ unzip pba_v1.0.5.zip
$ rm pba_v1.0.5.zip
$cd ~/vsfm/pba
$ make
$ cp ~/vsfm/pba/bin/libpba.so ~/vsfm/bin/

オプションと言いながらもCUDAをインストールしてないとcuda.hが無いって言われてエラーになる。

 g++ -o bin/out/pba.o src/pba/pba.cpp -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -fPIC -L/usr/lib64 -L/usr/lib -L./bin -O2 -Wall -Wno-deprecated -pthread  -march=native - mfpmath=sse -fpermissive -c
 g++ -o bin/out/CuTexImage.o src/pba/CuTexImage.cpp -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -fPIC -L/usr/lib64 -L/usr/lib -L./bin -O2 -Wall -Wno-deprecated - pthread  -march=native -mfpmath=sse -fpermissive -c
 src/pba/CuTexImage.cpp:29:18: fatal error: cuda.h: No such file or directory compilation terminated.
 makefile:45: recipe for target 'bin/out/CuTexImage.o' failed
 make: *** [bin/out/CuTexImage.o] Error 1

こうしないとダメ。
$ make -f makefile_no_gpu
$ cp ~/vsfm/pba/bin/libpba_no_gpu.so ~/vsfm/bin/
$ mv  ~/vsfm/bin/libpba_no_gpu.so ~/vsfm/pba/bin/libpba.so 

Try using the following commands if the make command failed
makeに失敗した場合は以下のコマンドを実行し再度make
you’ll need to edit two source code files. In “pba/src/pba”, edit “SparseBundleCU.h” and
“pba.h” by adding this one line to the top of each file:
SparseBundleCU.hとpba.hにの先頭に#include を追加する。

$ echo -e "#include <stdlib.h>\n$(cat ~/vsfm/pba/src/pba/SparseBundleCU.h)" >~/vsfm/pba/src/pba/SparseBundleCU.h
$ echo -e "#include <stdlib.h>\n$(cat ~/vsfm/pba/src/pba/pba.h)" > ~/vsfm/pba/src/pba/pba.h

参考になったページ
http://www.10flow.com/2012/08/15/building-visualsfm-on-ubuntu-12-04-precise-pangolin-desktop-64-bit/

Download, hack and install PMVS in the appropriate directory

PMVSのダウンロードとインストール
http://www.di.ens.fr/pmvs/documentation.html

$ cd ~/vsfm
$ wget http://www.di.ens.fr/pmvs/pmvs-2.tar.gz
$ tar xvzf pmvs-2.tar.gz
$ rm pmvs-2.tar.gz

$ cd ~/vsfm/pmvs-2/program/main/
$ cp ~/vsfm/pmvs-2/program/main/mylapack.o ~/vsfm/pmvs-2/program/main/mylapack.o.backup
$ make clean
$ cp ~/vsfm/pmvs-2/program/main/mylapack.o.backup ~/vsfm/pmvs-2/program/main/mylapack.o
$ make depend
$ make

Download and install Graclus1.2

Graclus1.2のダウンロードとインストール
http://www.cs.utexas.edu/users/dml/Software/graclus.html

$ cd ~/vsfm
$ wget http://www.cs.utexas.edu/users/dml/Software/graclus1.2.tar.gz
$ tar xvzf graclus1.2.tar.gz
$ rm graclus1.2.tar.gz
$ sed -i 's/COPTIONS = -DNUMBITS=32/COPTIONS = -DNUMBITS=64/' ~/vsfm/graclus1.2/Makefile.in
$ cd ~/vsfm/graclus1.2/ <----ここにcdしてmakeしないとダメ。
$ make

Download, hack and install CMVS in the appropriate directory

CMVSのダウンロードとインストール
http://www.di.ens.fr/cmvs/documentation.html

$ cd ~/vsfm
$ wget http://www.di.ens.fr/cmvs/cmvs-fix2.tar.gz
$ tar xvzf cmvs-fix2.tar.gz
$ rm cmvs-fix2.tar.gz

$ cp ~/vsfm/pmvs-2/program/main/mylapack.o ~/vsfm/cmvs/program/main/

$ echo -e "#include <vector>\n#include <numeric>\n$(cat ~/vsfm/cmvs/program/base/cmvs/bundle.cc)" > ~/vsfm/cmvs/program/base/cmvs/bundle.cc
$ echo -e "#include <stdlib.h>\n$(cat ~/vsfm/cmvs/program/main/genOption.cc)" > ~/vsfm/cmvs/program/main/genOption.cc
$ sed -e '/Your INCLUDE path*/ s/^#*/#/' -i ~/vsfm/cmvs/program/main/Makefile
$ sed -e '/Your metis directory*/ s/^#*/#/' -i ~/vsfm/cmvs/program/main/Makefile
$ sed -e '/Your LDLIBRARY path*/ s/^#*/#/' -i ~/vsfm/cmvs/program/main/Makefile

$ sed -i "s:YOUR_INCLUDE_METIS_PATH =*:YOUR_INCLUDE_METIS_PATH = -I$HOME/vsfm/graclus1.2/metisLib:" ~/vsfm/cmvs/program/main/Makefile
$ sed -i "s:YOUR_LDLIB_PATH =*:YOUR_LDLIB_PATH = -L$HOME/vsfm/graclus1.2:" ~/vsfm/cmvs/program/main/Makefile


$ cd ~/vsfm/cmvs/program/main
$ make
graclus1.2のインストールする際、~/vsfm/graclus1.2/にcdしてからmakeすれば 
multilevelとmetisのエラーは無くなる。

multilevelとmetisというライブラリが必要らしい。
g++ -c -O2 -Wall -Wno-deprecated -DNUMBITS=64 -I/home/miyamoto/vsfm/graclus1.2/metisLib -fopenmp -DNUMBITS=64 ../base/cmvs/graclus.cc
g++ -L/home/miyamoto/vsfm/graclus1.2 -lXext -lX11 -ljpeg -lm -lpthread -llapack -fopenmp -lmultilevel -lmetis -lm -o cmvs cmvs.o patch.o camera.o image.o photo.o photoSetS.o bundle.o
graclus.o -L/home/miyamoto/vsfm/graclus1.2 -lXext -lX11 -ljpeg -lm -lpthread -llapack - fopenmp -lmultilevel -lmetis -lm

/usr/bin/ld: cannot find -lmultilevel
/usr/bin/ld: cannot find -lmetis
collect2: error: ld returned 1 exit status
Makefile:49: recipe for target 'cmvs' failed
make: *** [cmvs] Error 1

$ cp ~/vsfm/cmvs/program/main/cmvs ~/vsfm/bin
$ cp ~/vsfm/cmvs/program/main/pmvs2 ~/vsfm/bin
$ cp ~/vsfm/cmvs/program/main/genOption ~/vsfm/bin


$ cd ~/vsfm
$ make

Maybe add this to your ~/.bashrc

$ export PATH=$PATH:$HOME/vsfm/bin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/vsfm/bin

使い方

https://qiita.com/takaaki5564/items/f6c3c8fe659c44a3e191
http://bluebirdofoz.hatenablog.com/entry/2017/11/07/022646
http://hamakun.web.fc2.com/UAV_Ortho.pdf

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
1