diff --git a/insomniac/extra_features/face_detector.py b/insomniac/extra_features/face_detector.py new file mode 100644 index 0000000..4b06400 --- /dev/null +++ b/insomniac/extra_features/face_detector.py @@ -0,0 +1,3 @@ +from insomniac import activation_controller + +exec(activation_controller.get_extra_feature('face_detector')) diff --git a/insomniac/tests/assets/face1.jpg b/insomniac/tests/assets/face1.jpg new file mode 100644 index 0000000..f656bc3 Binary files /dev/null and b/insomniac/tests/assets/face1.jpg differ diff --git a/insomniac/tests/assets/face2.jpg b/insomniac/tests/assets/face2.jpg new file mode 100644 index 0000000..18a28d5 Binary files /dev/null and b/insomniac/tests/assets/face2.jpg differ diff --git a/insomniac/tests/assets/face3.jpg b/insomniac/tests/assets/face3.jpg new file mode 100644 index 0000000..4e1a975 Binary files /dev/null and b/insomniac/tests/assets/face3.jpg differ diff --git a/insomniac/tests/assets/notface1.jpg b/insomniac/tests/assets/notface1.jpg new file mode 100644 index 0000000..2b451d4 Binary files /dev/null and b/insomniac/tests/assets/notface1.jpg differ diff --git a/insomniac/tests/assets/notface2.jpg b/insomniac/tests/assets/notface2.jpg new file mode 100644 index 0000000..06ddc88 Binary files /dev/null and b/insomniac/tests/assets/notface2.jpg differ diff --git a/insomniac/tests/face_detector_tests.py b/insomniac/tests/face_detector_tests.py new file mode 100644 index 0000000..7b0954a --- /dev/null +++ b/insomniac/tests/face_detector_tests.py @@ -0,0 +1,35 @@ +import os +import unittest + +from insomniac.extra_features.face_detector import FaceDetector + + +class FaceDetectorTests(unittest.TestCase): + + ASSETS_DIR = "assets" + face_detector = FaceDetector() + + def setUp(self): + print("Initializing FaceDetector") + self.face_detector.init() + + def test_positive(self): + for file in os.listdir(self.ASSETS_DIR): + filename = os.fsdecode(file) + if filename.startswith("face"): + is_face = self.face_detector.is_face_on_image_by_filename(os.path.join(self.ASSETS_DIR, file)) + assert is_face + + def test_negative(self): + for file in os.listdir(self.ASSETS_DIR): + filename = os.fsdecode(file) + if filename.startswith("notface"): + is_face = self.face_detector.is_face_on_image_by_filename(os.path.join(self.ASSETS_DIR, file)) + assert not is_face + + @staticmethod + def _interpret_faces_array(faces) -> str: + if len(faces) > 0: + return "face" + else: + return "not face"