Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.db.biosecure
Commits
b6a83418
Commit
b6a83418
authored
Nov 03, 2014
by
Manuel Günther
Browse files
Switched annotations() function to accept File objects instead of file ids
parent
f1249e98
Changes
3
Hide whitespace changes
Inline
Side-by-side
bob/db/biosecure/models.py
View file @
b6a83418
...
...
@@ -75,6 +75,7 @@ class File(Base, bob.db.verification.utils.File):
# for Python
client
=
relationship
(
"Client"
,
backref
=
backref
(
"files"
,
order_by
=
id
))
annotation
=
relationship
(
"Annotation"
,
backref
=
backref
(
"file"
),
uselist
=
False
)
def
__init__
(
self
,
client_id
,
path
,
session_id
,
camera
,
shot_id
):
# call base class constructor
...
...
bob/db/biosecure/query.py
View file @
b6a83418
...
...
@@ -204,25 +204,20 @@ class Database(bob.db.verification.utils.SQLiteDatabase):
return
list
(
set
(
retval
))
# To remove duplicates
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/biosecure/test.py
View file @
b6a83418
...
...
@@ -63,7 +63,7 @@ def test_annotations():
# Tests that for all files the annotated eye positions exist and are in correct order
db
=
bob
.
db
.
biosecure
.
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