Ubuntu 环境 openMVG+openMVS 配置

1. openMVG

比较简单,直接按照 build wiki 的步骤一步一步来就没问题。

Instruction: Build on Linux

# Install the required external libraries.
sudo apt-get install libpng-dev libjpeg-dev libtiff-dev libxxf86vm1 libxxf86vm-dev libxi-dev libxrandr-dev
# If you want see the view graph svg logs, install Graphviz.
$ sudo apt-get install graphviz
# Checkout OpenMVG.
$ git clone --recursive https://github.com/openMVG/openMVG.git
# 设置编译和安装路径
$ cd openMVG
$ mkdir openmvg-build
$ mkdir openmvg-bin
$ cd openmvg-build
# Configure and build
$ cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/path/to/openMVG/openmvg-bin ../src/
$ cmake --build . --target install

2. openMVS

2.1 这一步就比较麻烦了,因为wiki里面的指导不一定能安装成功。

# Prepare and empty machine for building
apt-get update && apt-get install -qq
apt-get -y install build-essential git mercurial cmake libpng-dev libjpeg-dev libtiff-dev libglu1-mesa-dev libxmu-dev libxi-dev
#Boost (Required)
apt-get -y install libboost-iostreams-dev libboost-program-options-dev libboost-system-dev libboost-serialization-dev
#Eigen (Required)
git clone https://gitlab.com/libeigen/eigen.git --branch 3.3
cd eigen
mkdir eigen-build && cd eigen-build
cmake . .. -CMAKE_INSTALL_PREFIX=/path/to/eigen/eigen-bin
make && make install
cd ../..

2.2 下面这一步可能会出现问题,最好自己下载源码编译

#OpenCV (Required)
apt-get -y install libopencv-dev
# Build opencv from source
git clone https://github.com/opencv/opencv.git
cd opencv
git reset --hard 3.4.1
mkdir opencv-bin
mkdir opencv-build && cd opencv-build
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/path/to/opencv/opencv-bin ..
make -j8
make install

2.3 接下来的两个库直接按步骤就可以

#CGAL (Required)
apt-get -y install libcgal-dev libcgal-qt5-dev

#VCGLib (Required)
git clone https://github.com/cdcseacave/VCG.git vcglib
#Ceres (Required)
apt-get -y install libatlas-base-dev libsuitesparse-dev

# If google source encounter connection time out, try github
# git clone https://ceres-solver.googlesource.com/ceres-solver ceres-solver
git clone https://github.com/ceres-solver/ceres-solver.git

cd ceres-solver
git reset --hard 1.14.0
mkdir ceres-bin
mkdir ceres-build && cd ceres-build
cmake . ../ -DMINIGLOG=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
make -j2 && sudo make install
cd ../..

#GLFW3 (Optional)
apt-get -y install freeglut3-dev libglew-dev libglfw3-dev

2.4 进入主要步骤

#OpenMVS
git clone https://github.com/cdcseacave/openMVS.git openMVS
cd openMVS
mkdir openmvs-bin
mkdir openmvs-build && cd openmvs-build

cmake . ../ -DCMAKE_BUILD_TYPE=Release -DVCG_ROOT="/path/to/vcglib" -DBUILD_SHARED_LIBS=ON

#If something goes wrong, try to set shared libs OFF

#Install OpenMVS library (optional):
make -j8 && make install

2.5 make的过程中出现undefined reference错误记录如下

[100%] Linking CXX executable ../../bin/Viewer
/usr/bin/ld: CMakeFiles/Viewer.dir/Image.cpp.o: undefined refere
nce to symbol '_ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputAr
rayENS_5Size_IiEEddi'
//root/misc_codes/opencv/opencv-bin/lib/libopencv_imgproc.so.3.4
: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
apps/Viewer/CMakeFiles/Viewer.dir/build.make:229: recipe for tar
get 'bin/Viewer' failed
make[2]: *** [bin/Viewer] Error 1
CMakeFiles/Makefile2:732: recipe for target 'apps/Viewer/CMakeFi
les/Viewer.dir/all' failed
make[1]: *** [apps/Viewer/CMakeFiles/Viewer.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

openMVS的git issue里面提到的思路或许能解决问题

Ubuntu 环境 openMVG+openMVS 配置_第1张图片

in CMakeList.txt, add lines like below (replace {{target_name}} to your own):

find_package(Boost COMPONENTS system filesystem REQUIRED)
target_link_libraries({{target_name}} ${Boost_FILESYSTEM_LIBRARY})
target_link_libraries({{target_name}} ${Boost_SYSTEM_LIBRARY})

实际解决时,在每一个模块下面的CMakeLists.txt中添加动态链接库

# openMVS/apps/InterfaceCOLMAP/CMakeLists.txt
cxx_executable_with_flags_no_pch(InterfaceCOLMAP "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H})

target_link_libraries(InterfaceCOLMAP
        ${OpenCV_LIBRARIES}
        ${Boost_LIBRARIES}
        )

2.6 运行过程中遇到以下的问题

error: "There is no defined intrinsic data in order to compute an essential matrix for the initial pair."

解决方案

参考 openMVS git issue

Ubuntu 环境 openMVG+openMVS 配置_第2张图片 

至此配置完成,找一些数据如Middlebury dino/temple、DTU scan9、ETHD Pipes、Strecha fountain-P11等就可以运行测试了。

你可能感兴趣的:(Ubuntu 环境 openMVG+openMVS 配置)