OpenMVG + OpenMVS的配置与使用

项目地址:

https://github.com/openMVG/openMVG OpenMVG

https://github.com/cdcseacave/openMVS OpenMVS

 

 

Pipeline:

 

Structure from Motion(SfM) -> Multi-View Stereo(MVS) -> Surface Generation(SG) -> Texture Mapping(TM)

 

OpenMVG完成SFM,后续的MVS/SG/TM 由OpenMVS实现

 

 

所用的环境:

Ubuntu16.04 (Win10子系统版本)

 

OpenMVG:

配置过程中注意,不要用从github上下载解压的zip,要用git clone的形式

按照官方文档进行:

https://github.com/openMVG/openMVG/blob/master/BUILD.md#linux

此部分根据官方文档就应该能完成

 

OpenMVS:

照例按照官方文档进行:

https://github.com/cdcseacave/openMVS/wiki/Building

 

注意点1:

main_path='pwd' 这一步中‘pwd’更改为VCGLib所在的位置(这是后续要安装的一个库,推荐先装这个库)

 

注意点2:

Ceres部分

这里面的git clone里面的链接挂了,换成

https://github.com/ceres-solver/ceres-solver

 

 

 

注意点3:

后续编译找不到Eigen库,用下面的命令安装

sudo apt-get install libeigen3-dev

 

注意点4:

如果没有GPU,用不了CUDA那么需要在openMVS目录下找到CmakeLists.txt文件,找到CUDA开关,设置为OFF:

SET(OpenMVS_USE_CUDA OFF CACHE BOOL "Enable CUDA library")

 

运行脚本:

相机不在database中时我的版本:

 

 

#!/bin/bash

# reconstruction.sh

 

 

IMAGE_PATH='/home/chenyufeng/jieditanshuan'

CAMERA_SENSOR_WIDTH_DIRECTORY="/home/chenyufeng/openMVG/src/openMVG/exif/sensor_width_database"

OPENMVG_SFM_PATH='/home/chenyufeng/openMVG_Build/software/SfM'

OPENMVG_BIN_PATH='/home/chenyufeng/openMVG_Build/Linux-x86_64-RELEASE'

OPENMVG_OUT_PATH=$IMAGE_PATH/out

MATCHES_DIR=$OPENMVG_OUT_PATH/matches

REC_DIR=$OPENMVG_OUT_PATH/reconstruction_incremental

OPENMVS_BIN_PATH='/home/chenyufeng/openMVS_build/bin'

FOCAL_LENGTH=7200

 

echo "--- Reconstruction Begin ---"

cd $IMAGE_PATH && mkdir out

cd $OPENMVG_OUT_PATH && mkdir matches reconstruction_incremental

cd

echo "--- OpenMVG Intrinsics analysis 1/12 ---"

$OPENMVG_BIN_PATH/openMVG_main_SfMInit_ImageListing -i $IMAGE_PATH -f $FOCAL_LENGTH -o $MATCHES_DIR

#$OPENMVG_BIN_PATH/openMVG_main_SfMInit_ImageListing -i $IMAGE_PATH -o $MATCHES_DIR -d $CAMERA_SENSOR_WIDTH_DIRECTORY/sensor_width_camera_database.txt

 

echo "--- OpenMVG Compute features 2/12 ---"

# $OPENMVG_BIN_PATH/openMVG_main_ComputeFeatures -i $MATCHES_DIR/sfm_data.json -o $MATCHES_DIR -m AKAZE_FLOAT -p HIGH

$OPENMVG_BIN_PATH/openMVG_main_ComputeFeatures -i $MATCHES_DIR/sfm_data.json -o $MATCHES_DIR

 

echo "--- OpenMVG Compute Matches 3/12 ---"

$OPENMVG_BIN_PATH/openMVG_main_ComputeMatches -i $MATCHES_DIR/sfm_data.json -o $MATCHES_DIR

# $OPENMVG_BIN_PATH/openMVG_main_ComputeMatches -i $MATCHES_DIR/sfm_data.json -o $MATCHES_DIR -n ANNL2

 

echo "--- OpenMVG Do Incremental reconstruction 4/12 ---"

$OPENMVG_BIN_PATH/openMVG_main_IncrementalSfM -i $MATCHES_DIR/sfm_data.json -m $MATCHES_DIR -o $REC_DIR

 

echo "--- OpenMVG Colorize Structure 5/12 ---"

$OPENMVG_BIN_PATH/openMVG_main_ComputeSfM_DataColor -i $REC_DIR/sfm_data.bin -o $REC_DIR colorized.ply

 

echo "--- OpenMVG Structure from Known Poses (robust triangulation) 6/12 ---"

$OPENMVG_BIN_PATH/openMVG_main_ComputeStructureFromKnownPoses -i $REC_DIR/sfm_data.bin -m $MATCHES_DIR -f $MATCHES_DIR matches.f.bin -o $REC_DIR robust.bin

 

echo "--- OpenMVG Compute SfM Data Color 7/12 ---"

$OPENMVG_BIN_PATH/openMVG_main_ComputeSfM_DataColor -i $REC_DIR/robust.bin -o $REC_DIR robust_colorized.ply

 

echo "--- OpenMVG to OpenMVS 8/12 ---"

cd $OPENMVG_OUT_PATH/reconstruction_incremental

$OPENMVG_BIN_PATH/openMVG_main_openMVG2openMVS -i sfm_data.bin -o scene.mvs

 

echo "--- OpenMVS: Dense Point-Cloud Reconstruction 9/12 ---"

$OPENMVS_BIN_PATH/DensifyPointCloud scene.mvs

 

echo "--- OpenMVS: Rough Mesh Reconstruction 10/12 ---"

$OPENMVS_BIN_PATH/ReconstructMesh scene_dense.mvs

# $OPENMVS_BIN_PATH/ReconstructMesh -d 4 scene_dense.mvs

 

echo "--- OpenMVS: Mesh Refinement 11/12 ---"

$OPENMVS_BIN_PATH/RefineMesh --resolution-level=4 scene_mesh.mvs

# $OPENMVS_BIN_PATH/RefineMesh scene_mesh.mvs

 

echo "--- OpenMVS: Mesh Texturing 12/12 ---"

$OPENMVS_BIN_PATH/TextureMesh scene_dense_mesh.mvs

cd

 

echo "--- Done ---"

 

 

相关参数

 

对脚本中的部分参数作些说明:

  • -f $FOCAL_LENGTH

在第一步,如果图像的EXIF信息缺失或相机型号不在数据库列表中,则需要手动设置焦距,粗略的计算方法为:图像长边值乘以1.2,比如1024*768的图像数据集,FOCAL_LENGTH=1228.8(1024*1.2)

 

 

 

最后的结果

 

在图片文件夹下的out中,复制出

scene_dense_mesh_texture.ply

和scene_dense_mesh_texture.png

后可以用MeshLab查看

 

 

 

供参考的博客

http://leohope.com/%E8%A7%A3%E9%97%AE%E9%A2%98/2018/08/03/openmvg-openmvs/

你可能感兴趣的:(OpenMVG + OpenMVS的配置与使用)