mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-20 12:36:29 +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):
|
||||
""" Returns the file size in MB. """
|
||||
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
|
||||
}
|
||||
|
||||
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() {
|
||||
// Entry point for getting the image file URL
|
||||
|
@ -258,7 +240,7 @@ FocusScope {
|
|||
let vp = getViewpoint(_reconstruction.pickedViewId)
|
||||
let attr = getAttributeByName(displayedNode, outputAttribute.name)
|
||||
let path = attr ? attr.value : ""
|
||||
let resolved = vp ? resolve(path, vp) : path
|
||||
let resolved = vp ? Filepath.resolve(path, vp) : path
|
||||
return Filepath.stringToUrl(resolved)
|
||||
}
|
||||
|
||||
|
@ -277,7 +259,7 @@ FocusScope {
|
|||
|
||||
let seq = [];
|
||||
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
|
||||
|
@ -1032,7 +1014,7 @@ FocusScope {
|
|||
property var vp: _reconstruction ? getViewpoint(_reconstruction.selectedViewId) : null
|
||||
|
||||
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.ui.graph import UIGraph
|
||||
from meshroom.ui.utils import makeProperty
|
||||
from meshroom.ui.components.filepath import FilepathHelper
|
||||
|
||||
|
||||
class Message(QObject):
|
||||
|
@ -171,6 +172,8 @@ class ViewpointWrapper(QObject):
|
|||
sfmParamsChanged = Signal()
|
||||
undistortedImageParamsChanged = Signal()
|
||||
internalChanged = Signal()
|
||||
principalPointCorrectedChanged = Signal()
|
||||
uvCenterOffsetChanged = Signal()
|
||||
|
||||
def __init__(self, viewpointAttribute, reconstruction):
|
||||
"""
|
||||
|
@ -195,6 +198,9 @@ class ViewpointWrapper(QObject):
|
|||
self._undistortedImagePath = ''
|
||||
self._activeNode_PrepareDenseScene = self._reconstruction.activeNodes.get("PrepareDenseScene")
|
||||
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
|
||||
self._updateInitialParams()
|
||||
|
@ -240,17 +246,17 @@ class ViewpointWrapper(QObject):
|
|||
def _updateUndistortedImageParams(self):
|
||||
""" Update internal members depending on PrepareDenseScene or ExportAnimatedCamera. """
|
||||
# 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:
|
||||
basename = "{}_{}".format(self._viewpoint.intrinsicId.value, os.path.basename(self._viewpoint.path.value))
|
||||
filename = "{}.{}".format(os.path.splitext(basename)[0], self._activeNode_ExportAnimatedCamera.node.undistortedImageType.value)
|
||||
self._undistortedImagePath = os.path.join(self._activeNode_ExportAnimatedCamera.node.output.value, "undistort", filename)
|
||||
self._undistortedImagePath = FilepathHelper.resolve(FilepathHelper, self._activeNode_ExportAnimatedCamera.node.outputUndistorted.value, self._viewpoint)
|
||||
self._principalPointCorrected = self._activeNode_ExportAnimatedCamera.node.correctPrincipalPoint.value
|
||||
elif self._activeNode_PrepareDenseScene.node:
|
||||
self._undistortedImagePath = FilepathHelper.resolve(FilepathHelper, self._activeNode_PrepareDenseScene.node.undistorted.value, self._viewpoint)
|
||||
self._principalPointCorrected = False
|
||||
else:
|
||||
filename = "{}.{}".format(self._viewpoint.viewId.value, self._activeNode_PrepareDenseScene.node.outputFileType.value)
|
||||
self._undistortedImagePath = os.path.join(self._activeNode_PrepareDenseScene.node.output.value, filename)
|
||||
self._undistortedImagePath = ''
|
||||
self._principalPointCorrected = False
|
||||
self.undistortedImageParamsChanged.emit()
|
||||
self.principalPointCorrectedChanged.emit()
|
||||
|
||||
# Get the underlying Viewpoint attribute wrapped by this Viewpoint.
|
||||
attribute = Property(QObject, lambda self: self._viewpoint, constant=True)
|
||||
|
@ -334,10 +340,10 @@ class ViewpointWrapper(QObject):
|
|||
""" Get camera up vector. """
|
||||
return QVector3D(0.0, 1.0, 0.0)
|
||||
|
||||
@Property(type=QVector2D, notify=sfmParamsChanged)
|
||||
@Property(type=QVector2D, notify=uvCenterOffsetChanged)
|
||||
def uvCenterOffset(self):
|
||||
""" Get UV offset corresponding to the camera principal point. """
|
||||
if not self.solvedIntrinsics:
|
||||
if not self.solvedIntrinsics or self._principalPointCorrected:
|
||||
return None
|
||||
pp = self.solvedIntrinsics["principalPoint"]
|
||||
# compute principal point offset in UV space
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue