Skip to content
Snippets Groups Projects
Commit 6cad6f98 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

Read the should_flip metadata from the csv file

parent 4ea5b95e
No related branches found
No related tags found
1 merge request!106Vulnerability framework - CSV datasets
...@@ -17,7 +17,7 @@ import numpy ...@@ -17,7 +17,7 @@ import numpy
logger = bob.core.log.setup("bob.bio.face") logger = bob.core.log.setup("bob.bio.face")
def load_frame_from_file_replaymobile(file_name, frame, capturing_device): def load_frame_from_file_replaymobile(file_name, frame, should_flip):
"""Loads a single frame from a video file for replay-mobile. """Loads a single frame from a video file for replay-mobile.
This function uses bob's video reader utility that does not load the full This function uses bob's video reader utility that does not load the full
...@@ -48,7 +48,7 @@ def load_frame_from_file_replaymobile(file_name, frame, capturing_device): ...@@ -48,7 +48,7 @@ def load_frame_from_file_replaymobile(file_name, frame, capturing_device):
# Image captured by the 'mobile' device are flipped vertically. # Image captured by the 'mobile' device are flipped vertically.
# (Images were captured horizontally and bob.io.video does not read the # (Images were captured horizontally and bob.io.video does not read the
# metadata correctly, whether it was on the right or left side) # metadata correctly, whether it was on the right or left side)
if capturing_device == "mobile": if should_flip:
image = numpy.flip(image, 2) image = numpy.flip(image, 2)
# Convert to bob format (channel, height, width) # Convert to bob format (channel, height, width)
image = numpy.transpose(image, (0, 2, 1)) image = numpy.transpose(image, (0, 2, 1))
...@@ -135,13 +135,15 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics): ...@@ -135,13 +135,15 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics):
else: else:
if "subject_id" not in kwargs: if "subject_id" not in kwargs:
raise ValueError(f"`subject_id` not available in {header}") raise ValueError(f"`subject_id` not available in {header}")
if "should_flip" not in kwargs:
raise ValueError(f"`should_flip` not available in {header}")
# One row leads to multiple samples (different frames) # One row leads to multiple samples (different frames)
all_samples = [DelayedSample( all_samples = [DelayedSample(
functools.partial( functools.partial(
load_frame_from_file_replaymobile, load_frame_from_file_replaymobile,
file_name=os.path.join(self.dataset_original_directory, path + self.extension), file_name=os.path.join(self.dataset_original_directory, path + self.extension),
frame=frame, frame=frame,
capturing_device=kwargs["capturing_device"], should_flip=kwargs["should_flip"]=="TRUE",
), ),
key=f"{id}_{frame}", key=f"{id}_{frame}",
path=path, path=path,
......
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