Skip to content
Snippets Groups Projects
Commit 359cde0c authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Fixed no face detected issue in VideoFaceCrop

parent 436d474b
No related branches found
No related tags found
1 merge request!21Added a face detection functionality in the face cropping preprocessor
Pipeline #
......@@ -276,7 +276,15 @@ class VideoFaceCrop(Preprocessor, object):
if self.detect_faces_flag:
annotations = detect_faces_in_video(frames)
annotations_detected = detect_faces_in_video(frames)
if not annotations_detected:
annotations = annotations # if now annotations detected use DB annotations
else:
annotations = annotations_detected # if face was detected overwrite DB annotations
if len(frames) != len(annotations): # if some annotations are missing
......
......@@ -25,19 +25,14 @@ def detect_face_in_image(image):
``annotations`` : :py:class:`dict`
A dictionary containing annotations of the face bounding box.
Dictionary must be as follows ``{'topleft': (row, col), 'bottomright': (row, col)}``.
If no annotations found an empty dictionary is returned.
"""
data = bob.ip.dlib.FaceDetector().detect_single_face(image)
annotations = {}
if data is None:
annotations['topleft'] = (0, 0)
annotations['bottomright'] = (0, 0)
else:
if data is not None:
bounding_box = data[0]
......@@ -65,6 +60,7 @@ def detect_faces_in_video(frame_container):
Dictionary structure: ``annotations = {'1': frame1_dict, '2': frame1_dict, ...}``.
Where ``frameN_dict = {'topleft': (row, col), 'bottomright': (row, col)}``
is the dictionary defining the coordinates of the face bounding box in frame N.
If no annotations found an empty dictionary is returned.
"""
annotations = {}
......@@ -75,7 +71,9 @@ def detect_faces_in_video(frame_container):
frame_annotations = detect_face_in_image(image)
annotations[str(idx)] = frame_annotations
if frame_annotations:
annotations[str(idx)] = frame_annotations
return annotations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment