From 2d9a724d7baf372d9c8d2cb3f1940ea0adf5da19 Mon Sep 17 00:00:00 2001 From: Amir MOHAMMADI <amir.mohammadi@idiap.ch> Date: Thu, 23 Nov 2017 16:44:21 +0100 Subject: [PATCH] Use all frames. Improve docs --- bob/pad/face/database/database.py | 35 ++++++++++++++++++-------- bob/pad/face/database/mifs.py | 3 +++ bob/pad/face/database/msu_mfsd.py | 3 +++ bob/pad/face/database/replay.py | 29 +++------------------ bob/pad/face/database/replay_mobile.py | 3 +++ 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/bob/pad/face/database/database.py b/bob/pad/face/database/database.py index 5d029071..8f88445f 100644 --- a/bob/pad/face/database/database.py +++ b/bob/pad/face/database/database.py @@ -1,23 +1,36 @@ from bob.pad.base.database import PadFile -from bob.bio.video.database import VideoBioFile +import bob.bio.video -class VideoPadFile(VideoBioFile, PadFile): +class VideoPadFile(PadFile): """A simple base class that defines basic properties of File object for the - use in PAD experiments + use in face PAD experiments. """ def __init__(self, attack_type, client_id, path, file_id=None): - VideoBioFile.__init__( - self, - client_id=client_id, - path=path, - file_id=file_id, - ) - PadFile.__init__( - self, + super(VideoPadFile, self).__init__( attack_type=attack_type, client_id=client_id, path=path, file_id=file_id, ) + + def load(self, directory=None, extension='.avi', + frame_selector=bob.bio.video.FrameSelector(selection_style='all')): + """Loads the video file and returns in a :any:`bob.bio.video.FrameContainer`. + + Parameters + ---------- + directory : :obj:`str`, optional + The directory to load the data from. + extension : :obj:`str`, optional + The extension of the file to load. + frame_selector : :any:`bob.bio.video.FrameSelector`, optional + Which frames to select. + + Returns + ------- + :any:`bob.bio.video.FrameContainer` + The loaded frames inside a frame container. + """ + return frame_selector(self.make_path(directory, extension)) diff --git a/bob/pad/face/database/mifs.py b/bob/pad/face/database/mifs.py index d66cc4af..2b77f19e 100644 --- a/bob/pad/face/database/mifs.py +++ b/bob/pad/face/database/mifs.py @@ -41,6 +41,9 @@ class MIFSPadFile(VideoPadFile): Extension of the video files in the MIFS database. Default: None + ``frame_selector`` : ``FrameSelector`` + The frame selector to use. + **Returns:** ``video_data`` : FrameContainer diff --git a/bob/pad/face/database/msu_mfsd.py b/bob/pad/face/database/msu_mfsd.py index 6783d888..80e8ab52 100644 --- a/bob/pad/face/database/msu_mfsd.py +++ b/bob/pad/face/database/msu_mfsd.py @@ -66,6 +66,9 @@ class MsuMfsdPadFile(VideoPadFile): Note: ``extension`` value is not used in the code of this method. Default: None + ``frame_selector`` : ``FrameSelector`` + The frame selector to use. + **Returns:** ``video_data`` : FrameContainer diff --git a/bob/pad/face/database/replay.py b/bob/pad/face/database/replay.py index 8a9ff58f..f9988487 100644 --- a/bob/pad/face/database/replay.py +++ b/bob/pad/face/database/replay.py @@ -48,32 +48,9 @@ class ReplayPadFile(VideoPadFile): attack_type=attack_type, file_id=f.id) - #========================================================================== - def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')): - """ - Overridden version of the load method defined in the ``VideoPadFile``. - - **Parameters:** - - ``directory`` : :py:class:`str` - String containing the path to the Replay database. - - ``extension`` : :py:class:`str` - Extension of the video files in the Replay database. - - **Returns:** - - ``video_data`` : FrameContainer - Video data stored in the FrameContainer, see ``bob.bio.video.utils.FrameContainer`` - for further details. - """ - - path = self.f.make_path( - directory=directory, extension=extension) # path to the video file - - video_data = frame_selector(path) # video data - - return video_data # video data + def make_path(self, directory=None, extension='.mov'): + # path to the video file + return self.f.make_path(directory=directory, extension=extension) #============================================================================== diff --git a/bob/pad/face/database/replay_mobile.py b/bob/pad/face/database/replay_mobile.py index 75c23b7a..82f8444a 100644 --- a/bob/pad/face/database/replay_mobile.py +++ b/bob/pad/face/database/replay_mobile.py @@ -59,6 +59,9 @@ class ReplayMobilePadFile(VideoPadFile): ``extension`` : :py:class:`str` Extension of the video files in the Replay-Mobile database. + ``frame_selector`` : ``FrameSelector`` + The frame selector to use. + **Returns:** ``video_data`` : FrameContainer -- GitLab