目录
colmap主页说明文档
https://colmap.github.io/cli.html#example
图片组织格式
/path/to/project/…
+── images
│ +── image1.jpg
│ +── image2.jpg
│ +── …
│ +── imageN.jpg
工程中包含images的文件夹,images中即为待重建的图片
自动重建命令
#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
逐步重建
1.特征提取
./colmap feature_extractor
–database_path $DATASET_PATH/database.db \ # 输出:特征点保存至数据库database.db
–image_path $DATASET_PATH/images # 输入:多视图图像
2.特征点匹配
./colmap exhaustive_matcher
–database_path $DATASET_PATH/database.db # 输入输出:数据库文件database.db
3.稀疏重建(SfM, Structure-from-Motion)(mapper)
mkdir $DATASET_PATH/sparse # 新建sparse文件夹
./colmap mapper
–database_path $DATASET_PATH/database.db \ # 输入:数据库文件database.db
–image_path $DATASET_PATH/images \ # 输入:多视图图像
–output_path $DATASET_PATH/sparse # 输出:sparse
文件夹
输出的结果sparse文件夹如下所示:
└── sparse # 稀疏重建结果
└── 0
├── cameras.bin # 相机内参
├── images.bin # 相机位姿
├── points3D.bin # 稀疏3D点
└── project.ini
4.图像去畸变
mkdir $DATASET_PATH/dense # 新建dense文件夹
./colmap image_undistorter
–image_path $DATASET_PATH/images \ # 输入:多视图图像
–input_path $DATASET_PATH/sparse/0 \ # 输入:sparse文件夹
–output_path $DATASET_PATH/dense \ # 输出:dense文件夹
–output_type COLMAP \ # 参数:输出格式
–max_image_size 2000 # 参数:最大图像尺寸
输出结果dense文件夹如下所示
└── dense
├── images
│ ├── 100_7100.JPG
│ ├── 100_7101.JPG
│ ├── …
│ └── 100_7110.JPG
├── run-colmap-geometric.sh
├── run-colmap-photometric.sh
├── sparse
│ ├── cameras.bin
│ ├── images.bin
│ └── points3D.bin
└── stereo
├── consistency_graphs
├── depth_maps
├── fusion.cfg
├── normal_maps
└── patch-match.cfg
5.稠密重建
./colmap patch_match_stereo
–workspace_path $DATASET_PATH/dense \ # 输入输出:dense文件夹
–workspace_format COLMAP \ # 参数:工作区格式
–PatchMatchStereo.geom_consistency true
稠密重建的结果:为每张图估计depth_map和normal_map
└── dense
├── images # resize之后的图像
│ ├── 100_7100.JPG
│ ├── 100_7101.JPG
│ ├── …
│ └── 100_7110.JPG
├── run-colmap-geometric.sh
├── run-colmap-photometric.sh
├── sparse
│ ├── cameras.bin
│ ├── images.bin
│ └── points3D.bin
└── stereo
├── consistency_graphs
├── depth_maps
│ ├── 100_7100.JPG.geometric.bin
│ ├── 100_7100.JPG.photometric.bin
│ ├── …
│ ├── …
│ ├── 100_7110.JPG.geometric.bin
│ └── 100_7110.JPG.photometric.bin
├── fusion.cfg
├── normal_maps
│ ├── 100_7100.JPG.geometric.bin
│ ├── 100_7100.JPG.photometric.bin
│ ├── …
│ ├── …
│ ├── 100_7110.JPG.geometric.bin
│ └── 100_7110.JPG.photometric.bin
└── patch-match.cfg
6.融合
./colmap stereo_fusion
–workspace_path $DATASET_PATH/dense \ # 输入:dense文件夹
–workspace_format COLMAP \ # 参数:工作区格式
–input_type geometric \ # 参数:输入类型
–output_path $DATASET_PATH/dense/fused.ply # 输出:fused.ply文件
重建结果可视化
1.稀疏重建结果可视化
····使用model_converter将sparse文件夹中的bin文件转为txt文件
./colmap model_converter
–input_path $DATASET_PATH/dense/sparse
–output_path $DATASET_PATH/dense/sparse
–output_type TXT
····使用colmap gui对稀疏重建结果可视化
2.深度图/法向图可视化
3.稠密重建结果可视化
额外补充
.sh是shell语言写的脚本文件,通常用于在 Unix 或 Linux 系统中自动执行一系列命令。使用的是 Shell(如 Bash、sh、zsh 等)作为解释器。
如:
#!/bin/bash 指定脚本使用 Bash 解释器来执行。
echo “Hello, World!” 打印到终端
mkdir new_directory
cd new_directory
touch new_file.txt 创建一个名为 new_file.txt 的空文件。
echo “This is a new file” > new_file.txt 将 “This is a new file” 这行文字写入 new_file.txt 文件中。
执行脚本:
chmod +x example.sh 赋予可执行权限
./example.sh或者直接使用解释器bash example.sh
.py是python脚本