From d30571ce7d4f8a11b56db4dfd57d25baf295a0a0 Mon Sep 17 00:00:00 2001 From: Remy Mellet Date: Mon, 26 Jul 2021 17:14:05 +0200 Subject: [PATCH] Draft Reconstruction pipeline --- bin/meshroom_batch | 4 ++-- meshroom/multiview.py | 44 +++++++++++++++++++++++++++++++++++ meshroom/ui/qml/main.qml | 4 ++++ meshroom/ui/reconstruction.py | 3 +++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/bin/meshroom_batch b/bin/meshroom_batch index bfa388c4..3adcddfe 100755 --- a/bin/meshroom_batch +++ b/bin/meshroom_batch @@ -20,8 +20,8 @@ parser.add_argument('-I', '--inputRecursive', metavar='FOLDERS/IMAGES', type=str default=[], help='Input folders containing all images recursively.') -parser.add_argument('-p', '--pipeline', metavar='photogrammetry/panoramaHdr/panoramaFisheyeHdr/MG_FILE', type=str, default='photogrammetry', - help='"photogrammetry", "panoramaHdr", "panoramaFisheyeHdr", "cameraTracking" pipeline or a Meshroom file containing a custom pipeline to run on input images. ' +parser.add_argument('-p', '--pipeline', metavar='photogrammetry/panoramaHdr/panoramaFisheyeHdr/cameraTracking/photogrammetryDraft/MG_FILE', type=str, default='photogrammetry', + help='"photogrammetry", "panoramaHdr", "panoramaFisheyeHdr", "cameraTracking", "photogrammetryDraft" pipeline or a Meshroom file containing a custom pipeline to run on input images. ' 'Requirements: the graph must contain one CameraInit node, ' 'and one Publish node if --output is set.') diff --git a/meshroom/multiview.py b/meshroom/multiview.py index 7380b0ea..56aaa61e 100644 --- a/meshroom/multiview.py +++ b/meshroom/multiview.py @@ -557,3 +557,47 @@ def photogrammetryAndCameraTracking(inputImages=list(), inputViewpoints=list(), return graph + +def photogrammetryDraft(inputImages=None, inputViewpoints=None, inputIntrinsics=None, output='', graph=None): + """ + Create a new Graph with a complete photogrammetry pipeline without requiring a NVIDIA CUDA video card. Something also named Draft Meshing. + More information on that pipeline https://github.com/alicevision/meshroom/wiki/Draft-Meshing + + Args: + inputImages (list of str, optional): list of image file paths + inputViewpoints (list of Viewpoint, optional): list of Viewpoints + output (str, optional): the path to export reconstructed model to + + Returns: + Graph: the created graph + """ + if not graph: + graph = Graph('PhotogrammetryDraft') + with GraphModification(graph): + sfmNodes = sfmPipeline(graph) + sfmNode = sfmNodes[-1] + + meshing = graph.addNewNode('Meshing', + input=sfmNode.output) + + meshFiltering = graph.addNewNode('MeshFiltering', + inputMesh=meshing.outputMesh) + texturing = graph.addNewNode('Texturing', + input=meshing.output, + inputMesh=meshFiltering.outputMesh) + + cameraInit = sfmNodes[0] + + if inputImages: + cameraInit.viewpoints.extend([{'path': image} for image in inputImages]) + if inputViewpoints: + cameraInit.viewpoints.extend(inputViewpoints) + if inputIntrinsics: + cameraInit.intrinsics.extend(inputIntrinsics) + + if output: + graph.addNewNode('Publish', output=output, inputFiles=[texturing.outputMesh, + texturing.outputMaterial, + texturing.outputTextures]) + + return graph diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index 7792411d..1a7a1053 100755 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -436,6 +436,10 @@ ApplicationWindow { text: "Camera Tracking (experimental)" onTriggered: ensureSaved(function() { _reconstruction.new("cameratracking") }) } + Action { + text: "Photogrammetry Draft (No CUDA)" + onTriggered: ensureSaved(function() { _reconstruction.new("photogrammetrydraft") }) + } } Action { id: openActionItem diff --git a/meshroom/ui/reconstruction.py b/meshroom/ui/reconstruction.py index 96c9205f..231a0f81 100755 --- a/meshroom/ui/reconstruction.py +++ b/meshroom/ui/reconstruction.py @@ -496,6 +496,9 @@ class Reconstruction(UIGraph): elif p.lower() == "cameratracking": # default camera tracking pipeline self.setGraph(multiview.cameraTracking()) + elif p.lower() == "photogrammetrydraft": + # photogrammetry pipeline in draft mode (no cuda) + self.setGraph(multiview.photogrammetryDraft()) else: # use the user-provided default photogrammetry project file self.load(p, setupProjectFile=False)