Commit a030b502 authored by Amir Mohammadi's avatar Amir Mohammadi
Browse files

Fix replay and replay mobile

parent e8eefa38
...@@ -4,13 +4,13 @@ from bob.bio.face.database import ReplayMobileBioDatabase ...@@ -4,13 +4,13 @@ from bob.bio.face.database import ReplayMobileBioDatabase
replay_mobile_directory = "[YOUR_REPLAY_MOBILE_DIRECTORY]" replay_mobile_directory = "[YOUR_REPLAY_MOBILE_DIRECTORY]"
replay_licit = ReplayMobileBioDatabase( replaymobile_licit = ReplayMobileBioDatabase(
original_directory=replay_mobile_directory, original_directory=replay_mobile_directory,
original_extension=".mov", original_extension=".mov",
protocol='grandtest-licit', protocol='grandtest-licit',
) )
replay_spoof = ReplayMobileBioDatabase( replaymobile_spoof = ReplayMobileBioDatabase(
original_directory=replay_mobile_directory, original_directory=replay_mobile_directory,
original_extension=".mov", original_extension=".mov",
protocol='grandtest-spoof', protocol='grandtest-spoof',
......
...@@ -15,7 +15,8 @@ from bob.bio.base.database import BioDatabase ...@@ -15,7 +15,8 @@ from bob.bio.base.database import BioDatabase
class ReplayBioFile(FaceBioFile): class ReplayBioFile(FaceBioFile):
"""docstring for ReplayBioFile""" """BioFile implementation for the bob.db.replay database"""
def __init__(self, f): def __init__(self, f):
super(FaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) super(FaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id)
self._f = f self._f = f
...@@ -124,3 +125,15 @@ class ReplayBioDatabase(BioDatabase): ...@@ -124,3 +125,15 @@ class ReplayBioDatabase(BioDatabase):
temp.client_id = 'attack' temp.client_id = 'attack'
retval.append(temp) retval.append(temp)
return retval return retval
def arrange_by_client(self, files):
client_files = {}
for file in files:
if str(file.client_id) not in client_files:
client_files[str(file.client_id)] = []
client_files[str(file.client_id)].append(file)
files_by_clients = []
for client in sorted(client_files.keys()):
files_by_clients.append(client_files[client])
return files_by_clients
...@@ -31,7 +31,9 @@ class ReplayMobileBioDatabase(BioDatabase): ...@@ -31,7 +31,9 @@ class ReplayMobileBioDatabase(BioDatabase):
def __init__(self, max_number_of_frames=None, **kwargs): def __init__(self, max_number_of_frames=None, **kwargs):
# call base class constructors to open a session to the database # call base class constructors to open a session to the database
super(ReplayMobileBioDatabase, self).__init__(name='replay', **kwargs) super(ReplayMobileBioDatabase, self).__init__(
name='replay',
max_number_of_frames=max_number_of_frames, **kwargs)
from bob.db.replaymobile.verificationprotocol import Database as LowLevelDatabase from bob.db.replaymobile.verificationprotocol import Database as LowLevelDatabase
self._db = LowLevelDatabase(max_number_of_frames) self._db = LowLevelDatabase(max_number_of_frames)
...@@ -42,11 +44,30 @@ class ReplayMobileBioDatabase(BioDatabase): ...@@ -42,11 +44,30 @@ class ReplayMobileBioDatabase(BioDatabase):
def groups(self): def groups(self):
return self._db.groups() return self._db.groups()
def annotations(self, file): def annotations(self, myfile):
return self._db.annotations(file) """Will return the bounding box annotation of nth frame of the video."""
fn = myfile._f.framen # 10th frame number
annots = myfile._f._f.bbx(directory=self.original_directory)
# bob uses the (y, x) format
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): def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs):
return self._db.model_ids_with_protocol(groups, protocol, **kwargs) return self._db.model_ids_with_protocol(groups, protocol, **kwargs)
def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs):
return self._db.objects(groups, protocol, purposes, model_ids, **kwargs) return [ReplayMobileBioFile(f) for f in self._db.objects(groups, protocol, purposes, model_ids, **kwargs)]
def arrange_by_client(self, files):
client_files = {}
for file in files:
if str(file.client_id) not in client_files:
client_files[str(file.client_id)] = []
client_files[str(file.client_id)].append(file)
files_by_clients = []
for client in sorted(client_files.keys()):
files_by_clients.append(client_files[client])
return files_by_clients
...@@ -80,7 +80,7 @@ def test_caspeal(): ...@@ -80,7 +80,7 @@ def test_caspeal():
#@db_available('frgc') #@db_available('frgc')
#def test_frgc(): # def test_frgc():
# import xml.sax # import xml.sax
# database = bob.bio.base.load_resource('frgc', 'database', preferred_package='bob.bio.face') # database = bob.bio.base.load_resource('frgc', 'database', preferred_package='bob.bio.face')
# try: # try:
...@@ -108,7 +108,7 @@ def test_gbu(): ...@@ -108,7 +108,7 @@ def test_gbu():
try: try:
check_database(database, models_depend=True) check_database(database, models_depend=True)
check_database(database, protocol='Bad', models_depend=True) check_database(database, protocol='Bad', models_depend=True)
check_database(database, protocol = 'Ugly', models_depend=True) check_database(database, protocol='Ugly', models_depend=True)
_check_annotations(database) _check_annotations(database)
except IOError as e: except IOError as e:
raise SkipTest( raise SkipTest(
...@@ -206,8 +206,30 @@ def test_xm2vts(): ...@@ -206,8 +206,30 @@ def test_xm2vts():
@db_available('replay') @db_available('replay')
def test_replay(): def test_replay_licit():
database = bob.bio.base.load_resource('replay', 'database', preferred_package='bob.bio.face') database = bob.bio.base.load_resource('replay-img-licit', 'database', preferred_package='bob.bio.face')
try:
check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
except IOError as e:
raise SkipTest(
"The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('replay')
def test_replay_spoof():
database = bob.bio.base.load_resource('replay-img-spoof', 'database', preferred_package='bob.bio.face')
try:
check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
except IOError as e:
raise SkipTest(
"The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('replaymobile')
def test_replaymobile_licit():
database = bob.bio.base.load_resource('replaymobile-img-licit', 'database', preferred_package='bob.bio.face')
try: try:
check_database(database, groups=('dev', 'eval')) check_database(database, groups=('dev', 'eval'))
_check_annotations(database) _check_annotations(database)
...@@ -217,8 +239,8 @@ def test_replay(): ...@@ -217,8 +239,8 @@ def test_replay():
@db_available('replaymobile') @db_available('replaymobile')
def test_replaymobile(): def test_replaymobile_spoof():
database = bob.bio.base.load_resource('replaymobile', 'database', preferred_package='bob.bio.face') database = bob.bio.base.load_resource('replaymobile-img-spoof', 'database', preferred_package='bob.bio.face')
try: try:
check_database(database, groups=('dev', 'eval')) check_database(database, groups=('dev', 'eval'))
_check_annotations(database) _check_annotations(database)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment