Commit 8adbdf78 authored by Manuel Günther's avatar Manuel Günther
Browse files

Switched annotations() function to accept File objects instead of file ids

parent e4f5bd06
......@@ -104,6 +104,7 @@ class File(Base, bob.db.verification.utils.File):
# For Python: A direct link to the client object that this file belongs to
real_client = relationship("Client", backref=backref("files", order_by=id))
annotation = relationship("Annotation", backref=backref("file"), uselist=False)
def __init__(self, client_id, path, claimed_id, shot_id, session_id):
# call base class constructor
......
......@@ -469,25 +469,20 @@ class Database(bob.db.verification.utils.SQLiteDatabase, bob.db.verification.uti
zgroups.append('dev')
return self.objects(protocol, 'probe', model_ids, zgroups, None, languages)
def annotations(self, file_id):
def annotations(self, file):
"""Returns the annotations for the image with the given file id.
Keyword Parameters:
file_id
The id of the File object to retrieve the annotations for.
file
The ``File`` object to retrieve the annotations for.
Returns: the eye annotations as a dictionary {'reye':(y,x), 'leye':(y,x)}.
"""
self.assert_validity()
query = self.query(Annotation).join(File).filter(File.id==file_id)
assert query.count() == 1
annotation = query.first()
# return the annotations as returned by the call function of the Annotation object
return annotation()
return file.annotation()
def protocol_names(self):
......
......@@ -92,7 +92,7 @@ def test_annotations():
# Tests that for all files the annotated eye positions exist and are in correct order
db = bob.db.banca.Database()
for f in db.objects():
annotations = db.annotations(f.id)
annotations = db.annotations(f)
assert annotations is not None
assert len(annotations) == 2
assert 'leye' in annotations
......
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