Last active
November 29, 2022 06:54
-
-
Save pathtrk/7e63279436698dda04ffece450a4398f to your computer and use it in GitHub Desktop.
Run colmap and openMVS on PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory = $true)][String]$data_dir, | |
[String]$project_dir | |
) | |
if (Get-Item -Path $data_dir\images -ErrorAction Ignore) { | |
# The data folder must contain a folder "images" with all the images. | |
$DATA_ROOT = $data_dir.TrimEnd('\') | |
} | |
else { | |
Write-Output "Please specify a directory that contains 'images' folder." | |
exit | |
} | |
if (Get-Item -Path $project_dir -ErrorAction Ignore) { | |
$PROJECT = $project_dir.TrimEnd('\') | |
} | |
else { | |
$PROJECT = ".\Colmap" | |
Write-Output "Project directory was missing. Current working directory was set as a project root." | |
} | |
colmap feature_extractor ` | |
--SiftExtraction.use_gpu 1 ` | |
--database_path $PROJECT\database.db ` | |
--image_path $DATA_ROOT\images | |
colmap exhaustive_matcher ` | |
--SiftMatching.use_gpu 1 ` | |
--database_path $PROJECT\database.db | |
if (!(Test-Path $PROJECT\sparse)) { | |
mkdir $PROJECT\sparse | |
} | |
colmap mapper ` | |
--database_path $PROJECT\database.db ` | |
--image_path $DATA_ROOT\images ` | |
--output_path $PROJECT\sparse | |
colmap image_undistorter ` | |
--image_path $DATA_ROOT\images ` | |
--input_path $PROJECT\sparse\0 ` | |
--output_path $PROJECT\dense ` | |
--output_type COLMAP | |
colmap model_converter ` | |
--input_path $PROJECT\dense\sparse ` | |
--output_path $PROJECT\dense\sparse ` | |
--output_type TXT | |
$origin = $pwd; Set-Location $PROJECT\dense | |
InterfaceCOLMAP ` | |
--input-file . ` | |
--output-file model_colmap.mvs | |
DensifyPointCloud ` | |
--input-file model_colmap.mvs ` | |
--output-file model_dense.mvs ` | |
--archive-type -1 | |
ReconstructMesh ` | |
--input-file model_dense.mvs ` | |
--output-file model_dense_mesh.mvs | |
RefineMesh ` | |
--resolution-level 1 ` | |
--input-file model_dense_mesh.mvs ` | |
--output-file model_dense_mesh_refine.mvs | |
TextureMesh ` | |
--export-type ply ` | |
--output-file model.ply ` | |
--input-file model_dense_mesh_refine.mvs | |
Set-Location $origin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment