kopia lustrzana https://github.com/OpenDroneMap/ODM
refactorize resize cell in order to give proper error logs
rodzic
bb28291360
commit
a4870e76d3
|
@ -35,13 +35,14 @@ class ODMResizeCell(ecto.Cell):
|
||||||
|
|
||||||
# loop over photos
|
# loop over photos
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
try:
|
|
||||||
# open and resize image with opencv
|
|
||||||
img = cv2.imread(photo.path_file)
|
|
||||||
|
|
||||||
# TODO(edgar): check if resize is needed, else copy img.
|
# TODO(edgar): check if resize is needed, else copy img.
|
||||||
# Try to avoid oversampling!
|
# Try to avoid oversampling!
|
||||||
|
new_path_file = io.join_paths(resizing_dir, photo.filename)
|
||||||
|
|
||||||
|
if not io.file_exists(new_path_file):
|
||||||
|
# open and resize image with opencv
|
||||||
|
img = cv2.imread(photo.path_file)
|
||||||
# compute new size
|
# compute new size
|
||||||
max_side = max(photo.width, photo.height) \
|
max_side = max(photo.width, photo.height) \
|
||||||
if photo.width and photo.height \
|
if photo.width and photo.height \
|
||||||
|
@ -49,7 +50,6 @@ class ODMResizeCell(ecto.Cell):
|
||||||
ratio = float(args['resize_to']) / float(max_side)
|
ratio = float(args['resize_to']) / float(max_side)
|
||||||
img_r = cv2.resize(img, None, fx=ratio, fy=ratio)
|
img_r = cv2.resize(img, None, fx=ratio, fy=ratio)
|
||||||
# write image with opencv
|
# write image with opencv
|
||||||
new_path_file = io.join_paths(resizing_dir, photo.filename)
|
|
||||||
cv2.imwrite(new_path_file, img_r)
|
cv2.imwrite(new_path_file, img_r)
|
||||||
# read metadata with pyexiv2
|
# read metadata with pyexiv2
|
||||||
old_meta = pyexiv2.ImageMetadata(photo.path_file)
|
old_meta = pyexiv2.ImageMetadata(photo.path_file)
|
||||||
|
@ -66,14 +66,10 @@ class ODMResizeCell(ecto.Cell):
|
||||||
photo.update_focal()
|
photo.update_focal()
|
||||||
|
|
||||||
# log message
|
# log message
|
||||||
log.ODM_DEBUG('Resized image %s | dimensions: %s' % \
|
log.ODM_DEBUG('Resized %s | dimensions: %s to %s' % \
|
||||||
(photo.filename, img_r.shape))
|
(photo.filename, img_r.shape, args['resize_to']))
|
||||||
|
else:
|
||||||
except cv2.error as e:
|
log.ODM_WARNING('Already resized %s' % photo.filename)
|
||||||
# something went wrong with this image
|
|
||||||
# TODO(edgar): remove photo from array
|
|
||||||
log.ODM_ERROR('Could not resize image %s' % photo.file_name)
|
|
||||||
log.ODM_ERROR('%s' % e)
|
|
||||||
else:
|
else:
|
||||||
log.ODM_ERROR('Not enough photos in photos to resize')
|
log.ODM_ERROR('Not enough photos in photos to resize')
|
||||||
return ecto.QUIT
|
return ecto.QUIT
|
||||||
|
|
Ładowanie…
Reference in New Issue