From 009e21a8a640467c3bd0069ec75975cc0ba6219e Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Mon, 12 Mar 2018 14:59:12 +0100
Subject: [PATCH] Test min_face_size_validator

---
 bob/bio/face/annotator/__init__.py   |  4 +++-
 bob/bio/face/test/test_annotators.py | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/bob/bio/face/annotator/__init__.py b/bob/bio/face/annotator/__init__.py
index ce553638..e4969dac 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 4f71886e..e35c0a4a 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({})
-- 
GitLab