Ubuntu 安装并使用OpenMVG和OpenMVS(保姆级教程)

1.说明:

需要的工具:
• CMake
• Git
• C/C++ compiler(GCC, Visual Studio or Clang)

2.OpenMVG 安装

1) 安装依赖
 

sudo apt‐get install libxxf86vm1 libxxf86vm‐dev libpng‐dev libjpeg‐dev libtiff‐dev libxi‐dev libxrandr‐dev


2) Graphviz for view graph svg logs.
 

sudo apt‐get install graphviz


3) 下载 OpenMVG
 

git clone https://github.com/openMVG/openMVG.git
cd openMVG
mkdir openMVG_Build && cd openMVG_Build

4) 编译并安装
 

cmake ‐DCMAKE_BUILD_TYPE=RELEASE ../openMVG/src/
cmake ‐‐build . ‐‐target install

3 安装 OpenMVS
依赖:
Eigen version 3.4 or higher
OpenCV version 2.4 or higher
Ceres version 1.10 or higher

CGAL version 4.2 or higher
Boost version 1.56 or higher
VCG
GLFW
说明:OpenCVEigen 的安装方式网上有很多,此处就不浪费篇幅了。我使用的是OpenCV3.4Eigen3.4

3.1 安装依赖
1) 安装所需依赖:

sudo apt‐get install libglu1‐mesa‐dev


2) CGAL (Required)

sudo apt‐get install libcgal‐dev libcgal‐qt5‐dev


3) Boost (Required)

sudo apt‐get install libboost‐iostreams‐dev libboost‐program‐options‐dev libboost‐system‐dev libboost‐serialization‐dev


4) VCGLib (Required)
将 vcglib 里面的 vcg、warp 等文件夹移动到系统的 include 文件夹里即可。

通过cp -r 命令

git clone https://github.com/cdcseacave/VCG.git vcglib


5) Ceres (Optional)

$ sudo apt‐get install libatlas‐base‐dev libsuitesparse‐dev
$ git clone https://ceres‐solver.googlesource.com/ceres‐solver ceres‐solver
$ cd ceres‐solver && mkdir ce_build && cd ce_build $ cmake ..
$ sudo make ‐j2 && sudo make install


6) GLFW3 (Optional)
 

sudo apt‐get install freeglut3‐dev libglew‐dev libglfw3‐dev

3.2 编译并安装 OpenMVS
在项目文件夹运行下面的命令

mkdir openMVS_build && cd openMVS_build


在 cmake 的时候一定要将 build_ type 设置为 release

可以通过cmake-gui来设置

cmake ..


编译并安装:

make ‐j4 && sudo make install


build 文件夹下的 bin 里面就是编译生成的可执行文件就是我们所需要的。

4 OpenMVG+OpenMVS 三维重建
 可以通过如图的方式创建文件夹,bin 文件夹就是 OpenMVS 编译生成的,将照片放入 images 文件夹中

 下面就我们就可以对数据集进行三维重建。我们可以将这些命令写入一个sh 脚本,这样方便点

# 使用OpenMVG生成稀疏点云图
#第一个命令‐f 后面跟的是拍摄照片时的焦距与照片长边像素个数的乘积
openMVG_main_SfMInit_ImageListing ‐i images ‐o matches ‐f 3399
openMVG_main_ComputeFeatures ‐i matches/sfm_data.json ‐o matches/
openMVG_main_ComputeMatches ‐i matches/sfm_data.json ‐o matches/matches.txt
openMVG_main_SfM ‐i matches/sfm_data.json ‐o matches/ ‐‐match_file matches/matches.txt
openMVG_main_ExportUndistortedImages ‐i matches/sfm_data.json ‐o matches/image
openMVG_main_openMVG2openMVS ‐i matches/sfm_data.bin ‐o scene.mvs

#使用OpenMVS
./../bin/DensifyPointCloud scene.mvs
./../bin/ReconstructMesh scene_dense.mvs
./../bin/RefineMesh scene_dense_mesh.mvs
./../bin/TextureMesh scene_dense_mesh_refine.mvs
./../bin/Viewer scene_dense_mesh_refine_texture.mvs

效果如图:

5 额外的说明

5.1 出现的一个小问题
        如果 Ceres 不是通过 git 命令下载的可能会出现子模块没下载的问题

解决方法: 通过图中给出命令,完成子模块的下载。

git submodule update

5.2 OpenMVG 命令使用方式
        在 OpenMVG 包里面找到 tutorial_ demo.py.in,这个文本中包含了对命令的说明。

初学者文章可能不完善或者有问题,欢迎批评指正。

  • 1
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值