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

[replaymobile] Fix annotation check

parent a040e17c
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
Pipeline #
......@@ -46,11 +46,12 @@ class ReplayMobileBioDatabase(BioDatabase):
def annotations(self, myfile):
"""Will return the bounding box annotation of nth frame of the video."""
fn = myfile._f.framen # 10th frame number
fn = myfile._f.framen
annots = myfile._f._f.bbx(directory=self.original_directory)
# convert width and height to bottomright coordinates
# 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])
topleft = (annots[fn][1], annots[fn][0])
bottomright = (annots[fn][1] + annots[fn][3], annots[fn][0] + annots[fn][2])
annotations = {'topleft': topleft, 'bottomright': bottomright}
return annotations
......
......@@ -25,13 +25,17 @@ from bob.bio.base.test.utils import db_available
from bob.bio.base.test.test_database_implementations import check_database, check_database_zt
def _check_annotations(database):
def _check_annotations(database, topleft=False):
for file in database.all_files():
annotations = database.annotations(file)
if annotations is not None:
assert isinstance(annotations, dict)
assert 'reye' in annotations
assert 'leye' in annotations
if topleft:
assert 'topleft' in annotations
assert 'bottomright' in annotations
else:
assert 'reye' in annotations
assert 'leye' in annotations
@db_available('arface')
......@@ -210,7 +214,7 @@ 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)
_check_annotations(database, topleft=True)
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)
......@@ -221,7 +225,7 @@ 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)
_check_annotations(database, topleft=True)
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)
......@@ -232,7 +236,7 @@ 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)
_check_annotations(database, topleft=True)
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)
......@@ -243,7 +247,7 @@ 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)
_check_annotations(database, topleft=True)
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment