From 39145a54fcc394bf18166ff68bf8d1fa3dec57a8 Mon Sep 17 00:00:00 2001 From: Guillaume HEUSCH <guillaume.heusch@idiap.ch> Date: Tue, 10 Jul 2018 13:55:41 +0200 Subject: [PATCH] [preprocessor] fixed the problem with mean color extraction from a masked area --- bob/pad/face/preprocessor/LiPulseExtraction.py | 11 +++++++---- bob/pad/face/preprocessor/PPGSecure.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bob/pad/face/preprocessor/LiPulseExtraction.py b/bob/pad/face/preprocessor/LiPulseExtraction.py index 6a4a5899..3f7f2eec 100644 --- a/bob/pad/face/preprocessor/LiPulseExtraction.py +++ b/bob/pad/face/preprocessor/LiPulseExtraction.py @@ -134,7 +134,7 @@ class LiPulseExtraction(Preprocessor): ldms = previous_ldms # so do nothing ... logger.warning("No mask detected in frame {}".format(i)) - face_color[i] = 0 + face_color[i] = [0, 0, 0] continue frame = frame_rotated @@ -144,6 +144,7 @@ class LiPulseExtraction(Preprocessor): logger.warning("Frame {}: no landmarks detected, using the ones from previous frame".format(i)) if self.debug: + if False: from matplotlib import pyplot display = numpy.copy(frame) for p in ldms: @@ -152,10 +153,12 @@ class LiPulseExtraction(Preprocessor): pyplot.show() ldms = numpy.array(ldms) - mask_points, mask = kp66_to_mask(frame, ldms, self.indent, self.debug) + #mask_points, mask = kp66_to_mask(frame, ldms, self.indent, self.debug) + mask_points, mask = kp66_to_mask(frame, ldms, self.indent, False) - #XXX : be sure that the 3 colors are returned !! - face_color[i] = compute_average_colors_mask(frame, mask, self.debug) + #face_color[i] = compute_average_colors_mask(frame, mask, self.debug) + face_color[i] = compute_average_colors_mask(frame, mask, False) + logger.debug("Face color in frame {} = {}".format(i, face_color[i]) previous_ldms = ldms counter += 1 diff --git a/bob/pad/face/preprocessor/PPGSecure.py b/bob/pad/face/preprocessor/PPGSecure.py index 33a944bd..36b201d1 100644 --- a/bob/pad/face/preprocessor/PPGSecure.py +++ b/bob/pad/face/preprocessor/PPGSecure.py @@ -130,7 +130,7 @@ class PPGSecure(Preprocessor): # get the mask and the green value in the different ROIs masks = self._get_masks(frame, ldms) for k in range(5): - green_mean[i, k] = compute_average_colors_mask(frame, masks[k], self.debug) + green_mean[i, k] = compute_average_colors_mask(frame, masks[k], self.debug)[1] previous_ldms = ldms -- GitLab