diff --git a/bob/bio/face/annotator/__init__.py b/bob/bio/face/annotator/__init__.py index ce553638a891bb84b554f9c323834e1931e060a1..e4969daca3857c6f664d7d27ab64ab539d63314e 100644 --- a/bob/bio/face/annotator/__init__.py +++ b/bob/bio/face/annotator/__init__.py @@ -36,7 +36,9 @@ def min_face_size_validator(annotations, min_face_size=(32, 32)): bool True, if the face is large enough. """ - bbx = bob.ip.facedetect.bounding_box_from_annotations( + if not annotations: + return False + bbx = bob.ip.facedetect.bounding_box_from_annotation( source='direct', **annotations) if bbx.size < min_face_size: return False diff --git a/bob/bio/face/test/test_annotators.py b/bob/bio/face/test/test_annotators.py index 4f71886e0124738751270f132f9b042fb8a9af35..e35c0a4a199dee80295b8729b3d8eb57bbf7ac5e 100644 --- a/bob/bio/face/test/test_annotators.py +++ b/bob/bio/face/test/test_annotators.py @@ -2,7 +2,8 @@ import bob.io.base import bob.io.base.test_utils import bob.io.image from bob.bio.face.annotator import ( - BobIpFacedetect, BoundingBoxToEyes, BobIpFlandmark) + BobIpFacedetect, BoundingBoxToEyes, BobIpFlandmark, + min_face_size_validator) from bob.bio.base.annotator import FailSafe import numpy @@ -46,3 +47,20 @@ def test_bob_ip_flandmark(): _assert_bob_ip_facedetect(annot) assert [int(x) for x in annot['reye']] == [183, 127], annot assert [int(x) for x in annot['leye']] == [174, 223], annot + + +def test_min_face_size_validator(): + valid = { + 'topleft': (0, 0), + 'bottomright': (32, 32), + } + assert min_face_size_validator(valid) + + not_valid = { + 'topleft': (0, 0), + 'bottomright': (28, 32), + } + assert not min_face_size_validator(not_valid) + + assert not min_face_size_validator(None) + assert not min_face_size_validator({})