Updated batch script for Meshroom 2021

This is an update of a previous post, because updates to meshroom broke the previous scripts.

There’s two main changes to Meshroom that have occured:

  1. Instead of Meshroom_photogrammetry.exe, you now call meshroom_batch.exe
  2. Your scene must have a publish node after the final node.

Here’s the updated script, and it should be commented appropriately:

:: meshroomCMD.bat

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

:: Meshroom location - ***CHANGE THIS***

SET meshRoomBin="E:\Programs\Meshroom-2021.1.0"

:: Meshroom Graph location - open meshroom, setup the graph as you want, then save the scene.  This variable points to it
SET meshRoomScene="C:\Users\pfalk\Desktop\Meshroombatch\PetersTestScene.mg"

:: 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%, but change the bit before that to where you want output to go)
set workDir=C:\Users\pfalk\Desktop\%myfolder%

:: Make a new folder to put meshroom outputs in.
mkdir %workDir%

echo "hello"
::run meshroom on this folder
%meshRoomBin%\meshroom_batch.exe --input . --output %workdir% -p %meshRoomScene%

You can compare this to the previous script, and see that the binary has changed, and there’s reference to a standard scene (PetersTestScene.mg).

Unlike previously, the ‘workdir’ does not act as the cache location – that goes to whatever the default for your Meshroom program is (probably C:/Users/<username>/AppData/Local/Temp/MeshroomCache).

In your scene, you need to add a publish node. Connect mesh, texture and material from the Texturing node to the input files, and set an output folder. I’ve set this to a temp folder (“tempoutput”) on my desktop, and the script will move the files from here to the dynamic ‘output’ folder named according to the image folder.

Then, just as before, you can call this batch file from a small script that runs through all the subfolders within a directory:


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

Hopefully that helps, as I’ve had a few queries now about updated that old script. Let me know in the comments if anything is missing or doesn’t work for you.

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: