ubuntu20.04中使用openMVG和openMVS进行三维重建
需要指定相机焦距-f,大致可以由图像长乘以1.2估计得到,例如图像长宽为1280×720,则焦距估计为1280×1.2=1536。(或者可以点击图像属性看,一般自己拍的能显示焦距,网图的话可能就没有这个信息)
openMVG_main_SfMInit_ImageListing -i /home/zll/restruct/picture -o /home/zll/restruct/match -f 4800 openMVG_main_ComputeFeatures -i /home/zll/restruct/match/sfm_data.json -o /home/zll/restruct/match -m SIFT openMVG_main_PairGenerator -i /home/zll/restruct/match/sfm_data.json -o /home/zll/restruct/match/pairs.bin openMVG_main_ComputeMatches -i /home/zll/restruct/match/sfm_data.json -p /home/zll/restruct/match/pairs.bin -o /home/zll/restruct/match/matches.putatives.bin openMVG_main_GeometricFilter -i /home/zll/restruct/match/sfm_data.json -m /home/zll/restruct/match/matches.putatives.bin -o /home/zll/restruct/match/matches.f.bin openMVG_main_SfM --sfm_engine INCREMENTAL --input_file /home/zll/restruct/match/sfm_data.json --match_dir /home/zll/restruct/match --output_dir /home/zll/restruct/reconstruction openMVG_main_ComputeSfM_DataColor -i /home/zll/restruct/reconstruction/sfm_data.bin -o /home/zll/restruct/reconstruction/colorized.ply
openMVS可以很好地与openMVG对接,其主要的作用是进行稠密点云重建、网格重建与纹理映射。-d 4与–resolution-level=4的作用是为了简化运算,减小了重建的网格数量与精细程度.
将在同级目录下新建一个文件夹,将 sfm_data.bin复制进去,再进行以下操作
openMVG_main_openMVG2openMVS -i sfm_data.bin -o scene.mvs
/usr/local/bin/OpenMVS/DensifyPointCloud scene.mvs
/usr/local/bin/OpenMVS/ReconstructMesh scene_dense.mvs
/usr/local/bin/OpenMVS/RefineMesh --resolution-level=4 scene_dense_mesh.mvs
/usr/local/bin/OpenMVS/TextureMesh scene_dense_mesh_refine.mvs --decimate 0.5
/usr/local/bin/OpenMVS/Viewer scene_dense_mesh_refine_texture.mvs
效果: