예제 #1
0
    def test_should_not_detect(self):
        with open(abspath('./tests/fixtures/images/no_face.jpg')) as f:
            self.engine.load(f.read(), None)

        self.context.config.FACE_DETECTOR_CASCADE_FILE = abspath(
            './thumbor/detectors/face_detector/haarcascade_frontalface_default.xml'
        )

        FaceDetector(self.context, 0, []).detect(lambda: None)
        expect(self.context.request.focal_points).to_be_empty()
예제 #2
0
    def test_should_run_on_images_with_alpha(self):
        with open(abspath('./tests/fixtures/images/Giunchedi%2C_Filippo_January_2015_01.png')) as f:
            self.engine.load(f.read(), None)

        self.context.config.FACE_DETECTOR_CASCADE_FILE = abspath(
            './thumbor/detectors/face_detector/haarcascade_frontalface_default.xml',
        )
        if hasattr(FaceDetector, 'cascade'):
            del FaceDetector.cascade
        FaceDetector(self.context, 0, None).detect(lambda: None)
        detection_result = self.context.request.focal_points[0]
        expect(detection_result.origin).to_equal('Face Detection')
        expect(detection_result.x).to_be_numeric()
        expect(detection_result.y).to_be_numeric()
        expect(detection_result.width).to_be_numeric()
        expect(detection_result.height).to_be_numeric()
예제 #3
0
    def test_should_detect_one_face(self):
        with open(abspath('./tests/fixtures/images/one_face.jpg')) as f:
            self.engine.load(f.read(), None)

        for i, detector in enumerate([
                './thumbor/detectors/face_detector/haarcascade_frontalface_default.xml',
                './thumbor/detectors/face_detector/haarcascade_frontalface_alt.xml',
                './thumbor/detectors/face_detector/haarcascade_frontalface_alt2.xml',
                './thumbor/detectors/face_detector/haarcascade_frontalface_alt_tree.xml'
        ]):
            self.context.config.FACE_DETECTOR_CASCADE_FILE = abspath(detector)
            if hasattr(FaceDetector, 'cascade'):
                del FaceDetector.cascade
            FaceDetector(self.context, 0, None).detect(lambda: None)
            detection_result = self.context.request.focal_points[i]
            expect(detection_result.origin).to_equal('Face Detection')
            expect(detection_result.x).to_be_numeric()
            expect(detection_result.y).to_be_numeric()
            expect(detection_result.width).to_be_numeric()
            expect(detection_result.height).to_be_numeric()