diff --git a/bob/bio/face/config/database/replay.py b/bob/bio/face/config/database/replay.py new file mode 100644 index 0000000000000000000000000000000000000000..46f088cc21607d0ce6cf1c26fb43467290cf1af2 --- /dev/null +++ b/bob/bio/face/config/database/replay.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +from bob.bio.face.database import ReplayBioDatabase + +replay_attack_directory = "[YOUR_REPLAY_ATTACK_DIRECTORY]" + +replay_licit = ReplayBioDatabase( + original_directory=replay_attack_directory, + original_extension=".mov", + protocol='grandtest-licit', +) + +replay_spoof = ReplayBioDatabase( + original_directory=replay_attack_directory, + original_extension=".mov", + protocol='grandtest-spoof', +) diff --git a/bob/bio/face/database/replay.py b/bob/bio/face/database/replay.py index 3a98d01959dcb949a3329b6bfc2a17da59b4e27f..c85baba961811f85f141e08cc808a10edd233ddb 100644 --- a/bob/bio/face/database/replay.py +++ b/bob/bio/face/database/replay.py @@ -11,12 +11,25 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class ReplayBioFile(FaceBioFile): + """docstring for ReplayBioFile""" + def __init__(self, f): + super(FaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f + + def load(self, directory=None, extension=None): + video = self._f.load(directory, extension) + # just return the 10th frame. + return video[10] class ReplayBioDatabase(BioDatabase): """ Implements verification API for querying Replay database. + This database only loads the 10th image from the video files """ __doc__ = __doc__ @@ -44,15 +57,13 @@ class ReplayBioDatabase(BioDatabase): self.__db.groups(), self.low_level_group_names, self.high_level_group_names) def annotations(self, file): - """Will return the bounding box annotation of all frames of the video.""" - # fn = 10 # 10th frame number - annots = file.bbx(directory=self.original_directory) + """Will return the bounding box annotation of 10th frame of the video.""" + fn = 10 # 10th frame number + annots = file._f.bbx(directory=self.original_directory) # bob uses the (y, x) format - annotations = dict() - for i in range(annots.shape[0]): - topleft = (annots[i][2], annots[i][1]) - bottomright = (annots[i][2] + annots[i][4], annots[i][1] + annots[i][3]) - annotations[str(i)] = {'topleft': topleft, 'bottomright': bottomright} + topleft = (annots[fn][2], annots[fn][1]) + bottomright = (annots[fn][2] + annots[fn][4], annots[fn][1] + annots[fn][3]) + annotations = {'topleft': topleft, 'bottomright': bottomright} return annotations def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): @@ -106,9 +117,9 @@ class ReplayBioDatabase(BioDatabase): retval = [] for f in objects: if f.is_real(): - retval.append(FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id)) + retval.append(ReplayBioFile(f)) else: - temp = FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) + temp = ReplayBioFile(f) temp.client_id = 'attack' retval.append(temp) return retval diff --git a/databases.txt b/databases.txt index 9823c6572d6e6a2a6d44de790afe9c48fbcdf069..492ce304c436924de765bb032180bd2e7ebb44f0 100644 --- a/databases.txt +++ b/databases.txt @@ -8,3 +8,4 @@ bob.db.mobio bob.db.multipie bob.db.scface bob.db.xm2vts +bob.db.replay diff --git a/develop.cfg b/develop.cfg index 3abbb042459076b193b8bd46173ec937cd1e5ad0..d70bdd47b3155f232912b0f1dcbced4269391624 100644 --- a/develop.cfg +++ b/develop.cfg @@ -15,6 +15,7 @@ eggs = bob.bio.face bob.db.multipie bob.db.scface bob.db.xm2vts + bob.db.replay gridtk extensions = bob.buildout @@ -51,6 +52,7 @@ develop = src/bob.extension src/bob.db.multipie src/bob.db.scface src/bob.db.xm2vts + src/bob.db.replay . ; options for bob.buildout @@ -90,6 +92,7 @@ bob.db.mobio = git https://gitlab.idiap.ch/bob/bob.db.mobio bob.db.multipie = git https://gitlab.idiap.ch/bob/bob.db.multipie bob.db.scface = git https://gitlab.idiap.ch/bob/bob.db.scface bob.db.xm2vts = git https://gitlab.idiap.ch/bob/bob.db.xm2vts +bob.db.replay = git https://gitlab.idiap.ch/bob/bob.db.replay [scripts] recipe = bob.buildout:scripts diff --git a/doc/implementation.rst b/doc/implementation.rst index 186b51c8907e072dd5ad22a284a466a6df4036f4..88490b215cf04a4e55c8d5e3c368aff8be8b378b 100644 --- a/doc/implementation.rst +++ b/doc/implementation.rst @@ -151,6 +151,10 @@ Here is the list of files and replacement strings for all databases that are reg - Images: ``[YOUR_MULTI-PIE_IMAGE_DIRECTORY]`` - Annotations: ``[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]`` +* Replay Attack ``'replay-img-licit'``, ``'replay-img-spoof'`` + + - Complete directory: ``[YOUR_REPLAY_ATTACK_DIRECTORY]`` + * SC face: ``'scface'`` - Images: ``[YOUR_SC_FACE_DIRECTORY]`` @@ -159,7 +163,6 @@ Here is the list of files and replacement strings for all databases that are reg - Images: ``[YOUR_XM2VTS_DIRECTORY]`` - You can use the ``./bin/databases.py`` script to list, which data directories are correctly set up. In order to view the annotations inside your database on top of the images, you can use the ``./bin/display_face_annotations.py`` script that is provided. diff --git a/setup.py b/setup.py index 9b3d0d742085387f65e024a751de79c97d7b5dba..992fe08e2f11eb033e5709c0860b87c881197969 100644 --- a/setup.py +++ b/setup.py @@ -122,6 +122,8 @@ setup( 'multipie-pose = bob.bio.face.config.database.multipie_pose:database', 'scface = bob.bio.face.config.database.scface:database', 'xm2vts = bob.bio.face.config.database.xm2vts:database', + 'replay-img-licit = bob.bio.face.config.database.replay:replay_licit', + 'replay-img-spoof = bob.bio.face.config.database.replay:replay_spoof', ], 'bob.bio.preprocessor': [