From 6e270ad6a9e061542e9f426c31a2c128a7911f8d Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Mon, 16 Oct 2017 17:55:54 +0200 Subject: [PATCH] Use imageMatching node in the multiview pipeline --- bin/meshroom_photogrammetry | 2 +- meshroom/core/graph.py | 18 +++++++++--------- meshroom/multiview.py | 15 ++++++++++----- meshroom/nodes/aliceVision/ImageMatching.py | 11 +++++++++-- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/bin/meshroom_photogrammetry b/bin/meshroom_photogrammetry index 3cb12df1..2066b673 100755 --- a/bin/meshroom_photogrammetry +++ b/bin/meshroom_photogrammetry @@ -28,7 +28,7 @@ if not args.output and not args.save: graph = multiview.photogrammetryPipeline() if args.input: - cameraInit = graph.findNodeCandidates("CameraInit") + cameraInit = graph.findNode("CameraInit") cameraInit.imageDirectory.value = args.input if args.save: diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index dc288213..2d8b789c 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -631,16 +631,16 @@ class Graph(BaseObject): pattern = re.compile(nodeNameExpr) return [v for k, v in self._nodes.objects.items() if pattern.match(k)] + def findNode(self, nodeExpr): + candidates = self.findNodeCandidates('^' + nodeExpr) + if not candidates: + raise KeyError('No node candidate for "{}"'.format(nodeExpr)) + elif len(candidates) > 1: + raise KeyError('Multiple node candidates for "{}": {}'.format(nodeExpr, str([c.name for c in candidates]))) + return candidates[0] + def findNodes(self, nodesExpr): - out = [] - for nodeName in nodesExpr: - candidates = self.findNodeCandidates('^' + nodeName) - if not candidates: - raise KeyError('No node candidate for "{}"'.format(nodeName)) - elif len(candidates) > 1: - raise KeyError('Multiple node candidates for "{}": {}'.format(nodeName, str([c.name for c in candidates]))) - out.append(candidates[0]) - return out + return [self.findNode(nodeName) for nodeName in nodesExpr] def edge(self, dstAttributeName): return self._edges.get(dstAttributeName) diff --git a/meshroom/multiview.py b/meshroom/multiview.py index 288b0562..d09aab81 100644 --- a/meshroom/multiview.py +++ b/meshroom/multiview.py @@ -6,16 +6,19 @@ from .core.graph import Graph def photogrammetryPipeline(): # type: () -> Graph graph = Graph('pipeline') - cameraInit = graph.addNewNode('CameraInit', - sensorDatabase=os.environ.get('ALICEVISION_SENSOR_DB', 'sensor_width_camera_database.txt')) - + sensorDatabase=os.environ.get('ALICEVISION_SENSOR_DB', None)) featureExtraction = graph.addNewNode('FeatureExtraction', input=cameraInit.outputSfm) - # TODO: imageMatching + imageMatching = graph.addNewNode('ImageMatching', + input=cameraInit.outputSfm, + featuresDirectory=featureExtraction.output, + tree=os.environ.get('ALICEVISION_VOCTREE', None), + ) featureMatching = graph.addNewNode('FeatureMatching', input=cameraInit.outputSfm, - featuresDirectory=featureExtraction.output) + featuresDirectory=featureExtraction.output, + imagePairsList=imageMatching.output) structureFromMotion = graph.addNewNode('StructureFromMotion', input=cameraInit.outputSfm, featuresDirectory=featureExtraction.output, @@ -33,3 +36,5 @@ def photogrammetryPipeline(): texturing = graph.addNewNode('Texturing', mvsConfig=meshing.mvsConfig) return graph + + diff --git a/meshroom/nodes/aliceVision/ImageMatching.py b/meshroom/nodes/aliceVision/ImageMatching.py index bf9e4452..79336928 100644 --- a/meshroom/nodes/aliceVision/ImageMatching.py +++ b/meshroom/nodes/aliceVision/ImageMatching.py @@ -13,6 +13,13 @@ class ImageMatching(desc.CommandLineNode): uid=[0], isOutput=False, ) + featuresDirectory = desc.File( + label='Features Directory', + description='''Directory containing the extracted features and descriptors. By default, it is the directory containing the SfMData.''', + value='', + uid=[0], + isOutput=False, + ) tree = desc.File( label='Tree', description='''Input name for the vocabulary tree file.''', @@ -22,8 +29,8 @@ class ImageMatching(desc.CommandLineNode): ) output = desc.File( label='Output', - description='''Filepath to the output file with the list of selected image pairs. Optional parameters:''', - value='{cache}/{nodeType}/{uid0}/', + description='''Filepath to the output file with the list of selected image pairs.''', + value='{cache}/{nodeType}/{uid0}/imageMatches.txt', uid=[], isOutput=True, )