Fix exception dlib_face_identify when image is not recognized by face_recognition module (#8552)

*   Some images are not supported by face_recognition, so this patch treats the error
  messages instead throwing a traceback. Fixes #7867

* Makes lint happy
This commit is contained in:
Marcelo Moreira de Mello 2017-07-19 03:04:01 -04:00 committed by Pascal Vizeli
parent 1a86fa5a02
commit 4ece4bf241

View File

@ -58,8 +58,12 @@ class DlibFaceIdentifyEntity(ImageProcessingFaceEntity):
self._faces = {}
for face_name, face_file in faces.items():
image = face_recognition.load_image_file(face_file)
self._faces[face_name] = face_recognition.face_encodings(image)[0]
try:
image = face_recognition.load_image_file(face_file)
self._faces[face_name] = \
face_recognition.face_encodings(image)[0]
except IndexError as err:
_LOGGER.error("Failed to parse %s. Error: %s", face_file, err)
@property
def camera_entity(self):