mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-30 01:16:33 +02:00
[ui] Resolve Sequence and ImageList on Python side
This commit is contained in:
parent
4590868317
commit
1168ccaacb
3 changed files with 46 additions and 11 deletions
|
@ -5,6 +5,7 @@ from PySide2.QtCore import QObject, Slot
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class FilepathHelper(QObject):
|
class FilepathHelper(QObject):
|
||||||
|
@ -144,4 +145,26 @@ class FilepathHelper(QObject):
|
||||||
"""
|
"""
|
||||||
if extension is None:
|
if extension is None:
|
||||||
extension = ".*"
|
extension = ".*"
|
||||||
return [self.basename(FilepathHelper, f) for f in glob.glob(os.path.join(folderPath, f"*{extension}")) if os.path.isfile(f)]
|
return [self.basename(f) for f in glob.glob(os.path.join(folderPath, f"*{extension}")) if os.path.isfile(f)]
|
||||||
|
|
||||||
|
@Slot(str, result="QVariantList")
|
||||||
|
def resolveSequence(self, path):
|
||||||
|
"""
|
||||||
|
Get id of each file in the sequence.
|
||||||
|
"""
|
||||||
|
replacements = self.getFilenamesFromFolder(self.dirname(path), self.extension(path))
|
||||||
|
|
||||||
|
ids = []
|
||||||
|
for i in replacements:
|
||||||
|
# convert basename to regex
|
||||||
|
splitBefore = self.basename(path).split("(")
|
||||||
|
splitAfter = splitBefore[1].split(")")
|
||||||
|
id = re.search("["+splitBefore[0]+"]("+splitAfter[0]+")["+splitAfter[1]+"]", i)
|
||||||
|
if id:
|
||||||
|
# put id in replacements as key of replacements[i]
|
||||||
|
ids.append(id[1])
|
||||||
|
|
||||||
|
ids.sort()
|
||||||
|
|
||||||
|
resolved = [path.replace(self.basename(path), replacement) for replacement in replacements]
|
||||||
|
return ids, resolved
|
||||||
|
|
|
@ -29,7 +29,7 @@ FloatingPane {
|
||||||
property bool loading: fetchButton.checked || m.playing
|
property bool loading: fetchButton.checked || m.playing
|
||||||
property alias settings_SequencePlayer: settings_SequencePlayer
|
property alias settings_SequencePlayer: settings_SequencePlayer
|
||||||
property alias frameId: m.frame
|
property alias frameId: m.frame
|
||||||
property var frameRange: {"min" : 0, "max" : sortedViewIds.length - 1}
|
property var frameRange: {"min" : 0, "max" : 0}
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: settings_SequencePlayer
|
id: settings_SequencePlayer
|
||||||
|
|
|
@ -229,7 +229,7 @@ FocusScope {
|
||||||
function getImageFile() {
|
function getImageFile() {
|
||||||
// Entry point for getting the image file URL
|
// Entry point for getting the image file URL
|
||||||
|
|
||||||
let attr = getAttributeByName(displayedNode, outputAttribute.name)
|
let attr = displayedNode ? getAttributeByName(displayedNode, outputAttribute.name) : undefined
|
||||||
if (useExternal) {
|
if (useExternal) {
|
||||||
return sourceExternal
|
return sourceExternal
|
||||||
}
|
}
|
||||||
|
@ -261,20 +261,28 @@ FocusScope {
|
||||||
// ordered by path
|
// ordered by path
|
||||||
|
|
||||||
let objs = []
|
let objs = []
|
||||||
let attr = getAttributeByName(displayedNode, outputAttribute.name)
|
let attr = displayedNode ? getAttributeByName(displayedNode, outputAttribute.name) : undefined
|
||||||
|
|
||||||
if (displayedNode && displayedNode.hasSequenceOutput && (attr.desc.semantic === "imageList" || attr.desc.semantic === "sequence")) {
|
if (displayedNode && displayedNode.hasSequenceOutput && (attr.desc.semantic === "imageList" || attr.desc.semantic === "sequence")) {
|
||||||
objs = Filepath.resolve(path_template, null)
|
let sequence = Filepath.resolveSequence(path_template)
|
||||||
|
let ids = sequence[0]
|
||||||
|
let resolved = sequence[1]
|
||||||
|
|
||||||
//order by path
|
//order by path
|
||||||
objs.sort()
|
resolved.sort()
|
||||||
// reset current frame to 0 if it is imageList but not sequence
|
// reset current frame to 0 if it is imageList but not sequence
|
||||||
if (attr.desc.semantic === "imageList")
|
if (attr.desc.semantic === "imageList") {
|
||||||
frameRange.min = 0
|
frameRange.min = 0
|
||||||
frameRange.max = objs.length-1
|
frameRange.max = resolved.length-1
|
||||||
currentFrame = 0
|
currentFrame = 0
|
||||||
if (attr.desc.semantic === "sequence")
|
}
|
||||||
|
|
||||||
|
if (attr.desc.semantic === "sequence") {
|
||||||
|
frameRange.min = ids[0]
|
||||||
|
frameRange.max = ids[ids.length-1]
|
||||||
currentFrame = frameRange.min
|
currentFrame = frameRange.min
|
||||||
return objs
|
}
|
||||||
|
return resolved
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < _reconstruction.viewpoints.count; i++) {
|
for (let i = 0; i < _reconstruction.viewpoints.count; i++) {
|
||||||
objs.push(_reconstruction.viewpoints.at(i))
|
objs.push(_reconstruction.viewpoints.at(i))
|
||||||
|
@ -285,6 +293,10 @@ FocusScope {
|
||||||
seq.push(Filepath.resolve(path_template, objs[i]))
|
seq.push(Filepath.resolve(path_template, objs[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frameRange.min = 0
|
||||||
|
frameRange.max = seq.length-1
|
||||||
|
currentFrame = 0
|
||||||
|
|
||||||
return seq
|
return seq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -491,7 +503,7 @@ FocusScope {
|
||||||
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput))) ? getSequence() : []) }),
|
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput))) ? getSequence() : []) }),
|
||||||
'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize }),
|
'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize }),
|
||||||
'useSequence': Qt.binding(function() {
|
'useSequence': Qt.binding(function() {
|
||||||
let attr = getAttributeByName(root.displayedNode, outputAttribute.name)
|
let attr = root.displayedNode ? getAttributeByName(root.displayedNode, outputAttribute.name) : undefined
|
||||||
return (root.enableSequencePlayer && !useExternal && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput)) && (attr.desc.semantic === "imageList" || attr.desc.semantic === "sequence"))
|
return (root.enableSequencePlayer && !useExternal && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput)) && (attr.desc.semantic === "imageList" || attr.desc.semantic === "sequence"))
|
||||||
}),
|
}),
|
||||||
'fetchingSequence': Qt.binding(function() { return sequencePlayer.loading }),
|
'fetchingSequence': Qt.binding(function() { return sequencePlayer.loading }),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue