mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-22 21:46:28 +02:00
[ui] allow SfM augmentation when providing new images
* create two separate drop areas when adding images to the project (add images / augment reconstruction) * add sfm augmentation in graph after intrinsics have been built
This commit is contained in:
parent
b25fbcd00b
commit
450f800fef
3 changed files with 76 additions and 11 deletions
|
@ -26,7 +26,7 @@ Panel {
|
||||||
title: "Images"
|
title: "Images"
|
||||||
property int currentIndex: 0
|
property int currentIndex: 0
|
||||||
readonly property variant viewpoints: cameraInit.attribute('viewpoints').value
|
readonly property variant viewpoints: cameraInit.attribute('viewpoints').value
|
||||||
signal filesDropped(var drop)
|
signal filesDropped(var drop, var augmentSfm)
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -134,14 +134,56 @@ Panel {
|
||||||
enabled: !root.readOnly
|
enabled: !root.readOnly
|
||||||
// TODO: onEntered: call specific method to filter files based on extension
|
// TODO: onEntered: call specific method to filter files based on extension
|
||||||
onDropped: {
|
onDropped: {
|
||||||
root.filesDropped(drop)
|
var augmentSfm = augmentArea.hovered
|
||||||
|
root.filesDropped(drop, augmentSfm)
|
||||||
}
|
}
|
||||||
// DropArea overlay
|
|
||||||
|
// Background opacifier
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
visible: dropArea.containsDrag
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
opacity: 0.4
|
color: palette.window
|
||||||
visible: parent.containsDrag
|
opacity: 0.8
|
||||||
color: palette.highlight
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: dropArea.containsDrag
|
||||||
|
spacing: 1
|
||||||
|
Label {
|
||||||
|
id: addArea
|
||||||
|
property bool hovered: dropArea.drag.y < height
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
text: "Add Images"
|
||||||
|
font.bold: true
|
||||||
|
background: Rectangle {
|
||||||
|
color: parent.hovered ? palette.highlight : palette.window
|
||||||
|
opacity: 0.8
|
||||||
|
border.color: palette.highlight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DropArea overlay
|
||||||
|
Label {
|
||||||
|
id: augmentArea
|
||||||
|
property bool hovered: visible && dropArea.drag.y >= y
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: parent.height * 0.3
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
text: "Augment Reconstruction"
|
||||||
|
font.bold: true
|
||||||
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
|
visible: viewpoints.count > 0
|
||||||
|
background: Rectangle {
|
||||||
|
color: parent.hovered ? palette.highlight : palette.window
|
||||||
|
opacity: 0.8
|
||||||
|
border.color: palette.highlight
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ Item {
|
||||||
currentIndex: reconstruction.cameraInitIndex
|
currentIndex: reconstruction.cameraInitIndex
|
||||||
onCurrentIndexChanged: reconstruction.cameraInitIndex = currentIndex
|
onCurrentIndexChanged: reconstruction.cameraInitIndex = currentIndex
|
||||||
onRemoveImageRequest: reconstruction.removeAttribute(attribute)
|
onRemoveImageRequest: reconstruction.removeAttribute(attribute)
|
||||||
onFilesDropped: reconstruction.handleFilesDrop(drop, cameraInit)
|
onFilesDropped: reconstruction.handleFilesDrop(drop, augmentSfm ? null : cameraInit)
|
||||||
}
|
}
|
||||||
LiveSfmView {
|
LiveSfmView {
|
||||||
visible: settings_UILayout.showLiveReconstruction
|
visible: settings_UILayout.showLiveReconstruction
|
||||||
|
|
|
@ -344,7 +344,10 @@ class Reconstruction(UIGraph):
|
||||||
|
|
||||||
# Duplicate 'cameraInit' outside the graph.
|
# Duplicate 'cameraInit' outside the graph.
|
||||||
# => allows to compute intrinsics without modifying the node or the graph
|
# => allows to compute intrinsics without modifying the node or the graph
|
||||||
attributes = cameraInit.toDict()["attributes"]
|
# If cameraInit is None (i.e: SfM augmentation):
|
||||||
|
# * create an uninitialized node
|
||||||
|
# * wait for the result before actually creating new nodes in the graph (see onIntrinsicsAvailable)
|
||||||
|
attributes = cameraInit.toDict()["attributes"] if cameraInit else {}
|
||||||
cameraInitCopy = graph.Node("CameraInit", **attributes)
|
cameraInitCopy = graph.Node("CameraInit", **attributes)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -365,9 +368,29 @@ class Reconstruction(UIGraph):
|
||||||
|
|
||||||
def onIntrinsicsAvailable(self, cameraInit, views, intrinsics):
|
def onIntrinsicsAvailable(self, cameraInit, views, intrinsics):
|
||||||
""" Update CameraInit with given views and intrinsics. """
|
""" Update CameraInit with given views and intrinsics. """
|
||||||
with self.groupedGraphModification("Add Images"):
|
augmentSfM = cameraInit is None
|
||||||
self.setAttribute(cameraInit.viewpoints, views)
|
commandTitle = "Add {} Images"
|
||||||
self.setAttribute(cameraInit.intrinsics, intrinsics)
|
|
||||||
|
# SfM augmentation
|
||||||
|
if augmentSfM:
|
||||||
|
# filter out views already involved in the reconstruction
|
||||||
|
allViewIds = self.allViewIds()
|
||||||
|
views = [view for view in views if int(view["viewId"]) not in allViewIds]
|
||||||
|
commandTitle = "Augment Reconstruction ({} Images)"
|
||||||
|
|
||||||
|
# No additional views: early return
|
||||||
|
if not views:
|
||||||
|
return
|
||||||
|
|
||||||
|
commandTitle = commandTitle.format(len(views))
|
||||||
|
# allow updates between commands so that node depths
|
||||||
|
# are updated after "addSfmAugmentation" (useful for auto layout)
|
||||||
|
with self.groupedGraphModification(commandTitle, disableUpdates=False):
|
||||||
|
if augmentSfM:
|
||||||
|
cameraInit, self.sfm = self.addSfmAugmentation()
|
||||||
|
with self.groupedGraphModification("Set Views and Intrinsics"):
|
||||||
|
self.setAttribute(cameraInit.viewpoints, views)
|
||||||
|
self.setAttribute(cameraInit.intrinsics, intrinsics)
|
||||||
self.setCameraInit(cameraInit)
|
self.setCameraInit(cameraInit)
|
||||||
|
|
||||||
def setBuildingIntrinsics(self, value):
|
def setBuildingIntrinsics(self, value):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue