kopia lustrzana https://github.com/OpenDroneMap/ODM
fix resizing issue with file metadata
rodzic
7d0215be4d
commit
72d3a48b60
|
@ -20,3 +20,6 @@ def join_paths(path1, path2):
|
||||||
|
|
||||||
def file_exists(path_file):
|
def file_exists(path_file):
|
||||||
return os.path.isfile(path_file)
|
return os.path.isfile(path_file)
|
||||||
|
|
||||||
|
def dir_exists(dirname):
|
||||||
|
return os.path.isdir(dirname)
|
|
@ -26,7 +26,14 @@ class ODMLoadDatasetCell(ecto.Cell):
|
||||||
# get parameters
|
# get parameters
|
||||||
args = self.inputs.args
|
args = self.inputs.args
|
||||||
project_path = io.absolute_path_file(args['project_path'])
|
project_path = io.absolute_path_file(args['project_path'])
|
||||||
images_dir = io.join_paths(project_path, 'images')
|
images_dir = io.join_paths(project_path, 'images_resize')
|
||||||
|
|
||||||
|
# check if we rerun cell or not
|
||||||
|
rerun_cell = args['run_only'] is not None \
|
||||||
|
and args['run_only'] == 'resize'
|
||||||
|
|
||||||
|
if not io.dir_exists(images_dir) or rerun_cell:
|
||||||
|
images_dir = io.join_paths(project_path, 'images')
|
||||||
|
|
||||||
log.ODM_DEBUG('Loading dataset from: %s' % images_dir)
|
log.ODM_DEBUG('Loading dataset from: %s' % images_dir)
|
||||||
|
|
||||||
|
@ -38,9 +45,8 @@ class ODMLoadDatasetCell(ecto.Cell):
|
||||||
files = [f for f in files if supported_extension(f)]
|
files = [f for f in files if supported_extension(f)]
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
photos = []
|
|
||||||
|
|
||||||
# create ODMPhoto list
|
# create ODMPhoto list
|
||||||
|
photos = []
|
||||||
for f in files:
|
for f in files:
|
||||||
path_file = io.join_paths(images_dir, f)
|
path_file = io.join_paths(images_dir, f)
|
||||||
photos.append(types.ODMPhoto(path_file, args))
|
photos.append(types.ODMPhoto(path_file, args))
|
||||||
|
|
|
@ -64,6 +64,9 @@ class ODMResizeCell(ecto.Cell):
|
||||||
new_meta.read()
|
new_meta.read()
|
||||||
# copy metadata
|
# copy metadata
|
||||||
old_meta.copy(new_meta)
|
old_meta.copy(new_meta)
|
||||||
|
# update metadata size
|
||||||
|
new_meta['Exif.Photo.PixelXDimension'].value = img_r.shape[0]
|
||||||
|
new_meta['Exif.Photo.PixelYDimension'].value = img_r.shape[1]
|
||||||
new_meta.write()
|
new_meta.write()
|
||||||
# update photos array with new values
|
# update photos array with new values
|
||||||
photo.path_file = new_path_file
|
photo.path_file = new_path_file
|
||||||
|
@ -72,10 +75,12 @@ class ODMResizeCell(ecto.Cell):
|
||||||
photo.update_focal()
|
photo.update_focal()
|
||||||
|
|
||||||
# log message
|
# log message
|
||||||
log.ODM_DEBUG('Resized %s | dimensions: %s to %s' % \
|
log.ODM_DEBUG('Resized %s | dimensions: %s' % \
|
||||||
(photo.filename, img_r.shape, args['resize_to']))
|
(photo.filename, img_r.shape))
|
||||||
else:
|
else:
|
||||||
log.ODM_WARNING('Already resized %s' % photo.filename)
|
# log message
|
||||||
|
log.ODM_WARNING('Already resized %s | dimensions: %s x %s' % \
|
||||||
|
(photo.filename, photo.width, photo.height))
|
||||||
|
|
||||||
log.ODM_INFO('Resized %s images' % len(photos))
|
log.ODM_INFO('Resized %s images' % len(photos))
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue