当前位置: 首页 > news >正文

OpenMVS 的编译与运行

Title: OpenMVS 的编译与运行


文章目录

  • I. 编译与准备
    • 1. 获得源码
    • 2. wiki
    • 3. 退出 Conda 环境
    • 4. 编译
    • 5. 数据准备
  • II. 命令了解
    • 1. 稠密重建 DensifyPointCloud
    • 2. 曲面重建 ReconstructMesh
    • 3. 网格优化 RefineMesh
    • 4. 纹理贴图 TextureMesh
  • III. 命令运行
    • 1. 运行稠密重建
    • 2. 运行网格重建
    • 3. 运行网格优化
    • 4. 运行纹理贴图
  • IV. 简单结果


简单记录一下,备忘.

I. 编译与准备

1. 获得源码

git clone https://github.com/cdcseacave/openMVS.git

切换分支:

git checkout develop

一些 bug 在 develop 版本中修正了, 比如程序自己 “killed” 退出.

2. wiki

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

3. 退出 Conda 环境

隔离 Conda 环境与系统库, 不然容易冲突. 原先在 docker 容器的 conda 虚拟环境中编译, 版本冲突较多.

conda deactivate

4. 编译

makedir openMVS_build
cd openMVS_build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j4
make install

说明:

在 docker 的 ubuntu24 镜像下, 没有能够生成 Viewer. cmake 步骤中提示 -- Can't find GLAD. Continuing without it. 尝试好多次都没能配置成功.
Windows 下应该更容易生成 Viewer.

5. 数据准备

参考博文 https://blog.csdn.net/yangyu0515/article/details/129235389

.
|-- images
|   |-- 00000.jpg
|   |-- 00001.jpg
|   |-- 00002.jpg
|   |-- 00003.jpg
|   |-- 00004.jpg
|   |-- 00005.jpg
|   |-- 00006.jpg
|   |-- 00007.jpg
|   |-- 00008.jpg
|   |-- 00009.jpg
|   `-- 00010.jpg
`-- scene.mvs

II. 命令了解

1. 稠密重建 DensifyPointCloud

../openMVS_build/bin/DensifyPointCloud -h
17:14:59 [App     ] OpenMVS x64 v2.3.0
17:14:59 [App     ] Build date: May  7 2025, 16:53:39
17:14:59 [App     ] CPU: Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz (64 cores)
17:14:59 [App     ] RAM: 31.05GB Physical Memory 9.31GB Virtual Memory
17:14:59 [App     ] OS: Linux 5.14.0-1059-oem (x86_64)
17:14:59 [App     ] Disk: 416.64GB (881.87GB) space
17:14:59 [App     ] SSE & AVX compatible CPU & OS detected
17:14:59 [App     ] Command line: DensifyPointCloud -h
17:14:59 [App     ] Available options:Generic options:-h [ --help ]                         produce this help message-w [ --working-folder ] arg           working directory (default current directory)-c [ --config-file ] arg (=DensifyPointCloud.cfg)file name containing program options--archive-type arg (=-1)              project archive type: -1-interface, 0-text, 1-binary, 2-compressed binary--process-priority arg (=-1)          process priority (below normal by default)--max-threads arg (=0)                maximum number of threads (0 for using all available cores)-v [ --verbosity ] arg (=2)           verbosity levelDensify options:-i [ --input-file ] arg               input filename containing camera poses and image list-p [ --pointcloud-file ] arg          sparse point-cloud with views file nameto densify (overwrite existing point-cloud)-m [ --mask-path ] arg                path to folder containing mask images with '.mask.png' extension-o [ --output-file ] arg              output filename for storing the dense point-cloud (optional)--view-neighbors-file arg             input filename containing the list of views and their neighbors (optional)--output-view-neighbors-file arg      output filename containing the generated list of views and their neighbors--resolution-level arg (=1)           how many times to scale down the imagesbefore point-cloud computation--max-resolution arg (=2560)          do not scale images higher than this resolution--min-resolution arg (=640)           do not scale images lower than this resolution--sub-resolution-levels arg (=2)      number of patch-match sub-resolution iterations (0 - disabled)--number-views arg (=5)               number of views used for depth-map estimation (0 - all neighbor views available)--number-views-fuse arg (=2)          minimum number of images that agrees with an estimate during fusion in orderto consider it inlier (<2 - only merge depth-maps)--ignore-mask-label arg (=-1)         label value to ignore in the image mask, stored in the MVS scene or next to each image with '.mask.png' extension (<0 - disabled)--iters arg (=3)                      number of patch-match iterations--geometric-iters arg (=2)            number of geometric consistent patch-match iterations (0 - disabled)--estimate-colors arg (=2)            estimate the colors for the dense point-cloud (0 - disabled, 1 - final, 2- estimate)--estimate-normals arg (=2)           estimate the normals for the dense point-cloud (0 - disabled, 1 - final, 2- estimate)--estimate-scale arg (=0)             estimate the point-scale for the dense point-cloud (scale multiplier, 0 - disabled)--estimate-segmentation arg (=0)      estimate segmentation of the dense point-cloud based on the image segmentation masks; num views to agree (0 - disabled, <0 - only segmentation)--sub-scene-area arg (=0)             split the scene in sub-scenes such thateach sub-scene surface does not exceed the given maximum sampling area (0 - disabled)--sample-mesh arg (=0)                uniformly samples points on a mesh (0 -disabled, <0 - number of points, >0 - sample density per square unit)--fusion-mode arg (=0)                depth-maps fusion mode (-2 - fuse disparity-maps, -1 - export disparity-maps only, 0 - depth-maps & fusion, 1 - export depth-maps only)--fusion-filter arg (=2)              filter used to fuse the depth-maps (0 -merge, 1 - fuse, 2 - dense-fuse)--postprocess-dmaps arg (=0)          flags used to filter the depth-maps after estimation (0 - disabled, 1 - remove-speckles, 2 - fill-gaps, 4 - adjust-confidence)--filter-point-cloud arg (=0)         filter dense point-cloud based on visibility (0 - disabled)--export-number-views arg (=0)        export points with >= number of views (0 - disabled, <0 - save MVS project too)--roi-border arg (=0)                 add a border to the region-of-interest when cropping the scene (0 - disabled, >0 - percentage, <0 - absolute)--estimate-roi arg (=2)               estimate and set region-of-interest (0 - disabled, 1 - enabled, 2 - adaptive)--crop-to-roi arg (=1)                crop scene using the region-of-interest--remove-dmaps arg (=0)               remove depth-maps after fusion--tower-mode arg (=4)                 add a cylinder of points in the center of ROI; scene assume to be Z-up oriented (0 - disabled, 1 - replace, 2 - append, 3 - select neighbors, 4 - select neighbors & append, <0 - force tower mode)--normalize-coordinates arg (=0)      normalize scene coordinates and output the inverse transform to file (0 - disabled, 1 - center, 2 - center & scale17:14:59 [App     ] MEMORYINFO: {
17:14:59 [App     ] 	VmPeak:	  182316 kB
17:14:59 [App     ] 	VmSize:	  182256 kB
17:14:59 [App     ] } ENDINFO

2. 曲面重建 ReconstructMesh

../openMVS_build/bin/ReconstructMesh -h
17:17:23 [App     ] OpenMVS x64 v2.3.0
17:17:23 [App     ] Build date: May  7 2025, 16:53:39
17:17:23 [App     ] CPU: Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz (64 cores)
17:17:23 [App     ] RAM: 31.05GB Physical Memory 9.31GB Virtual Memory
17:17:23 [App     ] OS: Linux 5.14.0-1059-oem (x86_64)
17:17:23 [App     ] Disk: 416.64GB (881.87GB) space
17:17:23 [App     ] SSE & AVX compatible CPU & OS detected
17:17:23 [App     ] Command line: ReconstructMesh -h
17:17:23 [App     ] Available options:Generic options:-h [ --help ]                         produce this help message-w [ --working-folder ] arg           working directory (default current directory)-c [ --config-file ] arg (=ReconstructMesh.cfg)file name containing program options--export-type arg (=ply)              file type used to export the 3D scene (ply or obj)--archive-type arg (=4294967295)      project archive type: -1-interface, 0-text, 1-binary, 2-compressed binary--process-priority arg (=-1)          process priority (below normal by default)--max-threads arg (=0)                maximum number of threads (0 for using all available cores)-v [ --verbosity ] arg (=2)           verbosity levelReconstruct options:-i [ --input-file ] arg               input filename containing camera poses and image list-p [ --pointcloud-file ] arg          dense point-cloud with views file name to reconstruct (overwrite existing point-cloud)-o [ --output-file ] arg              output filename for storing the mesh-d [ --min-point-distance ] arg (=1.5)minimum distance in pixels between the projection of two 3D points to considerthem different while triangulating (0 -disabled)--integrate-only-roi arg (=0)         use only the points inside the ROI--constant-weight arg (=1)            considers all view weights 1 instead ofthe available weight-f [ --free-space-support ] arg (=0)  exploits the free-space support in order to reconstruct weakly-representedsurfaces--thickness-factor arg (=1)           multiplier adjusting the minimum thickness considered during visibility weighting--quality-factor arg (=1)             multiplier adjusting the quality weightconsidered during graph-cutClean options:--decimate arg (=1)                   decimation factor in range (0..1] to beapplied to the reconstructed surface (1- disabled)--target-face-num arg (=0)            target number of faces to be applied tothe reconstructed surface. (0 - disabled)--remove-spurious arg (=20)           spurious factor for removing faces withtoo long edges or isolated components (0 - disabled)--remove-spikes arg (=1)              flag controlling the removal of spike faces--close-holes arg (=30)               try to close small holes in the reconstructed surface (0 - disabled)--smooth arg (=2)                     number of iterations to smooth the reconstructed surface (0 - disabled)--edge-length arg (=0)                remesh such that the average edge length is this size (0 - disabled)--roi-border arg (=0)                 add a border to the region-of-interest when cropping the scene (0 - disabled, >0 - percentage, <0 - absolute)--crop-to-roi arg (=1)                crop scene using the region-of-interes17:17:23 [App     ] MEMORYINFO: {
17:17:23 [App     ] 	VmPeak:	  179168 kB
17:17:23 [App     ] 	VmSize:	  179108 kB
17:17:23 [App     ] } ENDINFO

3. 网格优化 RefineMesh

../openMVS_build/bin/RefineMesh -h
17:21:23 [App     ] OpenMVS x64 v2.3.0
17:21:23 [App     ] Build date: May  7 2025, 16:53:39
17:21:23 [App     ] CPU: Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz (64 cores)
17:21:23 [App     ] RAM: 31.05GB Physical Memory 9.31GB Virtual Memory
17:21:23 [App     ] OS: Linux 5.14.0-1059-oem (x86_64)
17:21:23 [App     ] Disk: 416.64GB (881.87GB) space
17:21:23 [App     ] SSE & AVX compatible CPU & OS detected
17:21:23 [App     ] Command line: RefineMesh -h
17:21:23 [App     ] Available options:Generic options:-h [ --help ]                         produce this help message-w [ --working-folder ] arg           working directory (default current directory)-c [ --config-file ] arg (=RefineMesh.cfg)file name containing program options--export-type arg (=ply)              file type used to export the 3D scene (ply or obj)--archive-type arg (=4294967295)      project archive type: -1-interface, 0-text, 1-binary, 2-compressed binary--process-priority arg (=-1)          process priority (below normal by default)--max-threads arg (=0)                maximum number of threads (0 for using all available cores)-v [ --verbosity ] arg (=2)           verbosity levelRefine options:-i [ --input-file ] arg               input filename containing camera poses and image list-m [ --mesh-file ] arg                mesh file name to refine (overwrite existing mesh)-o [ --output-file ] arg              output filename for storing the mesh--resolution-level arg (=0)           how many times to scale down the imagesbefore mesh refinement--min-resolution arg (=640)           do not scale images lower than this resolution--max-views arg (=8)                  maximum number of neighbor images used to refine the mesh--decimate arg (=0)                   decimation factor in range [0..1] to beapplied to the input surface before refinement (0 - auto, 1 - disabled)--close-holes arg (=30)               try to close small holes in the input surface (0 - disabled)--ensure-edge-size arg (=1)           ensure edge size and improve vertex valence of the input surface (0 - disabled, 1 - auto, 2 - force)--max-face-area arg (=32)             maximum face area projected in any pairof images that is not subdivided (0 - disabled)--scales arg (=2)                     how many iterations to run mesh optimization on multi-scale images--scale-step arg (=0.5)               image scale factor used at each mesh optimization step--alternate-pair arg (=0)             refine mesh using an image pair alternatively as reference (0 - both, 1- alternate, 2 - only left, 3 - only right)--regularity-weight arg (=0.200000003)scalar regularity weight to balance between photo-consistency and regularization terms during mesh optimization--rigidity-elasticity-ratio arg (=0.899999976)scalar ratio used to compute the regularity gradient as a combination ofrigidity and elasticity--gradient-step arg (=45.0499992)     gradient step to be used instead (0 - auto)--planar-vertex-ratio arg (=0)        threshold used to remove vertices on planar patches (0 - disabled)--reduce-memory arg (=1)              recompute some data in order to reduce memory requirement17:21:23 [App     ] MEMORYINFO: {
17:21:23 [App     ] 	VmPeak:	  178968 kB
17:21:23 [App     ] 	VmSize:	  178908 kB
17:21:23 [App     ] } ENDINFO

4. 纹理贴图 TextureMesh

../openMVS_build/bin/TextureMesh -h
17:22:19 [App     ] OpenMVS x64 v2.3.0
17:22:19 [App     ] Build date: May  7 2025, 16:53:39
17:22:19 [App     ] CPU: Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz (64 cores)
17:22:19 [App     ] RAM: 31.05GB Physical Memory 9.31GB Virtual Memory
17:22:19 [App     ] OS: Linux 5.14.0-1059-oem (x86_64)
17:22:19 [App     ] Disk: 416.64GB (881.87GB) space
17:22:19 [App     ] SSE & AVX compatible CPU & OS detected
17:22:19 [App     ] Command line: TextureMesh -h
17:22:19 [App     ] Available options:Generic options:-h [ --help ]                         produce this help message-w [ --working-folder ] arg           working directory (default current directory)-c [ --config-file ] arg (=TextureMesh.cfg)file name containing program options--export-type arg (=ply)              file type used to export the 3D scene (ply, obj, glb or gltf)--archive-type arg (=4294967295)      project archive type: -1-interface, 0-text, 1-binary, 2-compressed binary--process-priority arg (=-1)          process priority (below normal by default)--max-threads arg (=0)                maximum number of threads (0 for using all available cores)-v [ --verbosity ] arg (=2)           verbosity levelTexture options:-i [ --input-file ] arg               input filename containing camera poses and image list-m [ --mesh-file ] arg                mesh file name to texture (overwrite existing mesh)-o [ --output-file ] arg              output filename for storing the mesh--decimate arg (=1)                   decimation factor in range [0..1] to beapplied to the input surface before refinement (0 - auto, 1 - disabled)--close-holes arg (=30)               try to close small holes in the input surface (0 - disabled)--resolution-level arg (=0)           how many times to scale down the imagesbefore mesh refinement--min-resolution arg (=640)           do not scale images lower than this resolution--outlier-threshold arg (=0.0599999987)threshold used to find and remove outlier face textures (0 - disabled)--cost-smoothness-ratio arg (=0.100000001)ratio used to adjust the preference formore compact patches (1 - best quality/worst compactness, ~0 - worst quality/best compactness)--virtual-face-images arg (=0)        generate texture patches using virtual faces composed of coplanar triangles sharing at least this number of views (0 - disabled, 3 - good value)--global-seam-leveling arg (=1)       generate uniform texture patches using global seam leveling--local-seam-leveling arg (=1)        generate uniform texture patch borders using local seam leveling--texture-size-multiple arg (=0)      texture size should be a multiple of this value (0 - power of two)--patch-packing-heuristic arg (=3)    specify the heuristic used when deciding where to place a new patch (0 - best fit, 3 - good speed, 100 - best speed)--empty-color arg (=16744231)         color used for faces not covered by anyimage--sharpness-weight arg (=0.5)         amount of sharpness to be applied on the texture (0 - disabled)--orthographic-image-resolution arg (=0)orthographic image resolution to be generated from the textured mesh - the mesh is expected to be already geo-referenced or at least properly oriented (0 - disabled)--ignore-mask-label arg (=-1)         label value to ignore in the image mask, stored in the MVS scene or next to each image with '.mask.png' extension (-1 - auto estimate mask for lens distortion, -2 - disabled)--max-texture-size arg (=8192)        maximum texture size, split it in multiple textures of this size if needed (0 - unbounded17:22:19 [App     ] MEMORYINFO: {
17:22:19 [App     ] 	VmPeak:	  179196 kB
17:22:19 [App     ] 	VmSize:	  179136 kB
17:22:19 [App     ] } ENDINFO

III. 命令运行

1. 运行稠密重建

../openMVS_build/bin/DensifyPointCloud scene.mvs

生成 scene_dense.mvsscene_dense.ply 稠密点云模型. 其中 scene_dense.mvs 主要描述相机位姿、特征匹配等, 后面的命令中都用同一个 .mvs 文件.

2. 运行网格重建

../openMVS_build/bin/ReconstructMesh -i scene_dense.mvs

生成 scene_dense_mesh.ply 网格重建的三维模型.

3. 运行网格优化

上一步的输出作为下一步的输入, 输入的 .mvs 和 .ply 需要同名. scene_dense.mvs 复制一份为 scene_dense_mesh.mvs.

cp scene_dense.mvs scene_dense_mesh.mvs

直接运行 RefineMesh, 应该电脑内存不够的缘故, 程序自己 “killed” 退出了.

../openMVS_build/bin/RefineMesh -i scene_dense_mesh.mvs

降低精度等级就可以运行, 但是这相当于降采样了, 还不如上一步获得效果好. 这一步会生成 scene_dense_mesh_refine.ply.

../openMVS_build/bin/RefineMesh -i scene_dense_mesh.mvs --resolution-level 1

注意: RefineMesh 只是优化/微调 mesh 三维模型, 不是必须要处理的步骤. 这一步可以跳过.

4. 运行纹理贴图

如果使用网格重建中生成的 scene_dense_mesh.ply 来做纹理贴图, 则直接运行

../openMVS_build/bin/TextureMesh -i scene_dense_mesh.mvs

生成 scene_dense_mesh_texture.plyscene_dense_mesh_texture0.png. 这两个文件放在同一文件夹下, meshlab 打开 scene_dense_mesh_texture.ply 就可获得纹理贴图效果. 注意 conda 虚拟环境也可能引起冲突, 退出虚拟环境即可.

如果使用网格优化中生成 .ply 来做纹理贴图, 还是需要先复制一份 .mvs, 然后再运行纹理贴图命令.

cp scene_dense.mvs scene_dense_mesh_refine.mvs
../openMVS_build/bin/TextureMesh -i scene_dense_mesh_refine.mvs

IV. 简单结果

点云 网格 纹理

版权声明:本文为博主原创文章,遵循 CC 4.0 BY 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/woyaomaishu2/article/details/147773670
本文作者:wzf@robotics_notes

相关文章:

  • 电子电器架构 --- 48V架构的一丢丢事情
  • 2014年写的一个文档《基于大数据应用的综合健康服务平台研发及应用示范》
  • 【性能工具】一种简易hook bitmap创建的插件使用
  • 单片机-STM32部分:7、GPIO输入 按键
  • 二分查找习题
  • 默认成员函数移动构造和移动赋值运算符重载
  • 数 学 函数
  • 双11美妆数据分析
  • 百胜企业管理咨询:助力企业快速获得ecovadis认证
  • 若依前后端分离项目中可以删除哪些原若依有的?
  • 2398.预算内的最多机器人数目 滑动窗口+单调队列
  • 鸿蒙 使用动画 简单使用
  • vue-quill-editor的失焦事件
  • conda init before conda activate
  • 代码随想录算法训练营第三十三天(补)
  • [人机交互]交互设计过程
  • AI系列:智能音箱技术简析
  • TCGA数据库临床亚型可用!贝叶斯聚类+特征网络分析,这篇 NC 提供的方法可以快速用起来了!
  • 操作系统——第四章(文件的物理结构以及与逻辑结构的对比)
  • vue截图-html2canvas
  • 两部门发布山洪灾害气象预警:北京西部、河北西部等局地山洪可能性较大
  • 少年中国之少年的形塑
  • 经济日报:降准降息,提前还房贷划算吗?
  • 央行:全力推进一揽子金融政策加快落地
  • 4月深圳新房、二手房成交同比均上涨,“5月有望延续积极向好的发展态势”
  • 马上评|持续对标国际一流,才有22项“全球最优”