Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.db.banca
Commits
8adbdf78
Commit
8adbdf78
authored
Nov 03, 2014
by
Manuel Günther
Browse files
Switched annotations() function to accept File objects instead of file ids
parent
e4f5bd06
Changes
3
Hide whitespace changes
Inline
Side-by-side
bob/db/banca/models.py
View file @
8adbdf78
...
...
@@ -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
...
...
bob/db/banca/query.py
View file @
8adbdf78
...
...
@@ -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
):
...
...
bob/db/banca/test.py
View file @
8adbdf78
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment