[reconstruction] small structural re-organization

* move LiveSfmManager.stepCreated to Reconstruction.sfmAugmented
* add utility methods in Reconstruction to get all images/views used in the graph
* ui: perform local auto-layout on sfm augmentation on created nodes
This commit is contained in:
Yann Lanthony 2018-03-12 14:50:38 +01:00
parent 4f392a310b
commit 9f2dbc9639
4 changed files with 24 additions and 13 deletions

View file

@ -223,6 +223,7 @@ class QObjectListModel(QtCore.QAbstractListModel):
"""
return obj in self._objects
@QtCore.Slot(QtCore.QObject, result=int)
def indexOf(self, matchObj, fromIndex=0, positive=True):
""" Returns the index position of the first occurrence of object in
the model, searching forward from index position from.

View file

@ -25,12 +25,6 @@ Panel {
padding: 2
clip: true
Connections {
target: root.liveSfmManager
// Request graph auto-layout when an augmentation step is added for readability
onStepCreated: requestGraphAutoLayout()
}
Platform.FolderDialog {
id: selectFolderDialog
title: "Live Reconstruction - Select Image Folder"

View file

@ -286,6 +286,17 @@ ApplicationWindow {
}
}
Connections {
target: _reconstruction
// Request graph auto-layout when an augmentation step is added for readability
onSfmAugmented: graphEditor.doAutoLayout(_reconstruction.graph.nodes.indexOf(arguments[0]),
_reconstruction.graph.nodes.indexOf(arguments[1]),
0,
graphEditor.boundingBox().height + graphEditor.gridSpacing
)
}
Controls1.SplitView {
anchors.fill: parent
orientation: Qt.Vertical

View file

@ -59,7 +59,7 @@ class LiveSfmManager(QObject):
self._folder = folder
self.folderChanged.emit()
self.cameraInit = self.sfm = None
self.allImages = self.imagesInReconstruction()
self.allImages = self.reconstruction.allImagePaths()
self.minImagesPerStep = minImagesPerStep
self.setRunning(True)
self.update() # trigger initial update
@ -94,7 +94,6 @@ class LiveSfmManager(QObject):
self.reconstruction.beginModification("SfM Augmentation")
# Add SfM augmentation step in the graph
self.cameraInit, self.sfm = self.reconstruction.addSfmAugmentation()
self.stepCreated.emit()
self.addImageToStep(imagePath)
# If we have enough images and the graph is not being computed, compute augmentation step
@ -115,9 +114,6 @@ class LiveSfmManager(QObject):
""" Get images in the current augmentation step. """
return self.imagePathsInCameraInit(self.cameraInit) if self.cameraInit else []
def imagesInReconstruction(self):
""" Get all images in the reconstruction. """
return [vp.path.value for node in self.reconstruction.cameraInits for vp in node.viewpoints]
@Slot()
def computeStep(self):
@ -137,7 +133,6 @@ class LiveSfmManager(QObject):
self.reconstruction.endModification()
self.reconstruction.execute(sfm)
stepCreated = Signal()
runningChanged = Signal()
running = Property(bool, lambda self: self._running, notify=runningChanged)
folderChanged = Signal()
@ -296,9 +291,17 @@ class Reconstruction(UIGraph):
# connect last SfM node to ImageMatchingMultiSfm
self.addEdge(sfm.output, imageMatching.inputB)
self.sfmAugmented.emit(cameraInit, structureFromMotion)
return cameraInit, structureFromMotion
def allImagePaths(self):
""" Get all image paths in the reconstruction. """
return [vp.path.value for node in self._cameraInits for vp in node.viewpoints]
def allViewIds(self):
""" Get all view Ids involved in the reconstruction. """
return [vp.viewId.value for node in self._cameraInits for vp in node.viewpoints]
@Slot(QObject, graph.Node)
def handleFilesDrop(self, drop, cameraInit):
""" Handle drop events aiming to add images to the Reconstruction.
@ -426,3 +429,5 @@ class Reconstruction(UIGraph):
sfmReportChanged = Signal()
# convenient property for QML binding re-evaluation when sfm report changes
sfmReport = Property(bool, lambda self: len(self._poses) > 0, notify=sfmReportChanged)
sfmAugmented = Signal(graph.Node, graph.Node)