Skip to content
Snippets Groups Projects
Commit a030b502 authored by Amir Mohammadi's avatar Amir Mohammadi
Browse files

Fix replay and replay mobile

parent e8eefa38
No related branches found
No related tags found
1 merge request!15Resolve "Some database interfaces do not provide access to the annotations stored in the low-level databases", Add replay mobile bob.db.replaymobile
......@@ -4,13 +4,13 @@ from bob.bio.face.database import ReplayMobileBioDatabase
replay_mobile_directory = "[YOUR_REPLAY_MOBILE_DIRECTORY]"
replay_licit = ReplayMobileBioDatabase(
replaymobile_licit = ReplayMobileBioDatabase(
original_directory=replay_mobile_directory,
original_extension=".mov",
protocol='grandtest-licit',
)
replay_spoof = ReplayMobileBioDatabase(
replaymobile_spoof = ReplayMobileBioDatabase(
original_directory=replay_mobile_directory,
original_extension=".mov",
protocol='grandtest-spoof',
......
......@@ -15,7 +15,8 @@ from bob.bio.base.database import BioDatabase
class ReplayBioFile(FaceBioFile):
"""docstring for ReplayBioFile"""
"""BioFile implementation for the bob.db.replay database"""
def __init__(self, f):
super(FaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id)
self._f = f
......@@ -124,3 +125,15 @@ class ReplayBioDatabase(BioDatabase):
temp.client_id = 'attack'
retval.append(temp)
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):
def __init__(self, max_number_of_frames=None, **kwargs):
# 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
self._db = LowLevelDatabase(max_number_of_frames)
......@@ -42,11 +44,30 @@ class ReplayMobileBioDatabase(BioDatabase):
def groups(self):
return self._db.groups()
def annotations(self, file):
return self._db.annotations(file)
def annotations(self, myfile):
"""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):
return self._db.model_ids_with_protocol(groups, protocol, **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():
#@db_available('frgc')
#def test_frgc():
# def test_frgc():
# import xml.sax
# database = bob.bio.base.load_resource('frgc', 'database', preferred_package='bob.bio.face')
# try:
......@@ -108,7 +108,7 @@ def test_gbu():
try:
check_database(database, 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)
except IOError as e:
raise SkipTest(
......@@ -206,8 +206,30 @@ def test_xm2vts():
@db_available('replay')
def test_replay():
database = bob.bio.base.load_resource('replay', 'database', preferred_package='bob.bio.face')
def test_replay_licit():
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:
check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
......@@ -217,8 +239,8 @@ def test_replay():
@db_available('replaymobile')
def test_replaymobile():
database = bob.bio.base.load_resource('replaymobile', 'database', preferred_package='bob.bio.face')
def test_replaymobile_spoof():
database = bob.bio.base.load_resource('replaymobile-img-spoof', 'database', preferred_package='bob.bio.face')
try:
check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment