常见开源多视图立体算法运行脚本记录

1. MVE

项目主页 https://www.gcc.tu-darmstadt.de/home/proj/mve/

Github地址 https://github.com/simonfuhrmann/mve

#!/bin/bash

workspace_path=/root/test_result/mve_result
image_dir=${workspace_path}/${1}
scene_dir=${workspace_path}/${2}
mve=/root/misc_codes/mve/apps

maxpixel=20000000

intrinsic_fp="2759.48,0,0,0.4950,0.4916,0.9983" # fountain-p11
intrinsic_tp="1520.40,0,0,0.4724,0.5143,0.9964" # temple
intrinsic_eth_pipe="3430.27,0,0,0.5015,0.4969,1.0003" # eth3d pipes
intrinsic_dtu="2892.33,0,0,0.5145,0.5159,1.0032" # dtu dataset
intrinsic_tanks=""
intrinsic=${intrinsic_tanks}
# --init-intrinsics=${intrinsic} \
${mve}/makescene/makescene --original \
        --images-only ${image_dir} \
        --max-pixels=${maxpixel} \
        ${scene_dir} &&

# --fixed-intrinsics \
${mve}/sfmrecon/sfmrecon --max-pixels=${maxpixel} \
        --verbose-ba ${scene_dir} &&

${mve}/dmrecon/dmrecon --neighbors=9 \
        --scale=0 \
        --max-pixels=${maxpixel} \
        --local-neighbors=6 \
        --keep-dz \
        --progress=fancy ${scene_dir} &&

${mve}/scene2pset/scene2pset -F0 ${scene_dir} ${scene_dir}/pset-L0.ply &&

${mve}/fssrecon/fssrecon ${scene_dir}/pset-L0.ply ${scene_dir}/surface-L0.ply &&

${mve}/meshclean/meshclean --threshold=8.0 --delete-scale ${scene_dir}/surface-L0.ply ${scene_dir}/surface-clean.ply

2. SMVS

项目主页 https://www.gcc.tu-darmstadt.de/home/proj/smvs/smvs.en.jsp

Github地址 https://github.com/flanggut/smvs

#!/bin/bash

workspace_path=/root/test_result/smvs_result
image_dir=${workspace_path}/${1}
scene_dir=${workspace_path}/${2}
mve=/root/misc_codes/mve/apps
smvs=/root/misc_codes/smvs/smvsrecon

maxpixel=2000000

intrinsic_fp="2759.48,0,0,0.4950,0.4916,0.9983" # fountain-p11
intrinsic_tp="1520.40,0,0,0.4724,0.5143,0.9964" # temple
intrinsic_eth_pipe="3430.27,0,0,0.5015,0.4969,1.0003" # eth3d pipes
intrinsic_dtu="2892.33,0,0,0.5145,0.5159,1.0032" # dtu dataset
intrinsic_tanks="2304.00,0,0,0.5,0.5,1.0000" # Manually set intrinsic
intrinsic=${intrinsic_fp}

${mve}/makescene/makescene --original \
        --images-only ${image_dir} \
        --max-pixels=${maxpixel} \
        --init-intrinsics=${intrinsic} \
        ${scene_dir} &&

${mve}/sfmrecon/sfmrecon --max-pixels=${maxpixel} \
        --fixed-intrinsics \
        --verbose-ba ${scene_dir} &&

${smvs} ${scene_dir} &&

${mve}/fssrecon/fssrecon ${scene_dir}/pset-L0.ply ${scene_dir}/surface-L0.ply &&

${mve}/meshclean/meshclean --threshold=8.0 --delete-scale \
       ${scene_dir}/surface-L0.ply \
       ${scene_dir}/surface-clean.ply

3. openMVG+openMVS

多视图立体几何基础库 openMVG https://github.com/openMVG/openMVG

稠密重建库 openMVS https://github.com/cdcseacave/openMVS

#!/bin/bash

workspace_path=/root/test_result/openmvs_result/${1}
image_dir=${workspace_path}/images
recon_dir=${workspace_path}/reconstruct
match_dir=${recon_dir}/matches
openmvg=/root/misc_codes/openMVG/openmvg-bin/bin
openmvs=/root/misc_codes/openMVS/openmvs-build/bin

maxres=6400
minres=480

intrinsic_fp="2759.48;0;1520.69;0;2764.16;1006.81;0;0;1" # fountain-p11
intrinsic_tp="1520.40;0;302.32;0;1525.90;246.87;0;0;1" # temple
intrinsic_eth_pipe="3430.27;0;3119.2;0;3429.23;2057.75;0;0;1" # eth3d pipes
intrinsic_dtu="2892.33;0;823.21;0;2883.17;619.07;0;0;1" # for all dtu datasets
intrinsic_tanks="2304.00;0;960;0;2304.00;540;0;0;1" # Manually set intrinsic
intrinsic=${intrinsic_dtu}

mkdir ${recon_dir} && mkdir ${match_dir}
${openmvg}/openMVG_main_SfMInit_ImageListing -i ${image_dir} -o ${match_dir} \
        --camera_model 1 \
        --intrinsics ${intrinsic} \
        --group_camera_model 1

${openmvg}/openMVG_main_ComputeFeatures -i ${match_dir}/sfm_data.json \
        --outdir ${match_dir} \
        --describerPreset HIGH

${openmvg}/openMVG_main_ComputeMatches -i ${match_dir}/sfm_data.json \
        --out_dir ${match_dir} \
        --nearest_matching_method ANNL2

${openmvg}/openMVG_main_IncrementalSfM -i ${match_dir}/sfm_data.json \
        --matchdir ${match_dir} \
        --outdir ${recon_dir} \
        --camera_model 1 \
        --refineIntrinsics NONE
        # --refineIntrinsics "ADJUST_FOCAL_LENGTH|ADJUST_PRINCIPAL_POINT"

${openmvg}/openMVG_main_ComputeSfM_DataColor -i ${recon_dir}/sfm_data.bin \
        -o ${recon_dir}/colorized.ply

${openmvg}/openMVG_main_ComputeStructureFromKnownPoses -i ${recon_dir}/sfm_data.bin \
        --match_dir ${match_dir} \
        --match_file ${match_dir}/matches.f.bin \
        --output_file ${recon_dir}/robust.bin

${openmvg}/openMVG_main_ComputeSfM_DataColor -i ${recon_dir}/robust.bin \
        -o ${recon_dir}/robust_colorized.ply

# outfile is the file name to save converted result
# outdir is the path to save undistorted images
${openmvg}/openMVG_main_openMVG2openMVS --sfmdata ${recon_dir}/sfm_data.bin \
        --outfile ${recon_dir}/scene.mvs \
        --outdir ${recon_dir}

${openmvs}/DensifyPointCloud --working-folder ${recon_dir} \
        -i ${recon_dir}/scene.mvs \
        --max-resolution=${maxres} \
        --min-resolution=${minres} \
        --number-views=6
# free-space-support is for textureless region
${openmvs}/ReconstructMesh --working-folder ${recon_dir} \
        -i ${recon_dir}/scene_dense.mvs \
        --free-space-support 1

${openmvs}/RefineMesh --working-folder ${recon_dir} \
        -i ${recon_dir}/scene_dense_mesh.mvs \
        --min-resolution ${minres} \
        --max-views 9 \
        --scales 5 \
        --planar-vertex-ratio 5

${openmvs}/TextureMesh --working-folder ${recon_dir} \
        -i ${recon_dir}/scene_dense_mesh.mvs \
        --min-resolution ${minres} \
        --cost-smoothness-ratio 0.3

4. COLMAP

项目主页 https://demuc.de/colmap/

Github地址 https://github.com/colmap/colmap

#!/bin/bash

colmap=/root/misc_codes/colmap/colmap-bin/bin/colmap
workspace=/root/test_result/colmap_result/${1}
images=${workspace}/images
database_path=${workspace}/database.db
sparse_path=${workspace}/sparse
dense_path=${workspace}/dense
maxsize=2000
maxfeature=8192

intrinsic_fp="2759.48,2764.16,1520.69,1006.81" # fountain-p11
intrinsic_tp="1520.40,1525.90,302.32,246.87" # temple
intrinsic_dtu="2892.33,2883.17,823.21,619.07" # all dtu dataset
intrinsic_tanks=""
intrinsic=${intrinsic_dtu}

# --ImageReader.camera_params ${intrinsic} \
${colmap} feature_extractor \
        --database_path ${database_path} \
        --image_path ${images} \
        --ImageReader.camera_model PINHOLE \
        --ImageReader.camera_params ${intrinsic} \
        --ImageReader.single_camera 1 \
        --SiftExtraction.max_image_size ${maxsize} \
        --SiftExtraction.max_num_features ${maxfeature}

${colmap} exhaustive_matcher --database_path ${database_path} \
        --SiftMatching.guided_matching 0

mkdir ${sparse_path}
${colmap} mapper --database_path ${database_path} \
        --image_path ${images} \
        --output_path ${sparse_path} \
        --Mapper.ba_refine_principal_point false

mkdir ${dense_path} &&
${colmap} image_undistorter --image_path ${images} \
        --input_path ${sparse_path}/0 \
        --output_path ${dense_path} \
        --output_type COLMAP \
        --max_image_size ${maxsize} &&

${colmap} patch_match_stereo --workspace_path ${dense_path} \
        --workspace_format COLMAP \
        --PatchMatchStereo.max_image_size ${maxsize} \
        --PatchMatchStereo.window_radius 9 \
        --PatchMatchStereo.geom_consistency 1 \
        --PatchMatchStereo.filter_min_ncc 0.07 &&

${colmap} stereo_fusion --workspace_path ${dense_path} \
        --input_type geometric \
        --output_path ${dense_path}/fused.ply &&

${colmap} poisson_mesher --input_path ${dense_path}/fused.ply \
        --output_path ${dense_path}/meshed-poisson.ply

${colmap} delaunay_mesher --input_path ${dense_path} \
        --input_type dense \
        --output_path ${dense_path}/meshed-delaunay.ply

colmap recon script(from tanks and temples)

#!/bin/bash

# ----------------------------------------------------------------------------
# -                   TanksAndTemples Website Toolbox                        -
# -                    http://www.tanksandtemples.org                        -
# ----------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2017
# Arno Knapitsch <arno.knapitsch@gmail.com >
# Jaesik Park <syncle@gmail.com>
# Qian-Yi Zhou <Qianyi.Zhou@gmail.com>
# Vladlen Koltun <vkoltun@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ----------------------------------------------------------------------------
#
# This script generates a COLMAP reconstruction from a numbe rof input imagess
# Usage: sh get_colmap_reconstruction.sh <COLMAP-exe-directory> <image-set-directory> <project-directory>

colmap_folder=$1/
iname=$2/
outf=$3/

DATABASE=${outf}sample_reconstruction.db

PROJECT_PATH=${outf}
mkdir -p ${PROJECT_PATH}
mkdir -p ${PROJECT_PATH}/images

cp -n ${iname}*.jpg ${PROJECT_PATH}/images

${colmap_folder}/colmap feature_extractor \
    --database_path ${DATABASE} \
    --image_path ${PROJECT_PATH}/images \
    --ImageReader.camera_model RADIAL \
    --ImageReader.single_camera 1 \
    --SiftExtraction.use_gpu 1
    
${colmap_folder}/colmap exhaustive_matcher \
    --database_path ${DATABASE} \
    --SiftMatching.use_gpu 1 
    
mkdir ${PROJECT_PATH}/sparse
${colmap_folder}/colmap mapper \
    --database_path ${DATABASE} \
    --image_path ${PROJECT_PATH}/images \
    --output_path ${PROJECT_PATH}/sparse

mkdir ${PROJECT_PATH}/dense

${colmap_folder}/colmap image_undistorter \
    --image_path ${PROJECT_PATH}/images \
    --input_path ${PROJECT_PATH}/sparse/0/ \
    --output_path ${PROJECT_PATH}/dense \
    --output_type COLMAP --max_image_size 1500

${colmap_folder}/colmap patch_match_stereo \
    --workspace_path $PROJECT_PATH/dense \
    --workspace_format COLMAP \
    --PatchMatchStereo.geom_consistency true

${colmap_folder}/colmap stereo_fusion \
    --workspace_path $PROJECT_PATH/dense \
    --workspace_format COLMAP \
    --input_type geometric \
    --output_path $PROJECT_PATH/dense/fused.ply

上述几个脚本都放到了我的 Github 上,地址是:https://github.com/philleer/program_test/tree/mvs_script

Ubuntu 18.04 LTS 测试有效,欢迎补充。


Update: 2022.01.07
更改了脚本存放地址,新地址在 https://github.com/philleer/mvs_script

(全文完)


参考资料

[1] TU DarmstadtInformatikGCCProjects & Code https://www.gcc.tu-darmstadt.de/home/proj/index.en.jsp
[2] OpenMVG (open Multiple View Geometry) https://github.com/openMVG/openMVG
[3] OpenMVS: open Multi-View Stereo reconstruction library https://github.com/cdcseacave/openMVS
[4] TanksAndTemples script example https://raw.githubusercontent.com/IntelVCL/TanksAndTemples/master/python_toolbox/get_colmap_reconstruction.sh

本文作者 :phillee
发表日期 :2020年6月25日
本文链接https://www.cnblogs.com/phillee/p/13094478.html
版权声明 :自由转载-非商用-非衍生-保持署名(创意共享3.0许可协议/CC BY-NC-SA 3.0)。转载请注明出处!
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。

感谢您的支持

¥ 打赏

微信支付

posted @ 2020-06-25 01:11  coffee_tea_or_me  阅读(748)  评论(0编辑  收藏  举报