Skip to content

Instantly share code, notes, and snippets.

@pathtrk
Last active November 29, 2022 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathtrk/7e63279436698dda04ffece450a4398f to your computer and use it in GitHub Desktop.
Save pathtrk/7e63279436698dda04ffece450a4398f to your computer and use it in GitHub Desktop.
Run colmap and openMVS on PowerShell
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