diff --git a/bob/pad/face/database/aggregated_db.py b/bob/pad/face/database/aggregated_db.py index fec72e5b9a4fd4920ffe4a7906477f649e13b24e..c8072e246b76f888f5f632124729ac26a3b7b71b 100644 --- a/bob/pad/face/database/aggregated_db.py +++ b/bob/pad/face/database/aggregated_db.py @@ -15,7 +15,7 @@ from bob.pad.face.database import msu_mfsd as msu_mfsd_hldi from bob.bio.video.database.mobio import MobioBioFile -from bob.bio.video import FrameSelector +from bob.bio.video import FrameSelector, FrameContainer import numpy as np diff --git a/bob/pad/face/database/mifs.py b/bob/pad/face/database/mifs.py index beaba9dd049cd4d05f7ed4b00387a88794c03ab3..f15ee12b8e855917585b33f55da3acd64a782d1d 100644 --- a/bob/pad/face/database/mifs.py +++ b/bob/pad/face/database/mifs.py @@ -5,7 +5,8 @@ #============================================================================== -import bob.bio.video # Used in MIFSPadFile class +# Used in ReplayMobilePadFile class +from bob.bio.video import FrameSelector, FrameContainer import bob.io.base import numpy as np @@ -26,7 +27,7 @@ class MIFSPadFile(PadFile): file_id) #========================================================================== - def load(self, directory=None, extension=None): + def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')): """ Overridden version of the load method defined in the ``PadFile``. @@ -49,9 +50,6 @@ class MIFSPadFile(PadFile): path = self.make_path( directory=directory, extension=extension) # path to the file - frame_selector = bob.bio.video.FrameSelector( - selection_style='all' - ) # this frame_selector will select all frames from the video file data = bob.io.base.load(path) data = np.expand_dims(data, axis=0) # upgrade to 4D (video) diff --git a/bob/pad/face/database/msu_mfsd.py b/bob/pad/face/database/msu_mfsd.py index eb4ed5f743e4a77b74b826a311d87d282c03242b..5432ced1c37f3fb25afdf887ea1b2845dab4bf19 100644 --- a/bob/pad/face/database/msu_mfsd.py +++ b/bob/pad/face/database/msu_mfsd.py @@ -2,7 +2,8 @@ # -*- coding: utf-8 -*- #============================================================================== -import bob.bio.video # Used in MsuMfsdPadFile class +# Used in ReplayMobilePadFile class +from bob.bio.video import FrameSelector, FrameContainer from bob.pad.base.database import PadFile # Used in MsuMfsdPadFile class @@ -50,35 +51,7 @@ class MsuMfsdPadFile(PadFile): file_id=f.id) #========================================================================== - def convert_arr_to_frame_cont(self, data): - """ - This function converts an input 4D array with frames into FrameContainer, - where each frame is an RGB image. The dimensionality of the input array - is [N_frames, 3, N_rows, N_cols]. - - **Parameters:** - - ``data`` : 4D :py:class:`numpy.ndarray` - An input 4D array with frames of the dimensionality: - [N_frames, 3, N_rows, N_cols]. - - **Returns:** - - ``frames`` : FrameContainer - Resulting FrameContainer containing RGB frames. - """ - - frames = bob.bio.video.FrameContainer( - ) # initialize the FrameContainer - - for idx, sample in enumerate(data): - - frames.add(idx, sample) - - return frames - - #========================================================================== - def load(self, directory=None, extension=None): + def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')): """ Overridden version of the load method defined in the ``PadFile``. @@ -105,11 +78,7 @@ class MsuMfsdPadFile(PadFile): video_data_array = self.f.load( directory=directory, extension=extension) - - video_data = self.convert_arr_to_frame_cont( - video_data_array) # the result is now a FrameContainer - - return video_data + return frame_selector(video_data_array) #============================================================================== diff --git a/bob/pad/face/database/replay.py b/bob/pad/face/database/replay.py index fb1092ca196177f9a7bb31f52627a9c9c2021a50..203136c0a41e3f3e0cbe0ca13145bd0789fb82be 100644 --- a/bob/pad/face/database/replay.py +++ b/bob/pad/face/database/replay.py @@ -3,7 +3,8 @@ #============================================================================== -import bob.bio.video # Used in ReplayPadFile class +# Used in ReplayMobilePadFile class +from bob.bio.video import FrameSelector, FrameContainer from bob.pad.base.database import PadFile # Used in ReplayPadFile class @@ -48,7 +49,7 @@ class ReplayPadFile(PadFile): file_id=f.id) #========================================================================== - def load(self, directory=None, extension='.mov'): + def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')): """ Overridden version of the load method defined in the ``PadFile``. @@ -70,10 +71,6 @@ class ReplayPadFile(PadFile): path = self.f.make_path( directory=directory, extension=extension) # path to the video file - frame_selector = bob.bio.video.FrameSelector( - selection_style='all' - ) # this frame_selector will select all frames from the video file - video_data = frame_selector(path) # video data return video_data # video data diff --git a/bob/pad/face/database/replay_mobile.py b/bob/pad/face/database/replay_mobile.py index 862d45558acbbe50b8c1ae5b79415333bf751d39..843dee928dbb091e9f339f78b428e6417adad433 100644 --- a/bob/pad/face/database/replay_mobile.py +++ b/bob/pad/face/database/replay_mobile.py @@ -2,7 +2,8 @@ # -*- coding: utf-8 -*- #============================================================================== -import bob.bio.video # Used in ReplayMobilePadFile class +# Used in ReplayMobilePadFile class +from bob.bio.video import FrameSelector, FrameContainer from bob.pad.base.database import PadFile # Used in ReplayMobilePadFile class @@ -46,35 +47,7 @@ class ReplayMobilePadFile(PadFile): file_id=f.id) #========================================================================== - def convert_arr_to_frame_cont(self, data): - """ - This function converts an input 4D array with frames into FrameContainer, - where each frame is an RGB image. The dimensionality of the input array - is [N_frames, 3, N_rows, N_cols]. - - **Parameters:** - - ``data`` : 4D :py:class:`numpy.ndarray` - An input 4D array with frames of the dimensionality: - [N_frames, 3, N_rows, N_cols]. - - **Returns:** - - ``frames`` : FrameContainer - Resulting FrameContainer containing RGB frames. - """ - - frames = bob.bio.video.FrameContainer( - ) # initialize the FrameContainer - - for idx, sample in enumerate(data): - - frames.add(idx, sample) - - return frames - - #========================================================================== - def load(self, directory=None, extension='.mov'): + def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')): """ Overridden version of the load method defined in the ``PadFile``. @@ -96,10 +69,7 @@ class ReplayMobilePadFile(PadFile): video_data_array = self.f.load( directory=directory, extension=extension) - video_data = self.convert_arr_to_frame_cont( - video_data_array) # the result is now a FrameContainer - - return video_data + return frame_selector(video_data_array) #==============================================================================