COLMAP + OpenMVS scripts [Updated]

[updated 10/7/18 to use development version of COLMAP, and include environment variables]

It’s been a while since I wrote anything on the blog – an extremely high teaching load has kept me from tinkering.

So to ease myself back in, here are updated scripts for running colmap and openMVS automatically.  COLMAP 3.4 changed the way things are called from the command line, breaking my previous script, and the author now recommends using the dev version as standard

If you want detail on what each bit does, check out the original post here.

Updated COLMAP + OpenMVS script (v3.4+):


::These parameters are specific to computer

::Store current Directory:
set currDir=%CD%

::get folder name as variable
SET "MYDIR=%~p0"
set MYDIR1=%MYDIR:~0,-1%
for %%f in (%MYDIR1%) do set myfolder=%%~nxf

:: Set colmap directory (change this to where you've downloaded colmap, replace 'dev' with version number if necessary):
set colDir=C:\Users\Peter\Downloads\COLMAP-dev-windows\bin\colmap.exe

:: Set openMVS directory (change this to where you've downloaded openMVS)
set oMVS=C:\Users\Peter\Downloads\openMVS_sample-0.7a

:: Set Working Directory (I create a temporary folder on my D drive to process data in)
set workDir=D:\%myfolder%\

mkdir %workDir% 
copy *.jpg %workDir%\ 
cd /d %workDir%

%colDir% feature_extractor --database_path database.db --image_path .
%colDir% exhaustive_matcher --database_path database.db
mkdir sparse
%colDir% mapper --database_path %workDir%\database.db --image_path . --export_path %workDir%\sparse
%colDir% 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 you want to automate removal of the working folder, use the following line.
::Don't use it if you want to keep intermediate steps.
rmdir /S /Q %workDir%

This new script takes the current folder name and uses that to name the model. WARNING: SPACES CAN’T BE USED IN FOLDER/PATH NAMES.

Copy the above into a text file, rename the *.txt to *.bat, place in folder full of photos, and double click.

Remember to add the colmap libraries to your environment variables:

  1. Type “edit the system environment variables” into start and click it
  2. Click ‘Environment Variables’
  3. Double click the ‘path’ variable, and add a new line that goes straight to the COLMAP lib folder, e.g. “C:\Users\pfalkingham\Downloads\COLMAP-dev-windows\lib” Click ok.  Now the script should work.


I also have a script that will run through folders:

Script for processing multiple photos automatically

Put this bat file and the above bat file in the directory that contains folders of photos, e.g.:

|– Folder1
|  | — Photo1.jpg, photo2.jpg, photo3.jpg …
|– Folder2
|  | — Photo1.jpg etc…


for /D %%i in (*) do (
cd %%i
copy ..\ColmapScript.bat COLMAP.bat
call COLMAP.bat
cd ..

Just set everything up as above, and double click Autoprocessing.bat. The terminal will move into Folder1, copy the colmap script in there, run the colmap script, then move up and into Folder 2 to repeat.

Hope that helps/is of use to people.




7 thoughts on “COLMAP + OpenMVS scripts [Updated]

  1. Thanks a lot for sharing your scripts, it makes it easy to use these open source tools!
    I had to copy the content of the lib folder into the bin folder to get it to work though, otherwise it was complaining it couldn’t find the dll libraries.

  2. I’ve been trying to figure out how to use photogrammetry software just out of personal interest, and your blog has been incredibly helpful to me, but I haven’t been able to get OpenMVS to do anything, even when I use your script, no matter what I do. All it does is create a short log file along these lines for each step:
    20:41:08 [App ] Build date: May 26 2017, 18:38:57
    20:41:08 [App ] CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    20:41:08 [App ] RAM: 15.87GB Physical Memory 128.00TB Virtual Memory
    20:41:08 [App ] OS: Windows 10+ x64
    20:41:08 [App ] SSE & AVX compatible CPU & OS detected
    20:41:08 [App ] Command line: -i .\P13020
    20:41:08 [App ] Loading cameras/points: ./P13020
    and then exits out without producing any other output. When I try and do it myself, I can make a sparse point cloud in COLMAP just fine, and get the exact same lack of results from OpenMVS.

    1. Ah, not a lot to go on then. Is it definately reconstructing camera positions in COLMAP? (Using the GUI, does it reconstruct a sparse model?). If so, do you have a CUDA enabled GPU – that may be necessary for openMVS.

    2. Colmap requires CUDA to work… So you will need a CUDA enabled graphics card… Don’t know if PMVS recquires it too.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s