[multiview] unify image files helper functions

Move everything related to image files detection to the 'multiview' module.
This commit is contained in:
Yann Lanthony 2019-01-29 14:36:37 +01:00
parent 88c43fe316
commit 1cc2561a21
2 changed files with 24 additions and 26 deletions

View file

@ -99,8 +99,7 @@ class LiveSfmManager(QObject):
to include those images to the reconstruction.
"""
# Get all new images in the watched folder
filesInFolder = [os.path.join(self._folder, f) for f in os.listdir(self._folder)]
imagesInFolder = [f for f in filesInFolder if Reconstruction.isImageFile(f)]
imagesInFolder = multiview.findImageFiles(self._folder)
newImages = set(imagesInFolder).difference(self.allImages)
for imagePath in newImages:
# print('[LiveSfmManager] New image file : {}'.format(imagePath))
@ -160,8 +159,6 @@ class Reconstruction(UIGraph):
Specialization of a UIGraph designed to manage a 3D reconstruction.
"""
imageExtensions = ('.jpg', '.jpeg', '.tif', '.tiff', '.png', '.exr', '.rw2', '.cr2', '.nef', '.arw')
def __init__(self, graphFilepath='', parent=None):
super(Reconstruction, self).__init__(graphFilepath, parent)
self._buildingIntrinsics = False
@ -332,11 +329,6 @@ class Reconstruction(UIGraph):
"""
self.importImages(self.getImageFilesFromDrop(drop), cameraInit)
@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
@staticmethod
def getImageFilesFromDrop(drop):
urls = drop.property("urls")
@ -345,10 +337,9 @@ class Reconstruction(UIGraph):
for url in urls:
localFile = url.toLocalFile()
if os.path.isdir(localFile): # get folder content
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)])
images.extend(multiview.findImageFiles(localFile))
elif multiview.isImageFile(localFile):
images.append(localFile)
return images
def importImages(self, images, cameraInit):