Skip to content
Snippets Groups Projects
Commit 3ccccc84 authored by Ivana CHINGOVSKA's avatar Ivana CHINGOVSKA
Browse files

methods for querying the face location files

parent 2e5bdc4c
No related branches found
No related tags found
No related merge requests found
...@@ -155,6 +155,53 @@ class Database(object): ...@@ -155,6 +155,53 @@ class Database(object):
return retval return retval
def faces(self, filenames, directory=None):
"""Queries the files containing the face locations for the frames in the videos specified by the input parameter filenames
Keyword parameters:
filenames
The filenames of the videos. This object should be a python iterable (such as a tuple or list).
directory
A directory name that will be prepended to the final filepaths returned. The face locations files should be located in this directory
Returns:
A list of filenames with face locations. The face location files contain the following information, tab delimited:
* Frame number
* Bounding box top-left X coordinate
* Bounding box top-left Y coordinate
* Bounding box width
* Bounding box height
There is one row for each frame, and not all the frames contain detected faces
"""
if directory: return [os.path.join(directory, stem + '.faces') for stem in filenames]
return [stem + '.faces' for stem in filenames]
def faces_ids(self, ids, directory=None):
"""Queries the files containing the face locations for the frames in the videos specified by the input parameter ids
Keyword parameters:
ids
The ids of the objects in the database table "file". This object should be a python iterable (such as a tuple or list).
directory
A directory name that will be prepended to the final filepath returned. The face locations files should be located in this directory
Returns:
A list of filenames with face locations. For description on the face locations file format, see the documentation for faces()
"""
if not directory:
directory = ''
facespaths = self.paths(ids, prefix=directory, suffix='.faces')
return facespaths
def protocols(self): def protocols(self):
"""Returns the names of all registered protocols""" """Returns the names of all registered protocols"""
......
...@@ -127,3 +127,12 @@ class ReplayDatabaseTest(unittest.TestCase): ...@@ -127,3 +127,12 @@ class ReplayDatabaseTest(unittest.TestCase):
from bob.db.script.dbmanage import main from bob.db.script.dbmanage import main
self.assertEqual(main('replay checkfiles --self-test'.split()), 0) self.assertEqual(main('replay checkfiles --self-test'.split()), 0)
def test13_queryfacefile(self):
db = Database()
self.assertEqual(db.faces(('foo',), directory = 'dir')[0], 'dir/foo.faces',)
def test14_queryfacefile_key(self):
db = Database()
self.assertEqual(db.faces_ids(ids=(1,), directory='dir'), db.paths(ids=(1,), prefix='dir', suffix='.faces'))
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