Colmap 实用教程 —— Command-line Interface

https://colmap.github.io/index.html

Windows 通过 COLMAP.bat,Linux 通过 colmap 使用命令行调用 Colmap 工具。 

Structure-from-Motion 简要介绍

Colmap 实用教程 —— Command-line Interface_第1张图片

 从大范围来看的话,整个流程可以分成以下三个阶段:

  1. Feature detection and extraction
  2. Feature matching and geometric verification
  3. Structure and motion reconstruction

Colmap 三维重建处理流程

Colmap 提供了简单的集成三维重建方式方式 automatic_reconstructor,只需要提供工程文件路径和对应采集到的图像即可一键实现三维重建。

# The project folder must contain a folder "images" with all the images.
$ DATASET_PATH=/path/to/project

$ colmap automatic_reconstructor \
    --workspace_path $DATASET_PATH \
    --image_path $DATASET_PATH/images

 当然 Colmap 也提供了单步的重建方式,其中对应命令可以使用 -h 参数进行查看,比如 colmap feature_extractor -h。下面将分步骤详细介绍。

图像特征提取

$ colmap feature_extractor \
   --database_path $DATASET_PATH/database.db \
   --image_path $DATASET_PATH/images

feature_extractor 将基于提供的每张图像提取SIFT特征,并将特征存储在 database.db 中。同时,可以使用 feature_importer 加载已经提取的特征。

图像特征匹配

$ colmap exhaustive_matcher \
   --database_path $DATASET_PATH/database.db
  • exhaustive_matcher:针对少量图像(几百张量级),可以获得足够快且最好的重建结果。它将每张图像与其余所有图像进行匹配,不过 block size 可能限制同时加载到内存中的图像数量。
  • sequential_matcher:针对顺序采集的视频图像,由于相邻帧存在视觉上的重叠且没有必要进行完全匹配,它只匹配视频流中的相邻帧。同时,这种匹配方式能够基于 vocabulary tree 进行回环检测。最后,帧之间的前后关系由图像文件名给定,与数据集中的存储顺序无关。
  • vocab_tree_matcher:针对大量图像(几千帧量级),可以通过提供 vocabulary tree 从而快速检索视觉上最相近的图像进行匹配。
  • spatial_matcher:针对能够提供准确定位信息的图像,可以通过对应图像采集时的 GPS 信息从而仅匹配空间位置上相近的图像。
  • transitive_matcher:基于传递规则使用已有的特征匹配关系确定更完全的匹配图,即 A 与 B 匹配,B 与 C 匹配,那将直接匹配 A 和 C。
  • Custom Matching:通过 text 文件指定图像的匹配关系,如果是导入的特征可以进一步指定两张图像之间特征的匹配关系。

稀疏三维重建

$ mkdir $DATASET_PATH/sparse

$ colmap mapper \
    --database_path $DATASET_PATH/database.db \
    --image_path $DATASET_PATH/images \
    --output_path $DATASET_PATH/sparse
  • mapper:在执行特征提取与匹配后通过 sfM 进行稀疏三维重建与构图。
  • hierarchical_mapper:在执行特征提取与匹配后通过 hierarchical SfM 进行稀疏三维重建与构图。首先将整个场景拆分成部分重叠的多个子场景,然后通过独立并行的方式分别重建,最后进行融合。建议通过此方式建图后执行几次 point triangulation 和 bundle adjustment。

图像去畸变

$ mkdir $DATASET_PATH/dense

$ colmap image_undistorter \
    --image_path $DATASET_PATH/images \
    --input_path $DATASET_PATH/sparse/0 \
    --output_path $DATASET_PATH/dense \
    --output_type COLMAP \
    --max_image_size 2000

对原始图像进行去畸变,并且支持导出去畸变图像用于 MVS、CMVS 和 PMVS 进行稠密重建。

稠密三维重建

$ colmap patch_match_stereo \
    --workspace_path $DATASET_PATH/dense \
    --workspace_format COLMAP \
    --PatchMatchStereo.geom_consistency true

在使用 image_undistorter 初始化工作空间后,使用 MVS 进行稠密三维重建或建图。这一步主要是利用三角化计算深度和法线贴图。

  • $ colmap stereo_fusion \
        --workspace_path $DATASET_PATH/dense \
        --workspace_format COLMAP \
        --input_type geometric \
        --output_path $DATASET_PATH/dense/fused.ply

融合 patch_match_stereo 的结果形成一个上色点云。这一步主要是将上一步生成的深度和法线贴图融合到点云上。

$ colmap poisson_mesher \
    --input_path $DATASET_PATH/dense/fused.ply \
    --output_path $DATASET_PATH/dense/meshed-poisson.ply

$ colmap delaunay_mesher \
    --input_path $DATASET_PATH/dense \
    --output_path $DATASET_PATH/dense/meshed-delaunay.ply

 可选的点云 meshing 阶段。

  • poisson_mesher:使用 Poisson 表面重建生成彩色点云 mesh
  • delaunay_mesher:基于 Delaunay 三角剖分和可见性投票,使用 graph cut 对重建的稠密和稀疏点云生成 mesh。

其他命令行介绍

图像增删

  • image_rectifier:Stereo rectify cameras and undistort images for stereo disparity estimation.
  • image_filterer:基于稀疏重建过滤图像
  • image_deleter:从稀疏重建中删除指定图像
  • image_registrator:在 mapper 建图之后注册新的图像到现有模型中。其中不会执行 bundle adjustment 和 triangulation。

模型操作

  • model_analyzer:打印重建结果的统计分析。
  • model_aligner:Align/geo-register model to coordinate system of given camera centers.
  • model_orientation_aligner:使用曼哈顿世界假设对齐模型的坐标系。
  • model_converter:将 COLMAP 格式导出为 PLY 或 NVM 格式。
  • model_cropper:按照指定 bounding box 裁切模型,其中 BBox 可以通过 GPS 或者模型坐标系给出。
  • model_splitter:Divide model in rectangular sub-models specified from file containing bounding box coordinates, or max extent of sub-model, or number of subdivisions in each dimension.
  • model_merger:融合存在共同注册图像的两个不连续重建。

重建结果优化

  • point_triangulator:使用数据集中的所有匹配特征对现有模型中的所有注册图像观测进行三角化。
  • point_filtering:基于 minimum track length, maximum reprojection error 的标准滤除模型中的稀疏点。
  • bundle_adjuster:在现有重建场景上执行全局 bundle adjustment。在执行 image_registrator 或需要优化内参时执行。

数据集操作

  • database_creator:生成一个空的 COLMAP SQLite 数据集,其中包含必要的数据库信息。
  • database_merger:将两个数据集融合,其中同 id 的图像和相机会被作为不同进行处理。

vocabulary tree 相关

  • vocab_tree_builder:基于数据集中的提取图像生成 vocabulary tree。这是一个离线过程只需要被执行一次,同时可以被用于其他数据集。 Note that, as a rule of thumb, you should use at least 10-100 times more features than visual words. 预训练的结果可以从 https://demuc.de/colmap/ 直接下载。同时也可以构建自己的 vocabulary tree 从而适配不同的 PR 和速度。
  • vocab_tree_retriever:基于 vocabulary tree 进行图像检索。

其他

  • gui:启动图形界面
  • project_generator:基于不同重建质量设置生成项目文件
  • color_extractor:提取模型所有点的平均颜色。

你可能感兴趣的:(三维重建,colmap,三维重建)