Batch Script for running AliceVision MeshRoom from command line

Here’s a script to reduce the processing of AliceVision’s Meshroom to a single double click.

Much as I did for COLMAP, (and here) I’ve put together a batch file that can just be dropped into a folder of photos and double clicked to run the full Meshroom process and produce a filtered, textured model without any interaction.

It’s not that big of a deal, because MeshRoom is already pretty straightforward, but having a script like this means I can combine it with a second script that will work through a series of folders and produce multiple models (I’ll put this up on a subsequent post).

  • You need to set:
    • The location of your aliceVision Meshroom binaries
    • The place you want your dataProcessing to be done

Currently, my Meshroom binary is located on my D drive under programs:

D:\Programs\Meshroom-2018.1.0\”

 

And my working directory is going to be chucked in to my downloads folder, in a subfolder called the same thing as the folder my images are in (clearly this will change too):

set workDir=C:\Users\pfalkingham\Downloads\%myfolder%

 

Those should be the only two values you need to change between computers.

The other Caveat is that MeshRoom will fail if it can’t find the camera in the sensor_database, rather than just guessing and carrying on.  So make sure photos from your camera work fine when you set this up for large-scale processing.

Here’s the script:

::meshroomCMD.bat

:: Start with some parameters unique to your computer...

::Meshroom location - CHANGE THIS 

SET meshRoomBin="D:\Programs\Meshroom-2018.1.0\"

:: Now setup variables based on current directory/folder name

:: Current location

set currDir=%CD%

:: Make current foldername into a variable

SET "MYDIR=%~p0"

set MYDIR1=%MYDIR:~0,-1%

for %%f in (%MYDIR1%) do set myfolder=%%~nxf

:: Set Working Directory (windows) - CHANGE THIS TOO (LEAVE %MYFOLDER%)

set workDir=C:\Users\pfalkingham\Downloads\%myfolder%



:: Make a new folder to put meshroom outputs in.

mkdir %workDir%

%meshRoomBin%\meshroom_photogrammetry.exe --input . --output %workdir% --scale 2


As I said, quite simple.  Just create a new text file, put this in there (with your own locations for meshroom and working directory), then save and change the extension from txt to .bat.  Then you can just drop into a folder full of photos and double click it.  I run my scripts in powershell, so it excitingly looks like this:

Annotation 2018-12-13 154516.jpg

The first advantage of using this script rather than opening up meshroom is that I can just ‘fire and forget’  – I get my folder full of photos, drop the bat file in, double click and walk away.

That in turn means you can use a second script to batch process several different folders of images.  Such a script would look something like this:

::runthroughfolders.bat

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

I put this script plus my meshroom script into a folder of folders, as such:

Project_folder
|-\imageset1
|-\imageset2
|-\imagesetx…
|-meshroomCMD.bat
|_runthroughfolders.bat

…then just double click ‘runthroughfolders.bat’ and come back some time later.

With the way I’ve set up my script, I’ll come back to my downloads folder containing a bunch of new folders, in this case called ‘imageset1’ etc.  In each folder will be an obj, mtl, and texture file.

 

Note that currently, using the executable this way means you can’t specify which texturing algorithm you use, or other parameters.  This will apparently change in the future, but for now you can tweak the defaults for some parameters, which I’ll discuss in my next post.

 

2 thoughts on “Batch Script for running AliceVision MeshRoom from command line

Add yours

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: