mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-23 11:37:28 +02:00
[ui] support import of folders containing images
* add isImageFile static method to test input files * store completed image extensions list as class attribute
This commit is contained in:
parent
c06e2f110a
commit
e5acd916dc
1 changed files with 13 additions and 2 deletions
|
@ -13,6 +13,9 @@ class Reconstruction(UIGraph):
|
||||||
"""
|
"""
|
||||||
Specialization of a UIGraph designed to manage a 3D reconstruction.
|
Specialization of a UIGraph designed to manage a 3D reconstruction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
imageExtensions = ('.jpg', '.jpeg', '.tif', '.tiff', '.png', '.exr')
|
||||||
|
|
||||||
def __init__(self, graphFilepath='', parent=None):
|
def __init__(self, graphFilepath='', parent=None):
|
||||||
super(Reconstruction, self).__init__(graphFilepath, parent)
|
super(Reconstruction, self).__init__(graphFilepath, parent)
|
||||||
self._buildIntrinsicsThread = None
|
self._buildIntrinsicsThread = None
|
||||||
|
@ -97,6 +100,11 @@ class Reconstruction(UIGraph):
|
||||||
"""
|
"""
|
||||||
self.importImagesFromUrls(drop.property("urls"))
|
self.importImagesFromUrls(drop.property("urls"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def isImageFile(filepath):
|
||||||
|
""" Return whether filepath is a path to an image file supported by Meshroom. """
|
||||||
|
return os.path.splitext(filepath)[1].lower() in Reconstruction.imageExtensions
|
||||||
|
|
||||||
@Slot(QObject)
|
@Slot(QObject)
|
||||||
def importImagesFromUrls(self, urls):
|
def importImagesFromUrls(self, urls):
|
||||||
""" Add the given list of images (as QUrl) to the Reconstruction. """
|
""" Add the given list of images (as QUrl) to the Reconstruction. """
|
||||||
|
@ -104,8 +112,11 @@ class Reconstruction(UIGraph):
|
||||||
images = []
|
images = []
|
||||||
for url in urls:
|
for url in urls:
|
||||||
localFile = url.toLocalFile()
|
localFile = url.toLocalFile()
|
||||||
if os.path.splitext(localFile)[1].lower() in (".jpg", ".png", ".jpeg"):
|
if os.path.isdir(localFile): # get folder content
|
||||||
images.append(localFile)
|
files = [os.path.join(localFile, f) for f in os.listdir(localFile)]
|
||||||
|
else:
|
||||||
|
files = [localFile]
|
||||||
|
images.extend([f for f in files if Reconstruction.isImageFile(f)])
|
||||||
if not images:
|
if not images:
|
||||||
return
|
return
|
||||||
# Start the process of updating views and intrinsics
|
# Start the process of updating views and intrinsics
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue