Skip to content

Instantly share code, notes, and snippets.

@natowi
Forked from donmahallem/MeshroomCollab.ipynb
Last active September 19, 2023 19:21
Show Gist options
  • Save natowi/3044484ad0c98877692c399297e3ab7e to your computer and use it in GitHub Desktop.
Save natowi/3044484ad0c98877692c399297e3ab7e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@natowi
Copy link
Author

natowi commented Nov 26, 2019

@paramphy The notepad is now updated

@mmfineart
Copy link

Hi,
I'm new to meshroom as well as python.
I want to upload photos to a google drive folder and get those to meshroom instead of uploading files from pc every time I try to use meshroom.
Could you please reply with code to do that? Thanks in advance!

@natowi
Copy link
Author

natowi commented Dec 3, 2019

@mmfineart Added Google Drive support (not fully tested, but should work)

@natowi
Copy link
Author

natowi commented Dec 21, 2019

!git clone --recursive git://github.com/alicevision/meshroom %cd meshroom !pip install -r requirements.txt

@somedevelopment
Copy link

@natowi thanks for the work!

Acutally as nothing really worked for me, I changed the script to the following. Working for me with G-Drive and the the release file.
https://github.com/somedevelopment/Meshroom_Colab_BIN_GDRIVE

@natowi
Copy link
Author

natowi commented Jan 19, 2020

I´ll take a look at the google drive loading problem. Maybe I will also split the script and create two versions.

@McFlyte
Copy link

McFlyte commented Jan 31, 2020

Thanks for the good work.

I also have the symlink problem as noted here: alicevision/Meshroom#735 when working with Google Drive. It works fine if I don't mount the Drive.

I'm very new to this, but do you think this could be related to the Drive being used primarily by a Windows (not Linux) machine?

@McFlyte
Copy link

McFlyte commented Feb 1, 2020

Today I tried installing Meshroom in the 'content' folder and that worked fine. I then mounted the G-drive and ran Meshroom with input and output saved to the G-drive while the install was in the 'content' folder. That worked fine.

@ReallyNotARussianSpy
Copy link

ReallyNotARussianSpy commented Feb 8, 2020

Very simple to copy pictures from Drive ...

Change

from google.colab import files

# optional upload for the images

uploaded = files.upload()

for fn in uploaded.keys():
    print('User uploaded file "{name}" with length {length} bytes'.format( name=fn, length=len(uploaded[fn])))

to:

cp -a '/content/drive/My Drive/Meshroom/.' .

Replace Meshroom with the name of your folder in Google Drive

@soham0243
Copy link

Hello , I've followed all steps of your solution but it didn't work out. I am facing the same error while extracting the tar file. I ignored it and and tried to binary directly. But it also failed (error code 127) . So I opened a new issue (alicevision/Meshroom#789)
Can you please help me out?
Thanks in advance.

@natowi
Copy link
Author

natowi commented Feb 15, 2020

You can use the previous version (without google drive) or this until I have some time to fix this notebook.

@soham0243
Copy link

Thanks I managed to run meshroom successfully.

@Geksaida
Copy link

How should I create .mg file and put it into this notebook to run my pipeline?

@natowi
Copy link
Author

natowi commented Mar 28, 2020

@Geksaedr Instead of meshroom_photogrammetry --input ./input --output ./out you can use meshroom_compute GRAPHFILE.mg [--node NODE_NAME] [--toNode NODE_NAME] [--cache FOLDER]
You can generate the Graph File in the Meshroom GUI on your computer, but you need to adjust the paths in the .mg file to match your colab folder structure.

@raphael2692
Copy link

I think a better solution to avoid untar problems (symlink etc) is just to use colab istance directory instead of mounted drive. I forked this notebook and applied this change here. It works fine

@natowi
Copy link
Author

natowi commented Jul 6, 2020

@raphael2692 Thanks, I was working on other projects and forgot to fix this notebook. I took the liberty to apply your changes :)

@raphael2692
Copy link

glad to help 😄

@sheIter
Copy link

sheIter commented Jul 11, 2020

Hey I have a problem, when i uploaded or mounted my drive with the pics, it says input: format not supported. The images are jpg and according to meshroom itself it should work?

@enoreyes
Copy link

Also having the same issue as @shelter

@natowi
Copy link
Author

natowi commented Jul 12, 2020

That´s strange...

@enoreyes
Copy link

enoreyes commented Jul 12, 2020

Actually, I think the issue was the files themselves. Meshroom does not like it when you include files with unknown EXIF metadata parameters. I was able to use images taken with my smartphone by stripping the metadata before I uploaded them to the drive. Perhaps it would be useful in the file upload part of this to strip the metadata or perform a check to ensure only supported metadata parameters are included. That is a bit beyond the scope of what i'm trying to do but I was able to strip metadata with this:

from PIL import Image

image = Image.open('image_file.jpeg')

# next 3 lines strip exif
data = list(image.getdata())
image_without_exif = Image.new(image.mode, image.size)
image_without_exif.putdata(data)

image_without_exif.save('image_file_without_exif.jpeg')

@natowi
Copy link
Author

natowi commented Jul 13, 2020

Yes, there can be issues with unsupported or corrupted metadata and unsupported characters/paths https://github.com/alicevision/meshroom/wiki/Images-cannot-be-imported

@sheIter
Copy link

sheIter commented Jul 13, 2020

Thanks for the response. I checked with my image all the things wiki told me to do and there was no problem, I also used the sample dataset from meshroom and it still produces the same error

@sheIter
Copy link

sheIter commented Jul 15, 2020

Sorry I dont know anything about coding. I replaced the line with yours in bracket for running meshroom but it gave me this error message meshroom_photogrammetry: error: unrecognized arguments: /content/out

@raphael2692
Copy link

Sorry I dont know anything about coding. I replaced the line with yours in bracket for running meshroom but it gave me this error message meshroom_photogrammetry: error: unrecognized arguments: /content/out

No worries, navigating the filesystem in colab could be tricky.

Try to always check the path by right clicking on the sidebar and always use double quotes.

E.g.

!/content/meshroom/Meshroom-2019.2.0/meshroom_photogrammetry --input "/content/input" --output "/content/out"

immagine

@sheIter
Copy link

sheIter commented Jul 16, 2020

Thanks you so much for your help. I should have read the last bracket really consciously. I didn't get that I need to copy my own paths in the last line, worked yesterday fine when i did it.

@jackdbd
Copy link

jackdbd commented Oct 22, 2020

Hey I have a problem, when i uploaded or mounted my drive with the pics, it says input: format not supported.

There is a typo in the Colab. It should be --input /content/input, not --input input

@ayushgupta9198
Copy link

Hello everyone

I have tried all the steps one by one but all the time i am receiving the same error , i have tried with all image formats but still the issue is same can you please help me in that , I am running this code in colab.

`Plugins loaded: CameraCalibration, CameraInit, CameraLocalization, CameraRigCalibration, CameraRigLocalization, ConvertSfMFormat, DepthMap, DepthMapFilter, ExportAnimatedCamera, ExportColoredPointCloud, ExportMaya, FeatureExtraction, FeatureMatching, ImageMatching, ImageMatchingMultiSfM, KeyframeSelection, LDRToHDR, MeshDecimate, MeshDenoising, MeshFiltering, MeshResampling, Meshing, PrepareDenseScene, Publish, SfMAlignment, SfMTransform, StructureFromMotion, Texturing
Program called with the following parameters:

  • allowSingleView = 1
  • defaultCameraModel = "" (default)
  • defaultFieldOfView = 45
  • defaultFocalLengthPix = -1 (default)
  • defaultIntrinsic = "" (default)
  • groupCameraFallback = Unknown Type "20EGroupCameraFallback"
  • imageFolder = "" (default)
  • input = "/tmp/tmpfuclkad5/CameraInit/c448939571d5c70b05c9ae4ad416ada37d6273ca//viewpoints.sfm"
  • output = "/tmp/tmpfuclkad5/CameraInit/c448939571d5c70b05c9ae4ad416ada37d6273ca/cameraInit.sfm"
  • sensorDatabase = "/content/meshroom/Meshroom-2019.2.0/aliceVision/share/aliceVision/cameraSensors.db"
  • verboseLevel = "info"

[11:38:41.909878][warning] Image 'shirt0_b.jpg' focal length (in mm) metadata is missing.
Can't compute focal length (px), use default.

[11:38:41.910090][warning] Some image(s) have no serial number to identify the camera/lens device.
This makes it impossible to correctly group the images by device if you have used multiple identical (same model) camera devices.
The reconstruction will assume that only one device has been used, so if 2 images share the same focal length approximation they will share the same internal camera parameters.
1 image(s) are concerned.
[11:38:41.910877][info] CameraInit report:
- # views listed: 1
- # views with an initialized intrinsic listed: 1
- # views without metadata (with a default intrinsic): 1
- # intrinsics listed: 1
Nodes to execute: ['CameraInit_1', 'FeatureExtraction_1', 'ImageMatching_1', 'FeatureMatching_1', 'StructureFromMotion_1', 'PrepareDenseScene_1', 'DepthMap_1', 'DepthMapFilter_1', 'Meshing_1', 'MeshFiltering_1', 'Texturing_1', 'Publish_1']

[1/12] CameraInit

  • commandLine: aliceVision_cameraInit --sensorDatabase "/content/meshroom/Meshroom-2019.2.0/aliceVision/share/aliceVision/cameraSensors.db" --defaultFieldOfView 45.0 --groupCameraFallback folder --verboseLevel info --output "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm" --allowSingleView 1 --input "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22//viewpoints.sfm"
  • logFile: /tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/log
  • elapsed time: 0:00:00.060493

[2/12] FeatureExtraction

  • commandLine: aliceVision_featureExtraction --input "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm" --describerTypes sift --describerPreset normal --forceCpuExtraction True --verboseLevel info --output "/tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7" --rangeStart 0 --rangeSize 40
  • logFile: /tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7/0.log
  • elapsed time: 0:00:10.666615

[3/12] ImageMatching

  • commandLine: aliceVision_imageMatching --input "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm" --featuresFolders "/tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7" --tree "/content/meshroom/Meshroom-2019.2.0/aliceVision/share/aliceVision/vlfeat_K80L3.SIFT.tree" --weights "" --minNbImages 200 --maxDescriptors 500 --nbMatches 50 --verboseLevel info --output "/tmp/MeshroomCache/ImageMatching/3db36665850427e4e77eb13e0f08f03b4f261a88/imageMatches.txt"
  • logFile: /tmp/MeshroomCache/ImageMatching/3db36665850427e4e77eb13e0f08f03b4f261a88/log
  • elapsed time: 0:00:00.228712

[4/12] FeatureMatching

  • commandLine: aliceVision_featureMatching --input "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm" --featuresFolders "/tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7" --imagePairsList "/tmp/MeshroomCache/ImageMatching/3db36665850427e4e77eb13e0f08f03b4f261a88/imageMatches.txt" --describerTypes sift --photometricMatchingMethod ANN_L2 --geometricEstimator acransac --geometricFilterType fundamental_matrix --distanceRatio 0.8 --maxIteration 2048 --geometricError 0.0 --maxMatches 0 --savePutativeMatches False --guidedMatching False --exportDebugFiles False --verboseLevel info --output "/tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204" --rangeStart 0 --rangeSize 20
  • logFile: /tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204/0.log
  • elapsed time: 0:00:00.049744

[5/12] StructureFromMotion

  • commandLine: aliceVision_incrementalSfM --input "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm" --featuresFolders "/tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7" --matchesFolders "/tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204" --describerTypes sift --localizerEstimator acransac --localizerEstimatorMaxIterations 4096 --localizerEstimatorError 0.0 --lockScenePreviouslyReconstructed False --useLocalBA True --localBAGraphDistance 1 --maxNumberOfMatches 0 --minInputTrackLength 2 --minNumberOfObservationsForTriangulation 2 --minAngleForTriangulation 3.0 --minAngleForLandmark 2.0 --maxReprojectionError 4.0 --minAngleInitialPair 5.0 --maxAngleInitialPair 40.0 --useOnlyMatchesFromInputFolder False --useRigConstraint True --lockAllIntrinsics False --initialPairA "" --initialPairB "" --interFileExtension .abc --verboseLevel info --output "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/sfm.abc" --outputViewsAndPoses "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/cameras.sfm" --extraInfoFolder "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893"
  • logFile: /tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/log
  • elapsed time: 0:00:00.078160
    ERROR:root:Error on node computation: Error on node "StructureFromMotion_1":
    Log:
    Program called with the following parameters:
  • describerTypes = "sift"
  • extraInfoFolder = "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893"
  • featuresFolders = = [/tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7]
  • initialPairA = ""
  • initialPairB = ""
  • input = "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm"
  • interFileExtension = ".abc"
  • localBAGraphDistance = 1
  • localizerEstimator = Unknown Type "N11aliceVision16robustEstimation16ERobustEstimatorE"
  • localizerEstimatorError = 0
  • localizerEstimatorMaxIterations = 4096
  • lockAllIntrinsics = 0
  • lockScenePreviouslyReconstructed = 0
  • matchesFolders = = [/tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204]
  • maxAngleInitialPair = 40
  • maxNumberOfMatches = 0
  • maxReprojectionError = 4
  • minAngleForLandmark = 2
  • minAngleForTriangulation = 3
  • minAngleInitialPair = 5
  • minInputTrackLength = 2
  • minNumberOfObservationsForTriangulation = 2
  • output = "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/sfm.abc"
  • outputViewsAndPoses = "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/cameras.sfm"
  • useLocalBA = 1
  • useOnlyMatchesFromInputFolder = 0
  • useRigConstraint = 1
  • useTrackFiltering = 1 (default)
  • verboseLevel = "info"

Loading features
0% 10 20 30 40 50 60 70 80 90 100%
|----|----|----|----|----|----|----|----|----|----|
[11:38:53.086174][info] Supported CUDA-Enabled GPU detected.


[11:38:53.087798][warning] No matches file loaded in: /tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204
[11:38:53.087856][warning] - /tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204

[11:38:53.087880][error] Unable to load matches.

WARNING: downgrade status on node "PrepareDenseScene_1(0)" from Status.SUBMITTED to Status.NONE
WARNING: downgrade status on node "DepthMap_1(0)" from Status.SUBMITTED to Status.NONE
WARNING: downgrade status on node "DepthMapFilter_1(0)" from Status.SUBMITTED to Status.NONE
WARNING: downgrade status on node "Meshing_1" from Status.SUBMITTED to Status.NONE
WARNING: downgrade status on node "MeshFiltering_1" from Status.SUBMITTED to Status.NONE
WARNING: downgrade status on node "Texturing_1" from Status.SUBMITTED to Status.NONE
WARNING: downgrade status on node "Publish_1" from Status.SUBMITTED to Status.NONE
Traceback (most recent call last):
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/cx_Freeze/initscripts/startup.py", line 14, in run
File "/opt/Meshroom/setupInitScriptUnix.py", line 39, in run
File "bin/meshroom_photogrammetry", line 144, in
File "/opt/Meshroom/meshroom/core/graph.py", line 1131, in executeGraph
File "/opt/Meshroom/meshroom/core/node.py", line 274, in process
File "/opt/Meshroom/meshroom/core/desc.py", line 453, in processChunk
RuntimeError: Error on node "StructureFromMotion_1":
Log:
Program called with the following parameters:

  • describerTypes = "sift"
  • extraInfoFolder = "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893"
  • featuresFolders = = [/tmp/MeshroomCache/FeatureExtraction/ed56ccf2ed755df819eb6e8e0403eb4eb4b5d9f7]
  • initialPairA = ""
  • initialPairB = ""
  • input = "/tmp/MeshroomCache/CameraInit/232be0b607cc30746c5e4c170ed2b92b93706d22/cameraInit.sfm"
  • interFileExtension = ".abc"
  • localBAGraphDistance = 1
  • localizerEstimator = Unknown Type "N11aliceVision16robustEstimation16ERobustEstimatorE"
  • localizerEstimatorError = 0
  • localizerEstimatorMaxIterations = 4096
  • lockAllIntrinsics = 0
  • lockScenePreviouslyReconstructed = 0
  • matchesFolders = = [/tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204]
  • maxAngleInitialPair = 40
  • maxNumberOfMatches = 0
  • maxReprojectionError = 4
  • minAngleForLandmark = 2
  • minAngleForTriangulation = 3
  • minAngleInitialPair = 5
  • minInputTrackLength = 2
  • minNumberOfObservationsForTriangulation = 2
  • output = "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/sfm.abc"
  • outputViewsAndPoses = "/tmp/MeshroomCache/StructureFromMotion/7a3ed6fdabee6e7bf1f90a968b38d938db562893/cameras.sfm"
  • useLocalBA = 1
  • useOnlyMatchesFromInputFolder = 0
  • useRigConstraint = 1
  • useTrackFiltering = 1 (default)
  • verboseLevel = "info"

Loading features
0% 10 20 30 40 50 60 70 80 90 100%
|----|----|----|----|----|----|----|----|----|----|
[11:38:53.086174][info] Supported CUDA-Enabled GPU detected.


[11:38:53.087798][warning] No matches file loaded in: /tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204
[11:38:53.087856][warning] - /tmp/MeshroomCache/FeatureMatching/e2816c11ae36004f2ee109f0bbf26cafab819204

[11:38:53.087880][error] Unable to load matches.
`

thanks

@i2rlabs
Copy link

i2rlabs commented May 11, 2022

@ayushgupta9198 you can solve problem?

@ayushgupta9198
Copy link

@i2rlabs Yes it was solved

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