1.CUDA和CUDNN安装
>> wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
>> sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
>> wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-wsl-ubuntu-11-7-local_11.7.1-1_amd64.deb
>> sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.1-1_amd64.deb
>> sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/
>> sudo apt-get update
>> sudo apt-get -y install cuda
>> tar -xf cudnn-linux-x86_64-8.9.2.26_cuda11-archive.tar.xz
>> sudo cp cudnn-linux-x86_64-8.9.2.26_cuda11-archive/include/*cudnn.h /usr/local/cuda/include/
>> sudo cp cudnn-linux-x86_64-8.9.2.26_cuda11-archive/lib/libcudnn* /usr/local/cuda/lib64
>> sudo chmod a+r /usr/local/lib64/libcudnn*
[3] 添加系统环境变量(.zshrc或.bashrc)
export CUDA_PATH = /usr/local/cuda
export CUDA_BIN = /usr/local/cuda/bin
export PATH = $PATH ::$CUDA_PATH : $CUDA_BIN
>> source ~/.zshrc
>> source ~/.bashrc
>> nvcc --version
nvcc: NVIDIA ( R) Cuda compiler driver
Copyright ( c) 2005 -2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7 , V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0
2.安装依赖库
2.1 apt安装依赖库
sudo apt-get -y install git cmake libpng-dev libjpeg-dev libtiff-dev libglu1-mesa-dev
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
sudo apt-get install libglfw3-dev
2.2 OpenCV安装
3.OpenMVS编译
>> git clone https://github.com/cdcseacave/VCG.git vcglib
>> cmake .. -DVCG_ROOT = [ VCG源码路径] /vcglib -DCMAKE_BUILD_TYPE = Release
.
├── CMakeCache.txt
├── CMakeFiles
│ ├── 3.16 .3
│ ├── 3.27 .0-rc3
│ ├── CMakeConfigureLog.yaml
│ ├── CMakeDirectoryInformation.cmake
│ ├── CMakeOutput.log
│ ├── CMakeRuleHashes.txt
│ ├── CMakeScratch
│ ├── CMakeTmp
│ ├── Export
│ ├── FindOpenMP
│ ├── Makefile.cmake
│ ├── Makefile2
│ ├── TargetDirectories.txt
│ ├── cmake.check_cache
│ ├── pkgRedirects
│ ├── progress.marks
│ └── uninstall.dir
├── CTestTestfile.cmake
├── ConfigLocal.h
├── Makefile
├── Modules
│ ├── FindBREAKPAD.cmake
│ ├── FindEigen3.cmake
│ └── FindVCG.cmake
├── OpenMVSConfig.cmake
├── OpenMVSConfigVersion.cmake
├── Templates
│ ├── ConfigLocal.h.in
│ ├── OpenMVSConfig.cmake.in
│ └── cmake_uninstall.cmake.in
├── Utils.cmake
├── apps
│ ├── CMakeFiles
│ ├── DensifyPointCloud
│ ├── InterfaceCOLMAP
│ ├── InterfaceMVSNet
│ ├── InterfaceMetashape
│ ├── InterfacePolycam
│ ├── Makefile
│ ├── ReconstructMesh
│ ├── RefineMesh
│ ├── Tests
│ ├── TextureMesh
│ ├── TransformScene
│ ├── Viewer
│ └── cmake_install.cmake
├── bin
│ ├── DensifyPointCloud
│ ├── InterfaceCOLMAP
│ ├── InterfaceMVSNet
│ ├── InterfaceMetashape
│ ├── InterfacePolycam
│ ├── ReconstructMesh
│ ├── RefineMesh
│ ├── Tests
│ ├── TextureMesh
│ ├── TransformScene
│ └── Viewer
├── cmake_install.cmake
├── cmake_uninstall.cmake
├── docs
│ ├── CMakeFiles
│ ├── Makefile
│ └── cmake_install.cmake
├── lib
│ ├── libCommon.a
│ ├── libIO.a
│ ├── libMVS.a
│ ├── libMath.a
│ └── pyOpenMVS.so
└── libs
├── CMakeFiles
├── Common
├── IO
├── MVS
├── Makefile
├── Math
└── cmake_install.cmake
4.效果测试
4.0 测试数据
4.1 稠密点云重建(可选项)
当场景部分缺失时,稠密点云重建模块可以估算一个稠密点云来恢复它们,默认采用patch匹配方法:
>> ./bin/DensifyPointCloud -w [ openMVS_sample路径] /mvs-data scene.mvs
使用meshlab打开点云结果scene_dense.ply
4.2 粗略网格重建
>> ./bin/ReconstructMesh -w [ openMVS_sample] /mvs-data scene_dense.mvs -p scene_dense.ply
使用meshlab打开网格生成结果scene_dense_mesh.ply
:
4.3 网格细化(可选项)
从点云获取到的网格可以进一步细化,进而恢复所有好的细节,更有甚者,恢复更大缺失的部分: (a) 细化由稀疏点云获取到的网格:
>> ./bin/RefineMesh -w [ openMVS_sample] /mvs-data scene.mvs -m scene_dense_mesh.ply -o scene_sparse_mesh_refine.mvs
看一下结果: (b) 细化由稠密点云获取到的网格:
>> ./bin/RefineMesh -w [ openMVS_sample] /mvs-data scene_dense.mvs -m scene_dense_mesh.ply -o scene_dense_mesh_refine.mvs
看一下效果:
4.4 网格纹理化
>> ./bin/TextureMesh -w [ openMVS_sample] /mvs-data scene_dense.mvs -m scene_dense_mesh_refine.ply -o scene_dense_mesh_refine_texture.mvs
看一下结果:
5.参考资料
[1] OpenMVS详细安装教程(ubuntu18.04) [2] OpenMVS [3] openMVS_sample