Skip to content

Instantly share code, notes, and snippets.

@julianrendell
Last active August 28, 2023 03:34
Show Gist options
  • Save julianrendell/da6372201234d943d3e4f77e43674fd2 to your computer and use it in GitHub Desktop.
Save julianrendell/da6372201234d943d3e4f77e43674fd2 to your computer and use it in GitHub Desktop.
Building Meshroom for Windows (May 2020)

Install Visual Studio

Install Visual Studio 2019 Community Edition; make sure to enable C/C++ development.

Make sure you use an x64 developer shell, not the powershell- it uses the x86 compilers.

Install Pre-reqs

Install CUDA: https://developer.nvidia.com/cuda-downloads

Do this before starting to install the dependencies via vcpkg or the CUDA paths won't be added and the vcpkg builds won't be able to find it.

QT

Not tried in this iteration, but suggested for anyone following this: intall QT 5.14+ via binary packages and remove it from the vcpkg build. It'll save a lot of compiling time!

Install VCPKG

Follow the instructions. Use .\bootstrap-vcpkg.bat -disableMetrics if you don't want metrics collection.

Make note and make sure you run .\vcpkg integrate install in an admin powershell.

Make note of the message re CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=D:/Users/MakeItZone/Documents/vcpkg/scripts/buildsystems/vcpkg.cmake"

Install Required Libraries

This is the combined pre-reqs for qmlAlembic, QtOIIO, Alice Vision, Meshroom

 .\vcpkg.exe install opencv4[sfm,cuda,ffmpeg,ipp,jpeg,openexr,opengl,openmp,png,tbb,tiff,world] qt5[default,latest] alembic openimageio boost-algorithm boost-accumulators boost-atomic boost-container boost-date-time boost-exception boost-filesystem boost-graph boost-log boost-program-options boost-property-tree boost-ptr-container boost-regex boost-serialization boost-system boost-test boost-thread boost-timer lz4 openexr openimageio[libraw] geogram eigen3 ceres[suitesparse] cuda  devil[libpng,tiff,libjpeg,openexr,jasper,lcms] openblas --triplet x64-windows

Notes

  • taking a guess at the features needed for opencv.
  • at the time of writing, needed qt[default,latest] to get Qt5.13+ required for QtOIIO; default includes 3D.
  • needed to rename the libx86 directory of installed packages so that the AliceVision(?) build picked up the x64 ceres libraries; otherwise it tried to use the x86 versions and failed.

Developer (x64) Shell Setup

Create and CD to a base directory where you're going to have all the source code for the Alice Vision components.

Choose an installation path for the results.

Run this in your developer shell:

set TCF=D:/Users/MakeItZone/Documents/vcpkg/scripts/buildsystems/vcpkg.cmake
set PREFIX=D:\Users\MakeItZone\Documents\vcpkg\installed\x86-windows

qmlAlembic

git clone https://github.com/alicevision/qmlAlembic.git
cd .\qmlAlembic
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\qmlAlembic
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release
nmake install
cd ..
cd ..

QtOIIO

git clone --recursive git://github.com/alicevision/QtOIIO
cd .\QtOIIO
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\QtOIIO
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release
nmake install

PopSIFT

Had to build without examples, as the vcpkg version of devil doesn't include the CPP wrapper.

git clone --recursive https://github.com/alicevision/popsift.git
cd  popsift
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\popsift
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release -DPopSift_BUILD_EXAMPLES=NO
nmake install

OpenGV

git clone --recursive git clone https://github.com/alicevision/opengv.git --branch=cmake_fix_install
cd  opengv
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\opengv
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release
nmake install

CCTag

Had to build without examples, as the vcpkg version of devil doesn't include the CPP wrapper.

git clone --recursive https://github.com/alicevision/CCTag.git
cd  cctag
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\cctag
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release -DCCTAG_WITH_CUDA:BOOL=OFF -DBUILD_APPS:BOOL=OFF
nmake install

Magma

Does not build on Windows - see https://icl.cs.utk.edu/magma/forum/viewtopic.php?f=2&t=4119

Download from: https://icl.utk.edu/magma/software/view.html?id=277 and extract to your build location.

Build without Fortran.

Tried adding

SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)

SET(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@")
SET(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")

to top of CMakeLists.txt to force use of response files (windows command line length limit issues..) From https://stackoverflow.com/questions/43184251/cmake-command-line-too-long-windows.

mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\magma 
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release -DUSE_FORTRAN=OFF
nmake install

uncertaintyTE

Probably will be superceded: alicevision/AliceVision#731

Proposed steps- blocked by Magma not being buildable on Windows.

git clone --recursive https://github.com/alicevision/uncertaintyTE.git
cd .\uncertaintyTE
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\uncertaintyTE
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release
nmake install

AliceVision

Note- needed two hacks, one to use latest cctags, and other to copy an inline function in a header to the two places it's called to work around a vs2019 compiler bug. https://github.com/alicevision/AliceVision/compare/develop...julianrendell:vs2019-hacks?expand=1

git clone https://github.com/alicevision/AliceVision.git --recursive
cd AliceVision
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\AliceVision

cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release -DPopSift_DIR:PATH=D:\Meshroom_Dev\popsift\lib\cmake\PopSift -DALICEVISION_USE_OPENCV=ON -DOpenCV_DIR:PATH=D:\Users\MakeItZone\Documents\vcpkg\buildtrees\opencv4\x64-windows-rel -DOPENGV_DIR:PATH=D:\Meshroom_Dev\opengv -DCCTag_DIR:PATH=D:\Meshroom_Dev\cctag\lib\cmake\CCTag

If you get error fatal error RC1106: invalid option: /bigobj NMAKE : fatal error U1077: 'C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe' : return code '0x1' make sure you have alicevision/AliceVision#796

nmake install

QtAliceVision

Plugin that allows you to see features overlaid on images.

git clone https://github.com/alicevision/QtAliceVision.git
cd QtAliceVision
mkdir build
cd build
set INSTALL=d:\Meshroom_Dev\QtAliceVision
cmake .. -DCMAKE_TOOLCHAIN_FILE=%TCF% -DCMAKE_PREFIX_PATH=%PREFIX% -DVCPKG_TARGET_TRIPLET=x64-windows -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_BUILD_TYPE=Release -DAliceVision_DIR=D:\Meshroom_Dev\AliceVision\share\aliceVision\cmake -DPopSift_DIR=D:\Meshroom_Dev\popsift\lib\cmake\PopSift

Meshroom

Install the x64 version of Python.

pip may require the --user opton to install the requirements.

Note the instructions re setting QML2_IMPORT_PATH and QT_PLUGIN_PATH in the installation instructions for the QML extensions don't work for Meshroom on Windows (path seperators not working in Qt?)

The easiest solution is to create a qml directory inside QT_PLUGIN_PATH, i.e.

qtPlugins
+---imageformats
\---qml
    +---AlembicEntity
    +---AliceVision
    \---DepthMapEntity

To run:

set QT_PLUGIN_PATH=D:\Meshroom_Dev\qtPlugins
set QML2_IMPORT_PATH=%QT_PLUGIN_PATH%\qml
set ALICEVISION_VOCTREE=D:\Meshroom_Dev\voctree
set ALICEVISION_SENSOR_DB=D:\Meshroom_Src\AliceVision\src\aliceVision\sensorDB\cameraSensors.db

python meshroom/ui
@WathikAhmed
Copy link

Can you show us how to run it from the command line?

the command: python bin/meshroom_batch --input INPUT_IMAGES_FOLDER --output OUTPUT_FOLDER

It dosent work for me, and i get the error:

Traceback (most recent call last):
File "bin/meshroom_batch", line 7, in
import meshroom
ModuleNotFoundError: No module named 'meshroom'

Thanks

@julianrendell
Copy link
Author

I only ran the Meshroom UI, as per the "To run" section - that's what the python meshroom/ui command does ;-).
You do need to cd into the directory where you have meshroom; in my example, that was D:\Meshroom_Dev.

I have not used the meshroom_batch command directly, so I can't help you with that. But I expect it needs all the same environment variables to be set.

Please do note that this info is probably out of date!

@ItaloFan
Copy link

Can you show us how to run it from the command line?

the command: python bin/meshroom_batch --input INPUT_IMAGES_FOLDER --output OUTPUT_FOLDER

It dosent work for me, and i get the error:

Traceback (most recent call last): File "bin/meshroom_batch", line 7, in import meshroom ModuleNotFoundError: No module named 'meshroom'

Thanks

A too late reply in 2023, you just need add your current path to PYTHONPATH environment variable, and that's what set PYTHONPATH=%CD% do in windows commandprompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment