Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom CLI pipe #851

Closed
NexTechAR-Scott opened this issue Apr 8, 2020 · 27 comments
Closed

Custom CLI pipe #851

NexTechAR-Scott opened this issue Apr 8, 2020 · 27 comments
Labels
cli anything related to the command line type:question

Comments

@NexTechAR-Scott
Copy link

Meshroom 2019.2.0 on Linux

Running pure CLI pipe.

For changing node parameters I've been dropping uncompiled .py from the Develop branch in place of the compiled nodes from the release.

Works great.

I'd like to add a denoise and decimate node to the pipe but for the life of me I can not figure out where or how to create a custom base project.mg

I've spent a good deal of time looking and this does not seem to be documented anywhere.

Thank you for any leads you may be able to provide.

@natowi
Copy link
Member

natowi commented Apr 8, 2020

When using meshroom_photogrammetry you can to set a parameter directly from the command line: "--paramOverrides NODE.param=value"

To add nodes, use 1) a Meshroom mg file created via the GUI (--pipeline graph.mg), 2) --save the default graph and manually edit it or 3) manually create your graph in the CLI by adding the nodes in the order you want, including parameters.

Default parameters are used when no parameters are set. Parameters printed to the Meshroom GUI Log can be used as reference. Example (you need to adjust the path to your OS):

aliceVision_cameraInit --sensorDatabase "PATH-TO\Meshroom-2019.2.0\aliceVision\share\aliceVision\cameraSensors.db" --defaultFieldOfView 45.0 --groupCameraFallback folder --verboseLevel info --output "PATH-TO/MeshroomCache/CameraInit/ea736ae9/cameraInit.sfm" --allowSingleView 1 --input "PATH-TO/MeshroomCache/CameraInit/ea736ae9/viewpoints.sfm"

https://github.com/alicevision/AliceVision/wiki/CLI-Parameters

@NexTechAR-Scott
Copy link
Author

Thanks but still struggling here. Let me see if I can restate the question.

I would like to alter / edit / refine the default parameters / graph if possible.

This will be running entirely headless / automated.

We have a pipe already that takes populates inputs and the pipe runs CLI through to final output.

We are creating directories with uid's, populating with input and output directories. We have a separate process that populates the inputs. We run meshroom and save the project.mg in the project directory.

I get that we can create a new graph using GUI which we have done but for the life of me can not get it to load as the default or rather in place of the default graph so that it is saved as our project.mg

The relevant portions of the script.

Scaffold project file for meshroom project
os.system("{!s}/meshroom_photogrammetry --input {!s}/{!s}/input --output {!s}/{!s}/output --save {!s}/{!s}/project.mg"

Start processing meshroom project file
os.system("{!s}/meshroom_compute {!s}/{!s}/project.mg --toNode Publish_1 --forceStatus"

Thoughts?

Thank you

@fabiencastan
Copy link
Member

You should add "--pipeline path/to/your_custom_pipeline.mg" to your meshroom_photogrammetry command line.

@simogasp
Copy link
Member

simogasp commented Apr 10, 2020

Hi @NexTechAR-Scott ,
please also refer to this other issue
#683 (comment)

@simogasp simogasp added the cli anything related to the command line label Apr 10, 2020
@NexTechAR-Scott
Copy link
Author

Update. All working as intended and expected.

Issue was unrelated, if part of my script failed it was not recovering cleanly.

Thanks for the input.

@Sachet12345
Copy link

Hi @natowi, how to manually create graph in CLI? Could you give an example?

@natowi
Copy link
Member

natowi commented Nov 5, 2020

@Sachet12345 use meshroom_photogrammetry with your graph created in the meshroom gui.
Otherwise you need to call each node in correct order and provide input and output paths. https://github.com/alicevision/AliceVision/wiki/CLI-Tools
https://github.com/alicevision/AliceVision/wiki/CLI-Parameters

@vinayadatta
Copy link

Solved! - Meshroom CLI with custom node settings on Google Colab

This solution was tested on Google Colab using a script from AB3D-Studio. Download the "RunMeshroom.ipynb" script file. You can check out the YouTube tutorial here for the complete setup.

Steps:

  1. Open your local Meshroom GUI and set up all the nodes and their parameters as per your desired requirements.

  2. Save your file as MyMESH.mg and copy it to your Google Drive (My Drive/Documents for example).

  3. Open Google Colab, upload the notebook script "RunMeshroom.ipynb" and follow the instructions to mount your google drive.

  4. Copy your input files to your folder in Google Drive.

  5. Copy the file paths of MyMesh.mg and your input files from Colab and replace all the file paths inside your MyMesh.mg file. You might have to be careful while doing this. Make sure you have completely replaced all the local paths to the Colab's reference paths. For example inputs > path: "C:\Users\USER_NAME\Documents" to path: "/content/drive/My Drive/Documents/".

  6. If you haven't set a custom output folder in your Publish Node, the output is saved in the default cache folder.

  7. Now run this command under 'Meshing' after you have performed the above steps correctly:
    !./meshroom/Meshroom-2020.1.0/meshroom_compute --forceCompute /content/drive/My Drive/Documents/MyMesh.mg

Note:
Check the Meshroom version that you are using, I have used the 2020 version.
Check CLI Parameters for more info.

@natowi
Copy link
Member

natowi commented Nov 14, 2020

@vinayadatta thanks, I have added this to the wiki.

@RayzedByRobots
Copy link

@vinayadatta @natowi thank you! Could you add some more detail around replacing the file paths inside the MyMesh.mg file? Background: I'm using meshroom 2020.1.1 on my PC and the RunMeshroom.ipynb is using meshroom 2019.1.0 - not sure if this is an issue.

When I open my adapted .mg file in colab I see what I think is where the program is looking for the images:
"sensorDatabase": "C:\Program Files\Meshroom\Meshroom-2020.1.1\aliceVision\share\aliceVision\cameraSensors.db",

So I copied the path to my images on google drive and replaced the above with:
"sensorDatabase": "/content/drive/MyDrive/Science/Coral/PDAM_H_Davis/E2",

The only other path I see is:
"tree": "C:\Program Files\Meshroom\Meshroom-2020.1.1\aliceVision\share\aliceVision\vlfeat_K80L3.SIFT.tree",
Do I need to change this or anything else in the .mg file?

I ran this command under "Meshing" as suggested above (#7)
!./meshroom/Meshroom-2020.1.0/meshroom_compute --forceCompute /content/drive/MyDrive/Science/MeshroomRunFiles/MyMESHwHigh.mg

And got back an error when I run:
/bin/bash: ./meshroom/Meshroom-2020.1.0/meshroom_compute: No such file or directory

Any help would be appreciated. thank you.

@vinayadatta
Copy link

@RayzedByRobots, I believe you are in the right path but missing a few things..

  1. You need to replace anything that starts with C:/ or any drive letter that points to your local storage location, to the Google drive link..
  2. "C:\Program Files\Meshroom\Meshroom-2020.1.1\aliceVision\share\aliceVision\vlfeat_K80L3.SIFT.tree" will be “/content/drive/MyDrive/Meshroom/Meshroom-2020.1.1/aliceVision/share/aliceVision/vlfeat_K80L3.SIFT.tree".. Try to extract or copy your Meshroom in your drive folder so that you don’t need to extract for every time..
  3. You’ll have to replace your input files’ path as well if they are showing up in your mg file..
  4. Try to use the same Meshroom version on both windows and Colab (Linux).. The last stable version that I found working on both the platforms was 2019.2.0 and there was no issues with Colab’s gpu usage as well..
  5. While you fix your Meshroom version to be used, you gotta be sure to use the file paths of the same version..

Your sensor database path that you mentioned looks to be having totally different folders.. Everything under Meshroom/Meshroom-version should remain same..

I guess that would solve your issue.. If not I can help you more..

@RayzedByRobots
Copy link

Great thanks I'll try right now to make your suggestions. One other quick question - how do you reset the notebook? Return it to its original form - it seems if you use the notebook a couple times or change something it doesn't like - errors like "can't create a file because it already exists" start to show up which are hard to get rid of.

@RayzedByRobots
Copy link

@vinayadatta - I followed your 1-3 above - I didn't understand "Try to extract or copy your Meshroom in your drive folder so that you don’t need to extract for every time." - but let's hold off on that for now if it is not critical to things working

I got a little farther, but it is still not working yet - more background - I am running the default meshroom nodes with featureExtraction on high and with guidedMatching turned on.

Review:
I made two changes to my .mg file (called MyMESHwHigh.mg) so both paths are now directed at google drive; my images are in the file E2

  1. "sensorDatabase": "/content/drive/MyDrive/Science/Coral/PDAM_H_Davis/E2",
  2. "tree": "/content/meshroom/Meshroom-2019.1.0/aliceVision/share/aliceVision/vlfeat_K80L3.SIFT.tree",

In Meshing, I used the command:
!./meshroom/Meshroom-2019.1.0/meshroom_compute --forceCompute /content/drive/MyDrive/Science/MeshroomRunFiles/MyMESHwHigh.mg

I get back an error:
mkdir: cannot create directory ‘/content/drive/MyDrive/Science/Coral/PDAM_H_Davis/E2’: File exists
Plugins loaded: CameraCalibration, CameraInit, CameraLocalization, CameraRigCalibration, CameraRigLocalization, ConvertSfMFormat, DepthMap, DepthMapFilter, ExportAnimatedCamera, ExportMaya, FeatureExtraction, FeatureMatching, ImageMatching, ImageMatchingMultiSfM, KeyframeSelection, MeshDecimate, MeshDenoising, MeshFiltering, MeshResampling, Meshing, PrepareDenseScene, Publish, SfMAlignment, SfMTransform, StructureFromMotion, Texturing
WARNING:root:Compatibility issue detected for node 'CameraInit_1': VersionConflict
WARNING:root:Compatibility issue detected for node 'FeatureExtraction_1': DescriptionConflict
WARNING:root:Compatibility issue detected for node 'ImageMatching_1': VersionConflict
WARNING:root:Compatibility issue detected for node 'FeatureMatching_1': DescriptionConflict
WARNING:root:Compatibility issue detected for node 'StructureFromMotion_1': DescriptionConflict
WARNING:root:Compatibility issue detected for node 'PrepareDenseScene_1': VersionConflict
WARNING:root:Compatibility issue detected for node 'DepthMapFilter_1': VersionConflict
WARNING:root:Compatibility issue detected for node 'Meshing_1': VersionConflict
WARNING:root:Compatibility issue detected for node 'MeshFiltering_1': VersionConflict
WARNING:root:Compatibility issue detected for node 'Texturing_1': VersionConflict
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']
WARNING: downgrade status on node "CameraInit_1" from Status.ERROR to Status.SUBMITTED

Does this error have to do with a version conflict? My .mg file was made on meshroom 2020.1.1 and the notebook uses 2019.1.0

If so can someone provide a link to a notebook that uses 2020.1.1? I would rather do that than to uninstall 2020.1.1 from my PC. or if there is another way. THANKS!!

@natowi
Copy link
Member

natowi commented Jan 6, 2021

@RayzedByRobots

My .mg file was made on meshroom 2020.1.1 and the notebook uses 2019.1.0

Don´t mix versions. mg files are not backward compatible. There is some forward compatibility, but it is not recommended.

I would rather do that than to uninstall 2020.1.1 from my PC.

You can use multiple Meshroom versions on one computer.

It should be no problem to change the notebook to the 2020 version. Please open a new issue if you have any issues with that.

@RayzedByRobots
Copy link

Ok thank you for the reply. I'll try to get the versions to match.

Thanks

@juanjosse
Copy link

Hi, one question: What is the recommended way of running a custom pipeline: e.g: I want to call the different nodes: cameraInit, featureExtraction,... but in some intermediate steps call to custom python scripts which manipulate some data.

I have written a BASH file which call them and create the folders for the input/output storage, but in the deptMapFilter stage I have observed that meshroom iterates with different parameters probably to fit the value.

How can I take it into account or where is a script to call this commandLine instructions so I can modify for my custom pipeline?

Thank you

@fabiencastan
Copy link
Member

The easiest way would be to create your custom nodes and implement your custom steps in it.
You can look at the Publish node for a simple example.

@juanjosse
Copy link

juanjosse commented Mar 31, 2022

But how are the nodes supposed to be run through the pipeline? I have already created a couple of custom nodes in .py and in the GUI I connect them to the rest of default nodes and the results are OK.
But I don't know how to call the nodes (even the original ones) from the command line. Is there a example or tutorial somewhere?
Thank you.

@NexTechAR-Scott
Copy link
Author

Open a new project in gui mode

Set your nodes the way you want.

Save

Navigate to project folder and find graphfile.mg

That is your saved node settings

call that from your batch

@juanjosse
Copy link

juanjosse commented Mar 31, 2022

Is it not supposed to be possible to call the different executables from aliceVision? I would like to do like a bash script calling them like this screenshot. But it seems than the depthMapFilter is called several time to adjust and so on. Where can I find the logic to call those scripts? Is there a bash file which call the executables or some python code? I would like to know how the executables are called.
Thank you.
image

(I try to replicate the meshroom cmd output when running from the GUI, but depending on the dataset, for example, the depthMapFilter is called several times changing one parameter (rangeStart) and I don't find this logic anywhere to replicate it.

@NexTechAR-Scott
Copy link
Author

graphfile.mg calls the individual nodes and tells them what to do.

it is effectively the batch file you are looking for

don’t make this harder than it needs to be by reinventing the wheel

@juanjosse
Copy link

And where is this "graphfile.mg"? I only see my project "projectName.mg", do you refer to that? Because it is a JSON. Thank you.

@NexTechAR-Scott
Copy link
Author

that’s it

name changed when you saved as

if you open a fresh project and check the folder before saving you will see the default name

the beauty of doing it this way is you can create as many custom graphs as you want for specific purposes / object types and call them as needed

youll have to pass some path parameters to it like where to import the data set from or use a drop / watch folder

meaning graphfile is set to import from a default location

obviously you’ll want to do some cleanup in that folder when the process completes

@juanjosse
Copy link

and then I run the meshroom_batch.exe with these graph.mg? Which parameter would it be? meshroom_bath.exe --overrides graphfile.mg??
(I find it difficult to fins documentation about this)
Thank you.

@juanjosse
Copy link

juanjosse commented Apr 1, 2022

Aham is meshroom_compute right?
Also I would be really grateful if you could help me with this issue, is one of the reasons why I wanted to create a BASH script, because the node implementation seems to have a non sense bug when you create a simple empty pasthrough node, the pipeline breaks without reason in depth map filter and nothing is done:

#1656

Thank you very much.

@NexTechAR-Scott
Copy link
Author

Sorry, had one of those days and had no time to assist on this.

I’ve run an automated solution for this on linux.

Happy to share those scripts which you should have no trouble porting to windows

I may need a day or two to dig them
up for you.

@juanjosse
Copy link

Ok, thank you very much. You mean the current issue or the new one I've referenced (#1656).
How can you share the scripts with me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli anything related to the command line type:question
Projects
None yet
Development

No branches or pull requests

8 participants