mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-20 20:46:28 +02:00
[ui] uvCenterOffset set according to principal point corrected or not + undistorted image path resolve according to output value of node
This commit is contained in:
parent
ad7745a7c5
commit
f6332efa7e
3 changed files with 38 additions and 31 deletions
|
@ -98,3 +98,22 @@ class FilepathHelper(QObject):
|
||||||
def fileSizeMB(self, path):
|
def fileSizeMB(self, path):
|
||||||
""" Returns the file size in MB. """
|
""" Returns the file size in MB. """
|
||||||
return QFileInfo(self.asStr(path)).size() / (1024*1024)
|
return QFileInfo(self.asStr(path)).size() / (1024*1024)
|
||||||
|
|
||||||
|
@Slot(str, QObject, result=str)
|
||||||
|
def resolve(self, path, vp):
|
||||||
|
# Resolve dynamic path that depends on viewpoint
|
||||||
|
|
||||||
|
replacements = {
|
||||||
|
"<VIEW_ID>": str(vp.childAttribute("viewId").value),
|
||||||
|
"<INTRINSIC_ID>": str(vp.childAttribute("intrinsicId").value),
|
||||||
|
"<POSE_ID>": str(vp.childAttribute("poseId").value),
|
||||||
|
"<PATH>": vp.childAttribute("path").value,
|
||||||
|
"<FILENAME>": FilepathHelper.basename(FilepathHelper, vp.childAttribute("path").value),
|
||||||
|
"<FILESTEM>": FilepathHelper.removeExtension(FilepathHelper, FilepathHelper.basename(FilepathHelper, vp.childAttribute("path").value)),
|
||||||
|
}
|
||||||
|
|
||||||
|
resolved = path
|
||||||
|
for key in replacements:
|
||||||
|
resolved = resolved.replace(key, replacements[key])
|
||||||
|
|
||||||
|
return resolved
|
|
@ -222,24 +222,6 @@ FocusScope {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolve(path, vp) {
|
|
||||||
// Resolve dynamic path that depends on viewpoint
|
|
||||||
|
|
||||||
let replacements = {
|
|
||||||
"<VIEW_ID>": vp.childAttribute("viewId").value,
|
|
||||||
"<INTRINSIC_ID>": vp.childAttribute("intrinsicId").value,
|
|
||||||
"<POSE_ID>": vp.childAttribute("poseId").value,
|
|
||||||
"<PATH>": vp.childAttribute("path").value,
|
|
||||||
"<FILENAME>": Filepath.removeExtension(Filepath.basename(vp.childAttribute("path").value)),
|
|
||||||
}
|
|
||||||
|
|
||||||
let resolved = path;
|
|
||||||
for (let key in replacements) {
|
|
||||||
resolved = resolved.replace(key, replacements[key])
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolved;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getImageFile() {
|
function getImageFile() {
|
||||||
// Entry point for getting the image file URL
|
// Entry point for getting the image file URL
|
||||||
|
@ -258,7 +240,7 @@ FocusScope {
|
||||||
let vp = getViewpoint(_reconstruction.pickedViewId)
|
let vp = getViewpoint(_reconstruction.pickedViewId)
|
||||||
let attr = getAttributeByName(displayedNode, outputAttribute.name)
|
let attr = getAttributeByName(displayedNode, outputAttribute.name)
|
||||||
let path = attr ? attr.value : ""
|
let path = attr ? attr.value : ""
|
||||||
let resolved = vp ? resolve(path, vp) : path
|
let resolved = vp ? Filepath.resolve(path, vp) : path
|
||||||
return Filepath.stringToUrl(resolved)
|
return Filepath.stringToUrl(resolved)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +259,7 @@ FocusScope {
|
||||||
|
|
||||||
let seq = [];
|
let seq = [];
|
||||||
for (let i = 0; i < objs.length; i++) {
|
for (let i = 0; i < objs.length; i++) {
|
||||||
seq.push(resolve(path_template, objs[i]))
|
seq.push(Filepath.resolve(path_template, objs[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
return seq
|
return seq
|
||||||
|
@ -1032,7 +1014,7 @@ FocusScope {
|
||||||
property var vp: _reconstruction ? getViewpoint(_reconstruction.selectedViewId) : null
|
property var vp: _reconstruction ? getViewpoint(_reconstruction.selectedViewId) : null
|
||||||
|
|
||||||
sourceComponent: CameraResponseGraph {
|
sourceComponent: CameraResponseGraph {
|
||||||
responsePath: resolve(path, vp)
|
responsePath: Filepath.resolve(path, vp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from meshroom.core import Version
|
||||||
from meshroom.core.node import Node, CompatibilityNode, Status, Position
|
from meshroom.core.node import Node, CompatibilityNode, Status, Position
|
||||||
from meshroom.ui.graph import UIGraph
|
from meshroom.ui.graph import UIGraph
|
||||||
from meshroom.ui.utils import makeProperty
|
from meshroom.ui.utils import makeProperty
|
||||||
|
from meshroom.ui.components.filepath import FilepathHelper
|
||||||
|
|
||||||
|
|
||||||
class Message(QObject):
|
class Message(QObject):
|
||||||
|
@ -171,6 +172,8 @@ class ViewpointWrapper(QObject):
|
||||||
sfmParamsChanged = Signal()
|
sfmParamsChanged = Signal()
|
||||||
undistortedImageParamsChanged = Signal()
|
undistortedImageParamsChanged = Signal()
|
||||||
internalChanged = Signal()
|
internalChanged = Signal()
|
||||||
|
principalPointCorrectedChanged = Signal()
|
||||||
|
uvCenterOffsetChanged = Signal()
|
||||||
|
|
||||||
def __init__(self, viewpointAttribute, reconstruction):
|
def __init__(self, viewpointAttribute, reconstruction):
|
||||||
"""
|
"""
|
||||||
|
@ -195,6 +198,9 @@ class ViewpointWrapper(QObject):
|
||||||
self._undistortedImagePath = ''
|
self._undistortedImagePath = ''
|
||||||
self._activeNode_PrepareDenseScene = self._reconstruction.activeNodes.get("PrepareDenseScene")
|
self._activeNode_PrepareDenseScene = self._reconstruction.activeNodes.get("PrepareDenseScene")
|
||||||
self._activeNode_ExportAnimatedCamera = self._reconstruction.activeNodes.get("ExportAnimatedCamera")
|
self._activeNode_ExportAnimatedCamera = self._reconstruction.activeNodes.get("ExportAnimatedCamera")
|
||||||
|
self._principalPointCorrected = False
|
||||||
|
self.principalPointCorrectedChanged.connect(self.uvCenterOffsetChanged)
|
||||||
|
self.sfmParamsChanged.connect(self.uvCenterOffsetChanged)
|
||||||
|
|
||||||
# update internally cached variables
|
# update internally cached variables
|
||||||
self._updateInitialParams()
|
self._updateInitialParams()
|
||||||
|
@ -240,17 +246,17 @@ class ViewpointWrapper(QObject):
|
||||||
def _updateUndistortedImageParams(self):
|
def _updateUndistortedImageParams(self):
|
||||||
""" Update internal members depending on PrepareDenseScene or ExportAnimatedCamera. """
|
""" Update internal members depending on PrepareDenseScene or ExportAnimatedCamera. """
|
||||||
# undistorted image path
|
# undistorted image path
|
||||||
if not self._activeNode_PrepareDenseScene.node or not self._activeNode_ExportAnimatedCamera.node:
|
|
||||||
# if not self._activeNode_PrepareDenseScene.node:
|
|
||||||
self._undistortedImagePath = ''
|
|
||||||
if self._activeNode_ExportAnimatedCamera.node:
|
if self._activeNode_ExportAnimatedCamera.node:
|
||||||
basename = "{}_{}".format(self._viewpoint.intrinsicId.value, os.path.basename(self._viewpoint.path.value))
|
self._undistortedImagePath = FilepathHelper.resolve(FilepathHelper, self._activeNode_ExportAnimatedCamera.node.outputUndistorted.value, self._viewpoint)
|
||||||
filename = "{}.{}".format(os.path.splitext(basename)[0], self._activeNode_ExportAnimatedCamera.node.undistortedImageType.value)
|
self._principalPointCorrected = self._activeNode_ExportAnimatedCamera.node.correctPrincipalPoint.value
|
||||||
self._undistortedImagePath = os.path.join(self._activeNode_ExportAnimatedCamera.node.output.value, "undistort", filename)
|
elif self._activeNode_PrepareDenseScene.node:
|
||||||
|
self._undistortedImagePath = FilepathHelper.resolve(FilepathHelper, self._activeNode_PrepareDenseScene.node.undistorted.value, self._viewpoint)
|
||||||
|
self._principalPointCorrected = False
|
||||||
else:
|
else:
|
||||||
filename = "{}.{}".format(self._viewpoint.viewId.value, self._activeNode_PrepareDenseScene.node.outputFileType.value)
|
self._undistortedImagePath = ''
|
||||||
self._undistortedImagePath = os.path.join(self._activeNode_PrepareDenseScene.node.output.value, filename)
|
self._principalPointCorrected = False
|
||||||
self.undistortedImageParamsChanged.emit()
|
self.undistortedImageParamsChanged.emit()
|
||||||
|
self.principalPointCorrectedChanged.emit()
|
||||||
|
|
||||||
# Get the underlying Viewpoint attribute wrapped by this Viewpoint.
|
# Get the underlying Viewpoint attribute wrapped by this Viewpoint.
|
||||||
attribute = Property(QObject, lambda self: self._viewpoint, constant=True)
|
attribute = Property(QObject, lambda self: self._viewpoint, constant=True)
|
||||||
|
@ -334,10 +340,10 @@ class ViewpointWrapper(QObject):
|
||||||
""" Get camera up vector. """
|
""" Get camera up vector. """
|
||||||
return QVector3D(0.0, 1.0, 0.0)
|
return QVector3D(0.0, 1.0, 0.0)
|
||||||
|
|
||||||
@Property(type=QVector2D, notify=sfmParamsChanged)
|
@Property(type=QVector2D, notify=uvCenterOffsetChanged)
|
||||||
def uvCenterOffset(self):
|
def uvCenterOffset(self):
|
||||||
""" Get UV offset corresponding to the camera principal point. """
|
""" Get UV offset corresponding to the camera principal point. """
|
||||||
if not self.solvedIntrinsics:
|
if not self.solvedIntrinsics or self._principalPointCorrected:
|
||||||
return None
|
return None
|
||||||
pp = self.solvedIntrinsics["principalPoint"]
|
pp = self.solvedIntrinsics["principalPoint"]
|
||||||
# compute principal point offset in UV space
|
# compute principal point offset in UV space
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue