[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+):
ColmapScript.bat:
::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:
- Type “edit the system environment variables” into start and click it
- Click ‘Environment Variables’
- 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.:
Folders_to_Process
|– Folder1
| | — Photo1.jpg, photo2.jpg, photo3.jpg …
|– Folder2
| | — Photo1.jpg etc…
|–ColmapScript.bat
|–AutoProcessing.bat
Autoprocessing.bat:
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.
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.
Yeah, I should have mentioned that somewhere. You can also add the lib folder to your PATH environment variable.
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.
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.
Colmap requires CUDA to work… So you will need a CUDA enabled graphics card… Don’t know if PMVS recquires it too.
Small typo in the first .bat…
%oMVS%\TextureMesh.exe –export-type obj -o myfolder%.obj model_dense_mesh_refine.mvs
Should be,
%oMVS%\TextureMesh.exe –export-type obj -o %myfolder%.obj model_dense_mesh_refine.mvs
I found it failed to export and realized why. Otherwise, works great! Thanks for sharing the automation.
Well spotted! -fixed now.
Greetings Dr. Falkingham, Thank you for posting your research! It has been very helpful… I was wondering if you ever had trouble building the dense cloud with openMvs after rendering the sparse cloud with colmap. My sparse cloud looks very good and camera positions look great but when I attempt to DensifyPointCloud in openMVS, I get an error for all images saying: error: reference image # has no good images in view. And the resulting *_dense.mvs file is empty. I have made sure that everything is installed correctly by using the sample mvs file from the website. Thanks again and I’d appreciate any feedback if you get the chance.
I used a total of 80 pictures of the subject in a white background, my cameras are fixed. Here is a picture of my sparse cloud:
https://ibb.co/fbQMOK
sample pictures:
https://ibb.co/kxpUce
https://ibb.co/fevPAz
https://ibb.co/eRoNxe
Terminal:
…
16:43:15 [App ] Build date: Aug 11 2018, 12:41:00
16:43:15 [App ] CPU: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
16:43:15 [App ] RAM: 16.00GB Physical Memory 16.00GB Virtual Memory
16:43:15 [App ] OS: Darwin 17.4.0 (x86_64)
16:43:15 [App ] SSE & AVX compatible CPU & OS detected
16:43:15 [App ] Command line: rock.mvs
16:43:15 [App ] Camera model loaded: platform 0; camera 0; f 0.776×0.776; poses 1
16:43:15 [App ] Camera model loaded: platform 1; camera 0; f 0.776×0.776; poses 1
16:43:15 [App ] Camera model loaded: platform 2; camera 0; f 0.791×0.791; poses 1
16:43:15 [App ] Camera model loaded: platform 3; camera 0; f 0.788×0.788; poses 1
.
..
…
16:43:15 [App ] Camera model loaded: platform 78; camera 0; f 0.770×0.770; poses 1
16:43:15 [App ] Camera model loaded: platform 79; camera 0; f 0.791×0.791; poses 1
16:43:15 [App ] Image loaded 0: 2018-08-20_151206.jpg
16:43:15 [App ] Image loaded 1: 2018-08-20_150635.jpg
16:43:15 [App ] Image loaded 2: 2018-08-20_151100.jpg
16:43:15 [App ] Image loaded 3: 2018-08-20_151116.jpg
16:43:15 [App ] Image loaded 4: 2018-08-20_151043.jpg
16:43:15 [App ] Image loaded 5: 2018-08-20_151055.jpg
.
..
…
16:43:22 [App ] error: reference image 76 has no good images in view
16:43:22 [App ] error: reference image 77 has no good images in view
16:43:22 [App ] error: reference image 78 has no good images in view
16:43:22 [App ] error: reference image 79 has no good images in view
16:43:22 [App ] Selecting images for dense reconstruction completed: 0 images (133ms)
Fused depth-maps 0 (100%, 0ms)
16:43:22 [App ] Depth-maps fused and filtered: 0 depth-maps, 0 depths, 0 points (-2147483648%%) (0ms)
16:43:22 [App ] Densifying point-cloud completed: 0 points (6s212ms)
16:43:22 [App ] Scene saved (7ms):
80 images (80 calibrated)
0 points, 0 vertices, 0 faces
I forgot to include this part of the log:
…
16:43:15 [App ] Image loaded 77: 2018-08-20_150652.jpg
16:43:15 [App ] Image loaded 78: 2018-08-20_150721.jpg
16:43:15 [App ] Image loaded 79: 2018-08-20_151243.jpg
16:43:15 [App ] Scene loaded from interface format (22ms):
80 images (80 calibrated) with a total of 616.60 MPixels (7.71 MPixels/image)
5429 points, 0 vertices, 0 faces
16:43:22 [App ] Preparing images for dense reconstruction completed: 80 images (6s75ms)
16:43:22 [App ] error: reference image 0 has no good images in view
16:43:22 [App ] error: reference image 1 has no good images in view
16:43:22 [App ] error: reference image 2 has no good images in view
16:43:22 [App ] error: reference image 3 has no good images in view
I reworked your script, so that it now can be used with folders including spaces. Would you mind, if I share it on github (as s gist)?
absolutely fine.
For all that want to use folders with spaces: you can find my modified script on github:
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
create3dModel_colmapAndOpenMVS.bat
hosted with ❤ by GitHub
BTW: I licensed my changes under MIT and stated that in a script header
Nice, thanks for that!
I tried to run your script for some sample images of the sceaux castle, but unfortunately it doesn’t work. I got the following error message when executing the .bat file:
C:\SfM\test_images\SceauxCastle\processed>”C:\SfM\COLMAP-dev-windows-no-cuda\bin\colmap.exe” feature_extractor –database_path database.db –image_path .
qt.qpa.plugin: Could not find the Qt platform plugin “windows” in “”
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
does it also work with the non-CUDA version of COLMAP?
I tried both, but ran into the same problem… Thanks!
I’ve not tried it with the non cuda version, but I wouldn’t expect that error. Looks like a formatting/incorrect path issue in there somewhere.
Maybe you could provide some feedback on https://github.com/colmap/colmap/issues/475… then this problem could most probably be fixed (don’t forget to reopen the issue).
Just getting started. Installed colmap, etc, set PATH environment variables, and copied script. Replaced drive letter, etc. Got this error in 1st colmap call. Can you help? Thanks much.
============
F:\Calculate>C:\Users\sbrande\Downloads\COLMAP-dev-windows\bin\colmap.exe feature_extractor –database_path database.db –image_path .
qt.qpa.plugin: Could not find the Qt platform plugin “windows” in “”
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
============
Sorry – just saw Leon’s comment above. Same issue. I’m also running the non-cuda version. Bummer.
Using the autoprocessing batch file, say I were to have a couple directories with images to process when I run the file, and while the processing is occurring I add another directory of images. Would it move into the new directory after finishing processing on the original two directories? If not, what modifications would I need to make to get that to happen?
UPDATE: Someone figured it out on Stack Overflow: https://stackoverflow.com/questions/55405401/moving-a-batch-file-into-directories-added-while-the-batch-file-is-running
Just got this running for the first time. Any suggestions for using this in 2019? Did you ever happen to work out that turntable setup? I have been looking to use one. Not use if Colmap works with stationary camera though. Thanks for all your hard work!
I never got a turntable set up, but COLMAP works great with photos taken with a stationary camera and turning the object manually. You could also give alicevision Meshroom a go, which is a bit newer and handles texturing too.
Hi. Thank you for posting this tutorial. I would be really grateful if you could kindly mention how to use “InterfaceCOLMAP.exe” instead of “InterfaceVisualSFM.exe”.
I don’t have OpenMVS installed at the minute, but when I last used it there wasn’t an InterfaceCOLMAP.exe – looks like that was added in a recent(ish) commit.
I’ll take another look at some point, but can’t gaurantee it’ll be soon.