0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

colmapを用いた3次元再構成入門|特徴点抽出〜メッシュ化

Posted at

colmapの基本トピック

colmapの概要

colmapは3次元再構成(3D Reconstruction)にあたって用いられる手法であるSfM(Structure-from-Motion)やMVS(Multi-View Stereo)について取り扱ったソフトウェアです。

colmap1.png
colmap Tutorial より

colmapでは基本的に上記のようなSfM(Structure-from-Motion)の流れに沿って3次元再構成が行われます。

colmapのインストール

colmapのインストールは上記に基づいて行うことができます。

colmapを用いた3次元再構成

ディレクトリ構成

まず、colmapのディレクトリ構成は下記のようになることを抑えておくと良いです。

/path/to/project/ex1/
+── images
│   +── image1.jpg
│   +── image2.jpg
│   +── ...
+── sparse
│   +── 0
│   │   +── cameras.bin
│   │   +── images.bin
│   │   +── points3D.bin
│   +── ...
+── dense
│   +── 0
│   │   +── images
│   │   +── sparse
│   │   +── stereo
│   │   +── fused.ply
│   │   +── meshed-poisson.ply
│   │   +── meshed-delaunay.ply
│   +── ...
+── database.db

実行する事例毎にディレクトリを作成し、その直下にiamgessparsedenseを作成、imagesに用いる画像群を保存する点だけ抑えておけば十分だと思います。

処理の実行

下記を実行することで特徴点抽出からメッシュ化までの3D再構成の一連の流れを実行することができます。

$ colmap feature_extractor --database_path database.db --image_path images
$ colmap exhaustive_matcher --database_path database.db
$ colmap mapper --database_path database.db --image_path images --output_path sparse
$ colmap image_undistorter --image_path images --input_path sparse/0 --output_path dense
$ colmap patch_match_stereo --workspace_path dense --workspace_format COLMAP --PatchMatchStereo.geom_consistency true
$ colmap stereo_fusion --workspace_path dense --workspace_format COLMAP --input_type geometric --output_path dense/fused.ply
$ colmap poisson_mesher --input_path dense/fused.ply --output_path dense/meshed-poisson.ply

colmap patch_match_stereo...の処理がCUDAを用いて1時間〜数時間ほどかかる点に注意が必要です。上記で得られた出力のdense/meshed-poisson.plyは下記のようなコードを実行することで可視化することが可能です。

import open3d as o3d


filepath = 'dense/meshed-poisson.ply'

mesh = o3d.io.read_triangle_mesh(filepath)
o3d.visualization.draw_geometries([mesh])

・実行結果
colmap2.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?