Skip corrupted photos

268
Piero Toffanin 2021-12-07 14:20:44 -05:00
rodzic 944cd4a0bf
commit 8566ba617c
3 zmienionych plików z 17 dodań i 7 usunięć

Wyświetl plik

@ -36,6 +36,9 @@ def find_largest_photo_dim(photos):
return max_dim
class PhotoCorruptedException(Exception):
pass
class ODM_Photo:
"""ODMPhoto - a class for ODMPhotos"""
@ -270,8 +273,11 @@ class ODM_Photo:
# self.set_attr_from_xmp_tag('bandwidth', tags, [
# 'Camera:WavelengthFWHM'
# ], float)
try:
self.width, self.height = get_image_size.get_image_size(_path_file)
except Exception as e:
raise PhotoCorruptedException(str(e))
self.width, self.height = get_image_size.get_image_size(_path_file)
# Sanitize band name since we use it in folder paths
self.band_name = re.sub('[^A-Za-z0-9]+', '', self.band_name)

Wyświetl plik

@ -4,6 +4,7 @@ import json
from opendm import context
from opendm import io
from opendm import types
from opendm.photo import PhotoCorruptedException
from opendm import log
from opendm import system
from opendm.geo import GeoFile
@ -109,11 +110,14 @@ class ODMLoadDatasetStage(types.ODM_Stage):
with open(tree.dataset_list, 'w') as dataset_list:
log.ODM_INFO("Loading %s images" % len(path_files))
for f in path_files:
p = types.ODM_Photo(f)
p.set_mask(find_mask(f, masks))
photos += [p]
dataset_list.write(photos[-1].filename + '\n')
try:
p = types.ODM_Photo(f)
p.set_mask(find_mask(f, masks))
photos += [p]
dataset_list.write(photos[-1].filename + '\n')
except PhotoCorruptedException:
log.ODM_WARNING("%s seems corrupted and will not be used" % os.path.basename(f))
# Check if a geo file is available
if tree.odm_geo_file is not None and os.path.isfile(tree.odm_geo_file):
log.ODM_INFO("Found image geolocation file")

Wyświetl plik

@ -24,7 +24,7 @@ class ODMOrthoPhotoStage(types.ODM_Stage):
system.mkdir_p(tree.odm_orthophoto)
if args.skip_orthophoto:
log.ODM_WARNING("--skip-orthophoto is set, skipping orthophoto generation.")
log.ODM_WARNING("--skip-orthophoto is set, no orthophoto will be generated")
return
if not io.file_exists(tree.odm_orthophoto_tif) or self.rerun():