Last active
October 9, 2018 11:57
-
-
Save nikolauskrismer/5cf9b8a94fc8d369d779e75fce8c26dc to your computer and use it in GitHub Desktop.
Photogrammetrie: script for creating a 3d model out of multiple jpg images (using COLMAP and openMVS)
This file contains hidden or 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
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:: Generates a 3D model out of multiple photographs using :: | |
:: COLMAP and openMVS. See https://peterfalkingham.com/ for more :: | |
:: information about photogrammetrie. :: | |
:: :: | |
:: Note that the COLMAP library folder needs to be added to the :: | |
:: PATH environment variable in order for this script to work. :: | |
:: :: | |
:: Copyright 2018, Peter Falkingham (v1.0, v1.1) :: | |
:: Copyright 2018, Nikolaus Krismer (v1.2) :: | |
:: :: | |
:: Licensed under the MIT License (since v1.2) :: | |
:: :: | |
:: Permission is hereby granted, free of charge, to any person obtaining :: | |
:: a copy of this software and associated documentation files (the :: | |
:: "Software"), to deal in the Software without restriction, including :: | |
:: without limitation the rights to use, copy, modify, merge, publish, :: | |
:: distribute, sublicense, and/or sell copies of the Software, and to :: | |
:: permit persons to whom the Software is furnished to do so, subject to :: | |
:: the following conditions: :: | |
:: The above copyright notice and this permission notice shall be :: | |
:: included in all copies or substantial portions of the Software. :: | |
:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, :: | |
:: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF :: | |
:: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND :: | |
:: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE :: | |
:: LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION :: | |
:: OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION :: | |
:: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. :: | |
:: :: | |
:: Revision history: :: | |
:: 2018-10-06 (v1.2) allows usage of spaces in folder names :: | |
:: restructuring source, support for COLMAP v3.6 :: | |
:: 2018-07-10 (v1.1) allows usage of development version of COLMAP :: | |
:: support for COLMAP v3.4+ :: | |
:: 2018-04-01 (v1.0) initial release :: | |
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:: Modify the following parameters according to your system | |
set "colDir=C:\Program Files\colmap" | |
set "oMVS=C:\Program Files\openMVS" | |
set "keepIntermediate=true" | |
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:: Do not modify anything below this line! | |
set "colBin=%colDir%\bin\colmap.exe" | |
set "currDir=%CD%" | |
set "workDir=%currDir%\processed" | |
set "MYDIR=%~p0" | |
set "MYDIR1=%MYDIR:~0,-1%" | |
for %%f in ("%MYDIR1%") do ( | |
set "myfolder=%%~nxf" | |
) | |
mkdir "%workDir%" | |
copy *.jpg "%workDir%" | |
cd "%workDir%" | |
mkdir "sparse" | |
"%colBin%" feature_extractor --database_path database.db --image_path . | |
"%colBin%" exhaustive_matcher --database_path database.db | |
"%colBin%" mapper --database_path "%workDir%\database.db" --image_path . --output_path "%workDir%\sparse" | |
"%colBin%" model_converter --input_path "sparse\0" --output_path model.nvm --output_type NVM | |
"%oMVS%\InterfaceVisualSFM.exe" model.nvm | |
"%oMVS%\DensifyPointCloud.exe" model.mvs | |
"%oMVS%\ReconstructMesh.exe" model_dense.mvs | |
"%oMVS%\RefineMesh.exe" --resolution-level 1 model_dense_mesh.mvs | |
"%oMVS%\TextureMesh.exe" --export-type obj -o %myfolder%.obj model_dense_mesh_refine.mvs | |
mkdir "%currDir%\model" | |
copy *.obj "%currDir%\model" | |
copy *.mtl "%currDir%\model" | |
copy *Kd.jpg "%currDir%\model" | |
cd "%currDir%" | |
if %keepIntermediate% == false ( | |
rmdir /S /Q "%workDir%" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment