[reconstruction] use multiview.sfmAugmentation

use centralized 'sfmAugmentation' method + create MVS pipeline when augmenting the reconstruction
This commit is contained in:
Yann Lanthony 2018-03-15 16:03:55 +01:00
parent d4c0d4cb36
commit 5740a0a9b2

View file

@ -245,7 +245,7 @@ class Reconstruction(UIGraph):
sfmNodes = self._graph.nodesFromNode(self._cameraInits[0], 'StructureFromMotion')[0] sfmNodes = self._graph.nodesFromNode(self._cameraInits[0], 'StructureFromMotion')[0]
return sfmNodes[-1] if sfmNodes else None return sfmNodes[-1] if sfmNodes else None
def addSfmAugmentation(self): def addSfmAugmentation(self, withMVS=False):
""" """
Create a new augmentation step connected to the last SfM node of this Reconstruction and Create a new augmentation step connected to the last SfM node of this Reconstruction and
return the created CameraInit and SfM nodes. return the created CameraInit and SfM nodes.
@ -253,6 +253,9 @@ class Reconstruction(UIGraph):
If the Reconstruction is not initialized (empty initial CameraInit), this method won't If the Reconstruction is not initialized (empty initial CameraInit), this method won't
create anything and return initial CameraInit and SfM nodes. create anything and return initial CameraInit and SfM nodes.
Args:
withMVS (bool): whether to create the MVS pipeline after the augmentation
Returns: Returns:
Node, Node: CameraInit, StructureFromMotion Node, Node: CameraInit, StructureFromMotion
""" """
@ -267,31 +270,10 @@ class Reconstruction(UIGraph):
return self._cameraInit, sfm return self._cameraInit, sfm
with self.groupedGraphModification("SfM Augmentation"): with self.groupedGraphModification("SfM Augmentation"):
# instantiate sfm augmentation chain sfm, mvs = multiview.sfmAugmentation(self, self.lastSfmNode(), withMVS=withMVS)
cameraInit = self.addNode('CameraInit')
featureExtraction = self.addNode('FeatureExtraction')
imageMatching = self.addNode('ImageMatchingMultiSfM')
featureMatching = self.addNode('FeatureMatching')
structureFromMotion = self.addNode('StructureFromMotion')
edges = ( self.sfmAugmented.emit(sfm[0], mvs[-1])
(cameraInit.output, featureExtraction.input), return sfm[0], sfm[-1]
(featureExtraction.input, imageMatching.input),
(featureExtraction.output, imageMatching.featuresFolder),
(imageMatching.featuresFolder, featureMatching.featuresFolder),
(imageMatching.outputCombinedSfM, featureMatching.input),
(imageMatching.output, featureMatching.imagePairsList),
(featureMatching.input, structureFromMotion.input),
(featureMatching.featuresFolder, structureFromMotion.featuresFolder),
(featureMatching.output, structureFromMotion.matchesFolder),
)
for src, dst in edges:
self.addEdge(src, dst)
# connect last SfM node to ImageMatchingMultiSfm
self.addEdge(sfm.output, imageMatching.inputB)
self.sfmAugmented.emit(cameraInit, structureFromMotion)
return cameraInit, structureFromMotion
def allImagePaths(self): def allImagePaths(self):
""" Get all image paths in the reconstruction. """ """ Get all image paths in the reconstruction. """
@ -387,7 +369,7 @@ class Reconstruction(UIGraph):
# are updated after "addSfmAugmentation" (useful for auto layout) # are updated after "addSfmAugmentation" (useful for auto layout)
with self.groupedGraphModification(commandTitle, disableUpdates=False): with self.groupedGraphModification(commandTitle, disableUpdates=False):
if augmentSfM: if augmentSfM:
cameraInit, self.sfm = self.addSfmAugmentation() cameraInit, self.sfm = self.addSfmAugmentation(withMVS=True)
with self.groupedGraphModification("Set Views and Intrinsics"): with self.groupedGraphModification("Set Views and Intrinsics"):
self.setAttribute(cameraInit.viewpoints, views) self.setAttribute(cameraInit.viewpoints, views)
self.setAttribute(cameraInit.intrinsics, intrinsics) self.setAttribute(cameraInit.intrinsics, intrinsics)