mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-07 05:12:00 +02:00
[ui] Reconstruction: the active sfm node can be a StructureFromMotion or a PanoramaEstimation node
This commit is contained in:
parent
9e03f67c9b
commit
49c03bc239
2 changed files with 32 additions and 30 deletions
|
@ -347,30 +347,3 @@ It iterates like that, adding cameras and triangulating new 2D features into 3D
|
||||||
uid=[],
|
uid=[],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getResults(node):
|
|
||||||
"""
|
|
||||||
Parse SfM result and return views, poses and intrinsics as three dicts with viewId, poseId and intrinsicId as keys.
|
|
||||||
"""
|
|
||||||
reportFile = node.outputViewsAndPoses.value
|
|
||||||
if not os.path.exists(reportFile):
|
|
||||||
return {}, {}, {}
|
|
||||||
|
|
||||||
with open(reportFile) as jsonFile:
|
|
||||||
report = json.load(jsonFile)
|
|
||||||
|
|
||||||
views = dict()
|
|
||||||
poses = dict()
|
|
||||||
intrinsics = dict()
|
|
||||||
|
|
||||||
for view in report['views']:
|
|
||||||
views[view['viewId']] = view
|
|
||||||
|
|
||||||
for pose in report['poses']:
|
|
||||||
poses[pose['poseId']] = pose['pose']
|
|
||||||
|
|
||||||
for intrinsic in report['intrinsics']:
|
|
||||||
intrinsics[intrinsic['intrinsicId']] = intrinsic
|
|
||||||
|
|
||||||
return views, poses, intrinsics
|
|
||||||
|
|
|
@ -356,6 +356,32 @@ class ViewpointWrapper(QObject):
|
||||||
return QUrl.fromLocalFile(self._undistortedImagePath)
|
return QUrl.fromLocalFile(self._undistortedImagePath)
|
||||||
|
|
||||||
|
|
||||||
|
def parseSfMJsonFile(sfmJsonFile):
|
||||||
|
"""
|
||||||
|
Parse the SfM Json file and return views, poses and intrinsics as three dicts with viewId, poseId and intrinsicId as keys.
|
||||||
|
"""
|
||||||
|
if not os.path.exists(sfmJsonFile):
|
||||||
|
return {}, {}, {}
|
||||||
|
|
||||||
|
with open(sfmJsonFile) as jsonFile:
|
||||||
|
report = json.load(jsonFile)
|
||||||
|
|
||||||
|
views = dict()
|
||||||
|
poses = dict()
|
||||||
|
intrinsics = dict()
|
||||||
|
|
||||||
|
for view in report['views']:
|
||||||
|
views[view['viewId']] = view
|
||||||
|
|
||||||
|
for pose in report['poses']:
|
||||||
|
poses[pose['poseId']] = pose['pose']
|
||||||
|
|
||||||
|
for intrinsic in report['intrinsics']:
|
||||||
|
intrinsics[intrinsic['intrinsicId']] = intrinsic
|
||||||
|
|
||||||
|
return views, poses, intrinsics
|
||||||
|
|
||||||
|
|
||||||
class Reconstruction(UIGraph):
|
class Reconstruction(UIGraph):
|
||||||
"""
|
"""
|
||||||
Specialization of a UIGraph designed to manage a 3D reconstruction.
|
Specialization of a UIGraph designed to manage a 3D reconstruction.
|
||||||
|
@ -504,6 +530,9 @@ class Reconstruction(UIGraph):
|
||||||
|
|
||||||
self.setSfm(self.lastSfmNode())
|
self.setSfm(self.lastSfmNode())
|
||||||
|
|
||||||
|
if not self.sfm:
|
||||||
|
self.sfm = self.lastNodeOfType("PanoramaEstimation", self._cameraInit, Status.SUCCESS)
|
||||||
|
|
||||||
# TODO: listen specifically for cameraInit creation/deletion
|
# TODO: listen specifically for cameraInit creation/deletion
|
||||||
self._graph.nodes.countChanged.connect(self.updateCameraInits)
|
self._graph.nodes.countChanged.connect(self.updateCameraInits)
|
||||||
|
|
||||||
|
@ -763,7 +792,7 @@ class Reconstruction(UIGraph):
|
||||||
recursive: List files in folders recursively.
|
recursive: List files in folders recursively.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
logging.warning("importImagesFromFolder: " + str(path))
|
logging.debug("importImagesFromFolder: " + str(path))
|
||||||
filesByType = multiview.findFilesByTypeInFolder(path, recursive)
|
filesByType = multiview.findFilesByTypeInFolder(path, recursive)
|
||||||
if filesByType.images:
|
if filesByType.images:
|
||||||
self.buildIntrinsics(self.cameraInit, filesByType.images)
|
self.buildIntrinsics(self.cameraInit, filesByType.images)
|
||||||
|
@ -910,7 +939,7 @@ class Reconstruction(UIGraph):
|
||||||
@Slot(QObject)
|
@Slot(QObject)
|
||||||
def setActiveNodeOfType(self, node):
|
def setActiveNodeOfType(self, node):
|
||||||
""" Set node as the active node of its type. """
|
""" Set node as the active node of its type. """
|
||||||
if node.nodeType == "StructureFromMotion":
|
if node.nodeType == "StructureFromMotion" or node.nodeType == "PanoramaEstimation":
|
||||||
self.sfm = node
|
self.sfm = node
|
||||||
elif node.nodeType == "FeatureExtraction":
|
elif node.nodeType == "FeatureExtraction":
|
||||||
self.featureExtraction = node
|
self.featureExtraction = node
|
||||||
|
@ -936,7 +965,7 @@ class Reconstruction(UIGraph):
|
||||||
self._poses = dict()
|
self._poses = dict()
|
||||||
self._solvedIntrinsics = dict()
|
self._solvedIntrinsics = dict()
|
||||||
else:
|
else:
|
||||||
self._views, self._poses, self._solvedIntrinsics = self._sfm.nodeDesc.getResults(self._sfm)
|
self._views, self._poses, self._solvedIntrinsics = parseSfMJsonFile(self._sfm.outputViewsAndPoses.value)
|
||||||
self.sfmReportChanged.emit()
|
self.sfmReportChanged.emit()
|
||||||
|
|
||||||
def getSfm(self):
|
def getSfm(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue