mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-28 17:57:16 +02:00
[ui] Use of pyseq for getting sequences
[ui] To squash
This commit is contained in:
parent
1168ccaacb
commit
cc2099534b
4 changed files with 23 additions and 17 deletions
|
@ -150,3 +150,4 @@ def setupEnvironment(backend=Backend.STANDALONE):
|
|||
|
||||
|
||||
os.environ["QML_XHR_ALLOW_FILE_READ"] = '1'
|
||||
os.environ["PYSEQ_STRICT_PAD"] = '1'
|
||||
|
|
|
@ -5,7 +5,7 @@ from PySide2.QtCore import QObject, Slot
|
|||
|
||||
import os
|
||||
import glob
|
||||
import re
|
||||
import pyseq
|
||||
|
||||
|
||||
class FilepathHelper(QObject):
|
||||
|
@ -146,25 +146,24 @@ class FilepathHelper(QObject):
|
|||
if extension is None:
|
||||
extension = ".*"
|
||||
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))
|
||||
# use of pyseq to get the sequences
|
||||
seq = pyseq.get_sequences(self.asStr(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 = [[s.start(), s.end()] for s in seq]
|
||||
|
||||
ids.sort()
|
||||
folder = self.dirname(path)
|
||||
|
||||
resolved = [path.replace(self.basename(path), replacement) for replacement in replacements]
|
||||
missingFiles = [s.missing() for s in seq]
|
||||
|
||||
# create the resolved path for each sequence and if a frame is missing add a empty string
|
||||
resolved = [[os.path.join(folder, s.head() + str(s.format("%p") % frame) + s.tail()) if frame not in missingFiles[seq.index(s)]
|
||||
else "" for frame in range(ids[seq.index(s)][0], ids[seq.index(s)][1] + 1)] if s.frames()
|
||||
else os.path.join(folder, s.head())
|
||||
for s in seq]
|
||||
return ids, resolved
|
||||
|
|
|
@ -39,7 +39,7 @@ FloatingPane {
|
|||
function updateReconstructionView() {
|
||||
if (isOutputSequence)
|
||||
return
|
||||
if (_reconstruction && m.frame >= 0 && m.frame < sortedViewIds.length) {
|
||||
if (_reconstruction && m.frame >= frameRange.min && m.frame < frameRange.max+1) {
|
||||
if (!m.playing && !frameSlider.pressed) {
|
||||
_reconstruction.selectedViewId = sortedViewIds[m.frame];
|
||||
} else {
|
||||
|
|
|
@ -268,20 +268,26 @@ FocusScope {
|
|||
let ids = sequence[0]
|
||||
let resolved = sequence[1]
|
||||
|
||||
//order by path
|
||||
resolved.sort()
|
||||
// reset current frame to 0 if it is imageList but not sequence
|
||||
if (attr.desc.semantic === "imageList") {
|
||||
// concat in one array all sequences in resolved
|
||||
resolved = [].concat.apply([], resolved)
|
||||
frameRange.min = 0
|
||||
frameRange.max = resolved.length-1
|
||||
currentFrame = 0
|
||||
}
|
||||
|
||||
if (attr.desc.semantic === "sequence") {
|
||||
// if there is several sequences, take the first one
|
||||
resolved = resolved[0]
|
||||
ids = ids[0]
|
||||
frameRange.min = ids[0]
|
||||
frameRange.max = ids[ids.length-1]
|
||||
currentFrame = frameRange.min
|
||||
}
|
||||
//order by path
|
||||
resolved.sort()
|
||||
|
||||
return resolved
|
||||
} else {
|
||||
for (let i = 0; i < _reconstruction.viewpoints.count; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue