Skip to content
Snippets Groups Projects
Commit c566bd39 authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Added a unit test for BW-NIR-D preprocessor instance

parent ee53d54a
No related branches found
No related tags found
1 merge request!84Multi-channel data preprocessing
Pipeline #26288 passed
......@@ -240,6 +240,8 @@ class VideoFaceCropAlignBlockPatch(Preprocessor, object):
facial region. ROI is annotated as follows:
``annotations['face_roi'][0] = [x_top_left, y_top_left]``
``annotations['face_roi'][1] = [x_bottom_right, y_bottom_right]``
If ``face_roi`` annotations are undefined, the patches will be
extracted from an entire cropped facial image.
**Returns:**
......
......@@ -52,6 +52,8 @@ from bob.pad.face.config.preprocessor.face_feature_crop_quality_check import fac
from bob.pad.face.utils.patch_utils import reshape_flat_patches
from bob.pad.face.config.preprocessor.video_face_crop_align_block_patch import video_face_crop_align_bw_ir_d_channels_3x128x128 as mc_preprocessor
def test_detect_face_landmarks_in_image_mtcnn():
......@@ -335,6 +337,42 @@ def test_preproc_with_quality_check():
assert data_preprocessed is None
# =============================================================================
def test_multi_channel_preprocessing():
"""
Test video_face_crop_align_bw_ir_d_channels_3x128x128 preprocessor.
"""
# =========================================================================
# prepare the test data:
image = load(datafile('test_image.png', 'bob.pad.face.test'))
# annotations must be known for this preprocessor, so compute them:
annotations = detect_face_landmarks_in_image(image, method="mtcnn")
video_color, annotations = convert_image_to_video_data(image, annotations, 2)
video_bw, _ = convert_image_to_video_data(image[0], annotations, 2)
mc_video = {}
mc_video["color"] = video_color
mc_video["infrared"] = video_bw
mc_video["depth"] = video_bw
# =========================================================================
# test the preprocessor:
data_preprocessed = mc_preprocessor(mc_video, annotations)
assert len(data_preprocessed) == 2
assert data_preprocessed[0][1].shape == (3, 128, 128)
# chanenls are preprocessed differently, thus this should apply:
assert np.any(data_preprocessed[0][1][0] != data_preprocessed[0][1][1])
assert np.any(data_preprocessed[0][1][0] != data_preprocessed[0][1][2])
# =============================================================================
def test_reshape_flat_patches():
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment