三维重构流程 openMVG + openMVS + meshlab

0 reference:

https://blog.csdn.net/baidu_40840693/article/details/84777589

https://blog.csdn.net/shanwenkang/article/details/103196001

[1] https://leohope.com/%E8%A7%A3%E9%97%AE%E9%A2%98/2018/03/06/compare-re3d-system/
[2] https://www.itread01.com/content/1543864993.html
[3] http://www.ishenping.com/ArtInfo/3737460.html
[4] https://blog.csdn.net/weixin_41631970/article/details/87893750
[5] https://www.youtube.com/watch?v=ELHOjC_V-FE&t=1134s

1 Install

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

1.1 openmvg

  • git clone --recursive https://github.com/openMVG/openMVG.git
  • mkdir openMVG_Build && cd openMVG_Build
  • cmake -DCMAKE_BUILD_TYPE=RELEASE ../openMVG/src/
  • cmake --build . --target install

1.2 openmvs

  • sudo apt-get update -qq && sudo apt-get install -qq
  • sudo apt-get -y install build-essential git mercurial cmake libpng-dev libjpeg-dev libtiff-dev libglu1-mesa-dev libxmu-dev libxi-dev
  • hg clone https://bitbucket.org/eigen/eigen#3.2
  • mkdir eigen_build && cd eigen_build
  • cmake . ../eigen
  • make && sudo make install
  • sudo apt-get -y install libboost-iostreams-dev libboost-program-options-dev libboost-system-dev libboost-serialization-dev
  • sudo apt-get -y install libcgal-dev libcgal-qt5-dev
  • git clone https://github.com/cdcseacave/VCG.git vcglib
  • sudo apt-get -y install libatlas-base-dev libsuitesparse-dev
  • git clone https://github.com/ceres-solver/ceres-solver ceres-solver
  • mkdir ceres_build && cd ceres_build
  • cmake . ../ceres-solver/ -DMINIGLOG=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
  • make -j2 && sudo make install
  • sudo apt-get -y install freeglut3-dev libglew-dev libglfw3-dev
     
  • git clone https://github.com/cdcseacave/openMVS.git openMVS
    mkdir openMVS_build && cd openMVS_build
    cmake . ../openMVS -DCMAKE_BUILD_TYPE=Release -DVCG_ROOT="$~/openMVS/vcglib"
     
  •  

2 reconstruction

2.1 openMVG

测试图片如下:https://github.com/openMVG/ImageDataset_SceauxCastle。首先切换到图片目录后开始执行指令,需要指定相机焦距-f,大致可以由图像长乘以1.2估计得到,例如图像长宽为1280×720,则焦距估计为1280×1.2=1536。

openMVG_main_SfMInit_ImageListing -i <images-dir> -f focal_length -o <output-dir>
openMVG_main_ComputeFeatures -i <output-dir>/sfm_data.json -o <output-dir>
openMVG_main_ComputeMatches -i <output-dir>/sfm_data.json  -o <output-dir>
openMVG_main_IncrementalSfM -i <output-dir>/sfm_data.json -m <output-dir> -o <output-dir>/reconstruction
openMVG_main_ComputeSfM_DataColor -i <output-dir>/reconstruction/sfm_data.bin -o  <output-dir>/colored.ply
openMVG_main_ComputeStructureFromKnownPoses -i <output-dir>/reconstrution/sfm_data.bin -m . -o <output-dir>/reconstruction/robust.bin -f <output-dir>/matches.f.bin
openMVG得到的稀疏点云结果可以用meshlab打开:

三维重构流程 openMVG + openMVS + meshlab

2.2 openMVS

openMVS可以很好地与openMVG对接,其主要的作用是进行稠密点云重建、网格重建与纹理映射。-d 4与–resolution-level=4的作用是为了简化运算,减小了重建的网格数量与精细程度

openMVG_main_openMVG2openMVS -i <output-dir>/reconstruction/robust.bin -o scene.mvs
DensifyPointCloud scene.mvs
ReconstructMesh -d 4 scene_dense.mvs
RefineMesh --resolution-level=4 scene_dense_mesh.mvs
TextureMesh scene_dense_mesh_refine.mvs
三维重构流程 openMVG + openMVS + meshlab