def test_load_image_exception(self): # Cloud not read exception with self.assertRaises(ValueError): image = facecrop.load_image(image_path='./sample/99999.jpeg') # Image dimension exceeded limit exception with self.assertRaises(ValueError): image = facecrop.load_image(image_path='./sample/IMG_0102.JPG')
def test_get_largest_face(self): # Should return largest cropped face (numpy.ndarray) image = facecrop.load_image(image_path='./sample/2.jpg') lg_face, bound = facecrop.get_largest_face( image=image, faces=facecrop.detect_face(image)) self.assertIsInstance(lg_face, numpy.ndarray) # Compare if it is the same largest face mssim = compare_image(lg_face, cv2.imread('./tests/asset/2.jpg')) self.assertGreaterEqual(mssim, .9)
def test_detect_face_exception(self): # No face detected exception with self.assertRaises(ValueError): faces = facecrop.detect_face(image=facecrop.load_image( image_path='./sample/blank.jpg'))
def test_detect_face(self): # Should return faces (dlib.rectangles) faces = facecrop.detect_face(image=facecrop.load_image( image_path='./sample/0.jpg')) self.assertIsInstance(faces, dlib.rectangles)
def test_load_image(self): # Should return image (numpy.ndarray) image = facecrop.load_image(image_path='./sample/0.jpg') self.assertIsInstance(image, numpy.ndarray)