Iter instead of dump

This commit is contained in:
Antonio J. Delgado 2021-09-06 16:47:27 +03:00
parent c971382270
commit b308a517c7

View file

@ -67,10 +67,12 @@ class image_classifier:
self._log.debug(f"Processing file '{file}'...")
people = self.find_faces(file)
if people:
self._log.debug(f"Found {len(people)} known people in the image.")
with open(file, 'rb') as image_file:
exif_info = exif.Image(image_file)
if exif_info.has_exif:
print(json.dumps(exif_info, indent=2))
for key in exif_info.list_all():
print(f"{key}: {exif_info[key]}")
# get date
# move to destination
@ -91,7 +93,7 @@ class image_classifier:
def find_faces(self, file):
''' Find faces in an image/video file '''
names = list()
people = list()
try:
image = face_recognition.load_image_file(file)
encodings = face_recognition.face_encodings(image)
@ -99,11 +101,11 @@ class image_classifier:
for known_person in self.known_people:
for encoding in encodings:
if face_recognition.compare_faces([known_person['encoding']], encoding)[0]:
names.append(known_person['name'])
people.append(known_person['name'])
except PIL.UnidentifiedImageError as error:
self._log.debug(f"File '{file}' don't seem to be an image.")
return False
return names
return people
def _init_log(self):
''' Initialize log object '''