Ubuntu20.04安装三维重建的openMVG、openMVS和colmap环境

前言:

安装openMVS和colmap顺序不一样,会导致出现各种问题。这里建议先安装openMVS,再安装colmap,最后安装openMVG。

安装步骤参考了官网的dockerfile文件,需要自己预先安装cuda,可以度娘cuda的安装步骤。

一、openMVS安装过程

sudo apt-get -y install git mercurial cmake libpng-dev libjpeg-dev libtiff-dev libglu1-mesa-dev
git clone https://gitlab.com/libeigen/eigen --branch 3.4

安装eigen(一定要手动安装,自动安装的版本会低于3.4)

mkdir eigen_build
cd eigen_build &&\
	cmake . ../eigen -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ &&\
	make && sudo make install &&\
	cd ..

安装Boost

sudo apt-get -y install libboost-iostreams-dev libboost-program-options-dev libboost-system-dev libboost-serialization-dev

安装OpenCV

sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq libopencv-dev

安装CGAL

sudo apt-get -y install libcgal-dev libcgal-qt5-dev

安装VCGLib

git clone -b v1.0.1 https://github.com/cdcseacave/VCG.git vcglib

下载openMVS

git clone -b v1.1.1  https://github.com/cdcseacave/openMVS.git

编译

mkdir openMVS_build

注意了这里如果找不到VCG,那么将-DVCG_ROOT参数值改为绝对路径

cd openMVS_build &&\
	cmake . ../openMVS -DCMAKE_BUILD_TYPE=Release -DVCG_ROOT=../vcglib -DOpenMVS_USE_CUDA=ON -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs/ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ -DCUDA_INCLUDE_DIRS=/usr/local/cuda/include/ -DCUDA_CUDART_LIBRARY=/usr/local/cuda/lib64 -DCUDA_NVCC_EXECUTABLE=/usr/local/cuda/bin/

安装

	make -j4 &&\
	sudo make install

二、colmap安装过程

sudo apt-get install -y \
    git \
    cmake \
    vim \
    build-essential \
    libboost-program-options-dev \
    libboost-filesystem-dev \
    libboost-graph-dev \
    libboost-regex-dev \
    libboost-system-dev \
    libboost-test-dev \
    libeigen3-dev \
    libsuitesparse-dev \
    libfreeimage-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libglew-dev \
    qtbase5-dev \
    libqt5opengl5-dev \
    libcgal-dev \
    libcgal-qt5-dev

Build and install ceres solver

sudo apt-get -y install \
    libatlas-base-dev \
    libsuitesparse-dev
git clone https://ghproxy.com/https://github.com/ceres-solver/ceres-solver.git --branch 1.14.0
cd ceres-solver && \
	mkdir build && \
	cd build && \
	cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF && \
	make -j4 && \
	sudo make install

下载colmap

git clone -b 3.6 https://ghproxy.com/https://github.com/colmap/colmap.git #--branch 3.6-dev.3

 如果编译出现代码报错,可以更换其colmap的其它版本

cd colmap && \
	#git checkout dev && \
	mkdir build && \
	cd build && \
	cmake .. && \
	make -j4 && \
	sudo make install

如果在make出现【x86_64-linux-gnu/libfreeimage.so: undefined reference to `TIFFTileRowSize@LIBTIFF_4.0’】错误,可以参考这个链接(anaconda引起的问题)进行解决 

三、安装openMVG

安装依赖

由于ubuntu20的资源库缺少python-minimal和liblemon-dev,我将python-minimal换成python2-minimal,而liblemon-dev采用手动安装。

apt-get install -y \
  cmake \
  build-essential \
  graphviz \
  git \
  coinor-libclp-dev \
  libceres-dev \
  libflann-dev \
  libjpeg-dev \
  libpng-dev \
  libtiff-dev \
  python2-minimal; \
  apt-get autoclean && apt-get clean

安装liblemon-dev

打开lemon库网站,将lemon下载下来,我这里直接给出下载地址:http://security.ubuntu.com/ubuntu/pool/universe/s/sqlite3/lemon_3.31.1-4ubuntu0.5_amd64.deb

然后使用下面命令进行安装:

sudo dpkg -i lemon_3.31.1-4ubuntu0.5_amd64.deb

下载openMVG

git clone --recursive https://github.com/openMVG/openMVG.git

编译

mkdir openMVG_Build; \
  cd openMVG_Build;
cmake -DCMAKE_BUILD_TYPE=RELEASE \
    -DOpenMVG_BUILD_TESTS=ON \
    -DOpenMVG_BUILD_EXAMPLES=OFF \
    ../openMVG/src; \
    make -j 4;

如果前面没按照顺序导致eigen版本错误,可以参考这个链接删除后重新手动安装。

安装

make test && sudo make install;

ps:如果安装过程中出现各种乱七八糟的问题,可以使用docker进行安装,确认好安装步骤后再迁移本地。

你可能感兴趣的:(ubuntu,三维重建,colmap,openmvs,openmvg)