From 65f0b81f568c02ecbee671a258b14ac54a84b123 Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Thu, 23 Nov 2017 16:17:18 +0100
Subject: [PATCH] Add a base pad file for all face pad databases

---
 bob/pad/face/database/__init__.py      |  6 ++++--
 bob/pad/face/database/aggregated_db.py |  6 +++---
 bob/pad/face/database/database.py      | 23 +++++++++++++++++++++++
 bob/pad/face/database/mifs.py          |  6 +++---
 bob/pad/face/database/msu_mfsd.py      |  6 +++---
 bob/pad/face/database/replay.py        |  6 +++---
 bob/pad/face/database/replay_mobile.py |  6 +++---
 doc/api.rst                            |  5 +++++
 8 files changed, 47 insertions(+), 17 deletions(-)
 create mode 100644 bob/pad/face/database/database.py

diff --git a/bob/pad/face/database/__init__.py b/bob/pad/face/database/__init__.py
index a2f0469a..12814bda 100644
--- a/bob/pad/face/database/__init__.py
+++ b/bob/pad/face/database/__init__.py
@@ -1,3 +1,4 @@
+from .database import VideoPadFile
 from .replay import ReplayPadDatabase
 from .replay_mobile import ReplayMobilePadDatabase
 from .msu_mfsd import MsuMfsdPadDatabase
@@ -8,8 +9,8 @@ from .mifs import MIFSPadDatabase
 # gets sphinx autodoc done right - don't remove it
 def __appropriate__(*args):
     """Says object was actually declared here, and not in the import module.
-  Fixing sphinx warnings of not being able to find classes, when path is shortened.
-  Parameters:
+  Fixing sphinx warnings of not being able to find classes, when path is
+  shortened. Parameters:
 
     *args: An iterable of objects to modify
 
@@ -22,6 +23,7 @@ def __appropriate__(*args):
 
 
 __appropriate__(
+    VideoPadFile,
     ReplayPadDatabase,
     ReplayMobilePadDatabase,
     MsuMfsdPadDatabase,
diff --git a/bob/pad/face/database/aggregated_db.py b/bob/pad/face/database/aggregated_db.py
index c8072e24..75e91b32 100644
--- a/bob/pad/face/database/aggregated_db.py
+++ b/bob/pad/face/database/aggregated_db.py
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 #==============================================================================
-from bob.pad.base.database import PadFile  # Used in ReplayPadFile class
+from bob.pad.face.database import VideoPadFile  # Used in ReplayPadFile class
 
 from bob.pad.base.database import PadDatabase
 
@@ -21,7 +21,7 @@ import numpy as np
 
 
 #==============================================================================
-class AggregatedDbPadFile(PadFile):
+class AggregatedDbPadFile(VideoPadFile):
     """
     A high level implementation of the File class for the Aggregated Database
     uniting 4 databases: REPLAY-ATTACK, REPLAY-MOBILE, MSU MFSD and Mobio.
@@ -190,7 +190,7 @@ class AggregatedDbPadFile(PadFile):
     #==========================================================================
     def load(self, directory=None, extension='.mov'):
         """
-        Overridden version of the load method defined in the ``PadFile``.
+        Overridden version of the load method defined in the ``VideoPadFile``.
 
         **Parameters:**
 
diff --git a/bob/pad/face/database/database.py b/bob/pad/face/database/database.py
new file mode 100644
index 00000000..5d029071
--- /dev/null
+++ b/bob/pad/face/database/database.py
@@ -0,0 +1,23 @@
+from bob.pad.base.database import PadFile
+from bob.bio.video.database import VideoBioFile
+
+
+class VideoPadFile(VideoBioFile, PadFile):
+    """A simple base class that defines basic properties of File object for the
+    use in 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,
+            attack_type=attack_type,
+            client_id=client_id,
+            path=path,
+            file_id=file_id,
+        )
diff --git a/bob/pad/face/database/mifs.py b/bob/pad/face/database/mifs.py
index f15ee12b..d66cc4af 100644
--- a/bob/pad/face/database/mifs.py
+++ b/bob/pad/face/database/mifs.py
@@ -10,14 +10,14 @@ from bob.bio.video import FrameSelector, FrameContainer
 import bob.io.base
 import numpy as np
 
-from bob.pad.base.database import PadFile  # Used in ReplayPadFile class
+from bob.pad.face.database import VideoPadFile  # Used in ReplayPadFile class
 
 from bob.pad.base.database import FileListPadDatabase
 
 #==============================================================================
 
 
-class MIFSPadFile(PadFile):
+class MIFSPadFile(VideoPadFile):
     """
     A high level implementation of the File class for the MIFS database.
     """
@@ -29,7 +29,7 @@ class MIFSPadFile(PadFile):
     #==========================================================================
     def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')):
         """
-        Overridden version of the load method defined in the ``PadFile``.
+        Overridden version of the load method defined in the ``VideoPadFile``.
 
         **Parameters:**
 
diff --git a/bob/pad/face/database/msu_mfsd.py b/bob/pad/face/database/msu_mfsd.py
index 5432ced1..6783d888 100644
--- a/bob/pad/face/database/msu_mfsd.py
+++ b/bob/pad/face/database/msu_mfsd.py
@@ -5,7 +5,7 @@
 # Used in ReplayMobilePadFile class
 from bob.bio.video import FrameSelector, FrameContainer
 
-from bob.pad.base.database import PadFile  # Used in MsuMfsdPadFile class
+from bob.pad.face.database import VideoPadFile  # Used in MsuMfsdPadFile class
 
 from bob.pad.base.database import PadDatabase
 
@@ -15,7 +15,7 @@ import numpy as np
 
 
 #==============================================================================
-class MsuMfsdPadFile(PadFile):
+class MsuMfsdPadFile(VideoPadFile):
     """
     A high level implementation of the File class for the MSU MFSD database.
     """
@@ -53,7 +53,7 @@ class MsuMfsdPadFile(PadFile):
     #==========================================================================
     def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')):
         """
-        Overridden version of the load method defined in the ``PadFile``.
+        Overridden version of the load method defined in the ``VideoPadFile``.
 
         **Parameters:**
 
diff --git a/bob/pad/face/database/replay.py b/bob/pad/face/database/replay.py
index 203136c0..8a9ff58f 100644
--- a/bob/pad/face/database/replay.py
+++ b/bob/pad/face/database/replay.py
@@ -6,14 +6,14 @@
 # Used in ReplayMobilePadFile class
 from bob.bio.video import FrameSelector, FrameContainer
 
-from bob.pad.base.database import PadFile  # Used in ReplayPadFile class
+from bob.pad.face.database import VideoPadFile  # Used in ReplayPadFile class
 
 from bob.pad.base.database import PadDatabase
 
 #==============================================================================
 
 
-class ReplayPadFile(PadFile):
+class ReplayPadFile(VideoPadFile):
     """
     A high level implementation of the File class for the REPLAY-ATTACK database.
     """
@@ -51,7 +51,7 @@ class ReplayPadFile(PadFile):
     #==========================================================================
     def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')):
         """
-        Overridden version of the load method defined in the ``PadFile``.
+        Overridden version of the load method defined in the ``VideoPadFile``.
 
         **Parameters:**
 
diff --git a/bob/pad/face/database/replay_mobile.py b/bob/pad/face/database/replay_mobile.py
index 843dee92..75c23b7a 100644
--- a/bob/pad/face/database/replay_mobile.py
+++ b/bob/pad/face/database/replay_mobile.py
@@ -5,13 +5,13 @@
 # Used in ReplayMobilePadFile class
 from bob.bio.video import FrameSelector, FrameContainer
 
-from bob.pad.base.database import PadFile  # Used in ReplayMobilePadFile class
+from bob.pad.face.database import VideoPadFile  # Used in ReplayMobilePadFile class
 
 from bob.pad.base.database import PadDatabase
 
 
 #==============================================================================
-class ReplayMobilePadFile(PadFile):
+class ReplayMobilePadFile(VideoPadFile):
     """
     A high level implementation of the File class for the Replay-Mobile database.
     """
@@ -49,7 +49,7 @@ class ReplayMobilePadFile(PadFile):
     #==========================================================================
     def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')):
         """
-        Overridden version of the load method defined in the ``PadFile``.
+        Overridden version of the load method defined in the ``VideoPadFile``.
 
         **Parameters:**
 
diff --git a/doc/api.rst b/doc/api.rst
index 74a89cd7..d1dde968 100644
--- a/doc/api.rst
+++ b/doc/api.rst
@@ -12,6 +12,11 @@ This section lists all the functionality available in this library allowing to r
 Database Interfaces
 ------------------------------
 
+Base classes
+============
+
+.. autoclass:: bob.pad.face.database.VideoPadFile
+
 
 REPLAY-ATTACK Database
 ========================
-- 
GitLab