diff --git a/bob/bio/face/config/preprocessor/histogram_equalization.py b/bob/bio/face/config/preprocessor/histogram_equalization.py index 96bad0adcdf62b65bd13310a3c28b54cc046fea1..32ceb409f19f22e89e03649515ffc8aababf6e3c 100644 --- a/bob/bio/face/config/preprocessor/histogram_equalization.py +++ b/bob/bio/face/config/preprocessor/histogram_equalization.py @@ -4,6 +4,10 @@ preprocessor = bob.bio.face.preprocessor.HistogramEqualization( face_cropper = 'face-crop-eyes' ) +preprocessor_landmark = bob.bio.face.preprocessor.HistogramEqualization( + face_cropper = 'landmark-detect' +) + preprocessor_no_crop = bob.bio.face.preprocessor.HistogramEqualization( face_cropper = None ) diff --git a/bob/bio/face/config/preprocessor/inorm_lbp.py b/bob/bio/face/config/preprocessor/inorm_lbp.py index 702dd2884799d69957cb5b2afd5245e97f983d23..e69c41ac7f37efadbea9ad8dbcce680fb839c5c3 100644 --- a/bob/bio/face/config/preprocessor/inorm_lbp.py +++ b/bob/bio/face/config/preprocessor/inorm_lbp.py @@ -6,6 +6,11 @@ preprocessor = bob.bio.face.preprocessor.INormLBP( dtype = numpy.float64 ) +preprocessor_landmark = bob.bio.face.preprocessor.INormLBP( + face_cropper = 'landmark-detect', + dtype = numpy.float64 +) + preprocessor_no_crop = bob.bio.face.preprocessor.INormLBP( face_cropper = None, dtype = numpy.float64 diff --git a/bob/bio/face/config/preprocessor/self_quotient_image.py b/bob/bio/face/config/preprocessor/self_quotient_image.py index 286f954f686d69d99097f2009c21247c9d8953a8..0ff239eb523a604ad5f2dbb8a8c72dcd7e12191e 100644 --- a/bob/bio/face/config/preprocessor/self_quotient_image.py +++ b/bob/bio/face/config/preprocessor/self_quotient_image.py @@ -4,6 +4,10 @@ preprocessor = bob.bio.face.preprocessor.SelfQuotientImage( face_cropper = 'face-crop-eyes' ) +preprocessor_landmark = bob.bio.face.preprocessor.SelfQuotientImage( + face_cropper = 'landmark-detect' +) + preprocessor_no_crop = bob.bio.face.preprocessor.SelfQuotientImage( face_cropper = None ) diff --git a/bob/bio/face/config/preprocessor/tan_triggs.py b/bob/bio/face/config/preprocessor/tan_triggs.py index faf64fd1bff784abda22c3fad7fa5b07a3b53f1a..0bbc67e288e22fc28eb39016336b61af9c3fb697 100644 --- a/bob/bio/face/config/preprocessor/tan_triggs.py +++ b/bob/bio/face/config/preprocessor/tan_triggs.py @@ -4,6 +4,10 @@ preprocessor = bob.bio.face.preprocessor.TanTriggs( face_cropper = 'face-crop-eyes' ) +preprocessor_landmark = bob.bio.face.preprocessor.TanTriggs( + face_cropper = 'landmark-detect' +) + preprocessor_no_crop = bob.bio.face.preprocessor.TanTriggs( face_cropper = None ) diff --git a/bob/bio/face/preprocessor/FaceDetect.py b/bob/bio/face/preprocessor/FaceDetect.py index e6402338ac03a3ceb5c60921b06d8d6ad088eaae..e833c67ce40a84c1bed732cb6d9fc1decc4b43b3 100644 --- a/bob/bio/face/preprocessor/FaceDetect.py +++ b/bob/bio/face/preprocessor/FaceDetect.py @@ -11,6 +11,8 @@ from .Base import Base from .utils import load_cropper_only from bob.bio.base.preprocessor import Preprocessor +import logging +logger = logging.getLogger("bob.bio.face") class FaceDetect (Base): @@ -75,7 +77,7 @@ class FaceDetect (Base): 'leye' : ((landmarks[2][0] + landmarks[6][0])/2., (landmarks[2][1] + landmarks[6][1])/2.) } else: - utils.warn("Could not detect landmarks -- using estimated landmarks") + logger.warn("Could not detect landmarks -- using estimated landmarks") # estimate from default locations return bob.ip.facedetect.expected_eye_positions(bounding_box) diff --git a/bob/bio/face/test/test_preprocessors.py b/bob/bio/face/test/test_preprocessors.py index 7b92a30eaf70da8ed40b38ce6353ccbf86a4daa5..1495394788bf7d8bc32d648bea1526fbc26bf3ec 100644 --- a/bob/bio/face/test/test_preprocessors.py +++ b/bob/bio/face/test/test_preprocessors.py @@ -128,10 +128,15 @@ def test_tan_triggs(): _compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/tan_triggs_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data) # test the preprocessor without cropping - preprocessor = bob.bio.face.preprocessor.TanTriggs(face_cropper=None) + preprocessor = bob.bio.base.load_resource('tan-triggs', 'preprocessor') + assert preprocessor.cropper is None # result must be identical to the original face cropper (same eyes are used) _compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/tan_triggs_none.hdf5'), preprocessor.write_data, preprocessor.read_data) + preprocessor = bob.bio.base.load_resource('tan-triggs-landmark', 'preprocessor') + assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect) + assert preprocessor.cropper.flandmark is not None + def test_inorm_lbp(): # read input @@ -145,6 +150,13 @@ def test_inorm_lbp(): # execute preprocessor _compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/inorm_lbp_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data) + # load the preprocessor without cropping + preprocessor = bob.bio.base.load_resource('inorm-lbp', 'preprocessor') + assert preprocessor.cropper is None + # load the preprocessor landmark detection + preprocessor = bob.bio.base.load_resource('inorm-lbp-landmark', 'preprocessor') + assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect) + def test_heq(): # read input @@ -158,6 +170,13 @@ def test_heq(): # execute preprocessor _compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/histogram_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data) + # load the preprocessor without cropping + preprocessor = bob.bio.base.load_resource('histogram', 'preprocessor') + assert preprocessor.cropper is None + # load the preprocessor landmark detection + preprocessor = bob.bio.base.load_resource('histogram-landmark', 'preprocessor') + assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect) + def test_sqi(): # read input @@ -171,6 +190,13 @@ def test_sqi(): # execute preprocessor _compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/self_quotient_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data) + # load the preprocessor without cropping + preprocessor = bob.bio.base.load_resource('self-quotient', 'preprocessor') + assert preprocessor.cropper is None + # load the preprocessor landmark detection + preprocessor = bob.bio.base.load_resource('self-quotient-landmark', 'preprocessor') + assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect) + """ def test06a_key_points(self): diff --git a/setup.py b/setup.py index a5299b0b688117d5d06c37bb7bbcda4ef1c304d8..499ac975b721fc99e36fad30889625422cd7cfce 100644 --- a/setup.py +++ b/setup.py @@ -122,24 +122,28 @@ setup( 'multipie-pose = bob.bio.face.config.database.multipie_pose:database', 'scface = bob.bio.face.config.database.scface:database', 'xm2vts = bob.bio.face.config.database.xm2vts:database', - ], 'bob.bio.preprocessor': [ 'base = bob.bio.face.config.preprocessor.base:preprocessor', # simple color conversion 'face-crop-eyes = bob.bio.face.config.preprocessor.face_crop_eyes:preprocessor', # face crop + 'landmark-detect = bob.bio.face.config.preprocessor.face_detect:preprocessor', # face detection + landmark detection + cropping + 'face-detect = bob.bio.face.config.preprocessor.face_detect:preprocessor_no_eyes', # face detection + cropping + 'inorm-lbp-crop = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor', # face crop + inorm-lbp 'tan-triggs-crop = bob.bio.face.config.preprocessor.tan_triggs:preprocessor', # face crop + Tan&Triggs 'histogram-crop = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor', # face crop + histogram equalization 'self-quotient-crop= bob.bio.face.config.preprocessor.self_quotient_image:preprocessor', # face crop + self quotient image - 'landmark-detect = bob.bio.face.config.preprocessor.face_detect:preprocessor', # face detection + landmark detection + cropping - 'face-detect = bob.bio.face.config.preprocessor.face_detect:preprocessor_no_eyes', # face detection + cropping + + 'inorm-lbp-landmark = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor_landmark', # face detection + landmark detection + cropping + inorm-lbp + 'tan-triggs-landmark = bob.bio.face.config.preprocessor.tan_triggs:preprocessor_landmark', # face detection + landmark detection + cropping + Tan&Triggs + 'histogram-landmark = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor_landmark', # face detection + landmark detection + cropping + histogram equalization + 'self-quotient-landmark = bob.bio.face.config.preprocessor.self_quotient_image:preprocessor_landmark', # face detection + landmark detection + cropping + self quotient image 'inorm-lbp = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor_no_crop', # inorm-lbp w/o face-crop 'tan-triggs = bob.bio.face.config.preprocessor.tan_triggs:preprocessor_no_crop', # Tan&Triggs w/o face-crop 'histogram = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor_no_crop', # histogram equalization w/o face-crop 'self-quotient = bob.bio.face.config.preprocessor.self_quotient_image:preprocessor_no_crop', # self quotient image w/o face-crop - ], 'bob.bio.extractor': [