From 771f56f1c54730687deb571ffd5950dc16d93a5b Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Fri, 4 Nov 2016 15:18:46 +0100 Subject: [PATCH] Fix errors on databases --- bob/bio/vein/configurations/utfvp.py | 4 +-- bob/bio/vein/configurations/verafinger.py | 4 +-- bob/bio/vein/database/__init__.py | 9 ------- bob/bio/vein/database/utfvp.py | 33 ++++++++++++++++++----- bob/bio/vein/database/verafinger.py | 30 +++++++++++---------- doc/api.rst | 10 ++++++- 6 files changed, 55 insertions(+), 35 deletions(-) diff --git a/bob/bio/vein/configurations/utfvp.py b/bob/bio/vein/configurations/utfvp.py index 6b40cc5..0a58bed 100644 --- a/bob/bio/vein/configurations/utfvp.py +++ b/bob/bio/vein/configurations/utfvp.py @@ -17,12 +17,12 @@ You can download the raw data of the `UTFVP`_ database by following the link. .. include:: links.rst """ -from bob.bio.vein.database import UtfvpBioDatabase +from bob.bio.vein.database.utfvp import Database utfvp_directory = "[YOUR_UTFVP_DIRECTORY]" """Value of ``~/.bob_bio_databases.txt`` for this database""" -database = UtfvpBioDatabase( +database = Database( original_directory = utfvp_directory, original_extension = '.png', ) diff --git a/bob/bio/vein/configurations/verafinger.py b/bob/bio/vein/configurations/verafinger.py index 9b64210..21c3320 100644 --- a/bob/bio/vein/configurations/verafinger.py +++ b/bob/bio/vein/configurations/verafinger.py @@ -15,12 +15,12 @@ the link. """ -from bob.bio.vein.database import VerafingerBioDatabase +from bob.bio.vein.database.verafinger import Database verafinger_directory = "[YOUR_VERAFINGER_DIRECTORY]" """Value of ``~/.bob_bio_databases.txt`` for this database""" -database = VerafingerBioDatabase( +database = Database( original_directory = verafinger_directory, original_extension = '.png', ) diff --git a/bob/bio/vein/database/__init__.py b/bob/bio/vein/database/__init__.py index e4da7db..e69de29 100644 --- a/bob/bio/vein/database/__init__.py +++ b/bob/bio/vein/database/__init__.py @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# vim: set fileencoding=utf-8 : - -from .database import VeinBioFile -from .verafinger import VerafingerBioDatabase -from .utfvp import UtfvpBioDatabase - -# gets sphinx autodoc done right - don't remove it -__all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/vein/database/utfvp.py b/bob/bio/vein/database/utfvp.py index b8f09a0..ee92467 100644 --- a/bob/bio/vein/database/utfvp.py +++ b/bob/bio/vein/database/utfvp.py @@ -1,30 +1,49 @@ #!/usr/bin/env python # vim: set fileencoding=utf-8 : -# Tue 27 Sep 2016 16:49:05 CEST +# Fri 04 Nov 2016 14:46:53 CET -from .database import VeinBioFile -from bob.bio.base.database import BioDatabase +from bob.bio.base.database import BioFile, BioDatabase -class UtfvpBioDatabase(BioDatabase): +class File(BioFile): + """ + Implements extra properties of vein files for the UTFVP Fingervein database + + + Parameters: + + f (object): Low-level file (or sample) object that is kept inside + + """ + + def __init__(self, f): + + super(File, self).__init__(client_id=f.client_id, path=f.path, + file_id=f.id) + self.__f = f + + +class Database(BioDatabase): """ Implements verification API for querying UTFVP Fingervein database. """ def __init__(self, **kwargs): - super(UtfvpBioDatabase, self).__init__(name='utfvp', - **kwargs) + super(Database, self).__init__(name='utfvp', **kwargs) from bob.db.utfvp.query import Database as LowLevelDatabase self.__db = LowLevelDatabase() + def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): protocol = protocol if protocol is not None else self.protocol return self.__db.model_ids(groups=groups, protocol=protocol) + def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [VeinBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + + return [File(f) for f in retval] diff --git a/bob/bio/vein/database/verafinger.py b/bob/bio/vein/database/verafinger.py index d3f49fd..2968dec 100644 --- a/bob/bio/vein/database/verafinger.py +++ b/bob/bio/vein/database/verafinger.py @@ -4,12 +4,11 @@ from bob.bio.base.database import BioFile, BioDatabase -from bob.bio.base.database.file import BioFile -class VerafingerBioFile(BioFile): +class File(BioFile): """ - Implements extra properties of vein files + Implements extra properties of vein files for the Vera Fingervein database Parameters: @@ -20,52 +19,54 @@ class VerafingerBioFile(BioFile): def __init__(self, f): - super(VerafingerBioFile, self).__init__( - client_id=f.model_id, - path=f.path, - file_id=f.id, - ) - self.f = f + super(File, self).__init__(client_id=f.model_id, path=f.path, + file_id=f.id) + self.__f = f def roi(self): """Returns the binary mask from the ROI annotations available""" + from ..preprocessor.utils import poly_to_mask - points = self.f.roi() + # The size of images in this database is (250, 665) pixels (h, w) + return poly_to_mask((250, 665), self.__f.roi()) -class VerafingerBioDatabase(BioDatabase): +class Database(BioDatabase): """ Implements verification API for querying Vera Fingervein database. """ def __init__(self, **kwargs): - super(VerafingerBioDatabase, self).__init__(name='verafinger', - **kwargs) + super(Database, self).__init__(name='verafinger', **kwargs) from bob.db.verafinger.query import Database as LowLevelDatabase self.__db = LowLevelDatabase() self.low_level_group_names = ('train', 'dev') self.high_level_group_names = ('world', 'dev') + def groups(self): return self.convert_names_to_highlevel(self.__db.groups(), self.low_level_group_names, self.high_level_group_names) + def client_id_from_model_id(self, model_id, group='dev'): """Required as ``model_id != client_id`` on this database""" return self.__db.finger_name_from_model_id(model_id) + def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): groups = self.convert_names_to_lowlevel(groups, self.low_level_group_names, self.high_level_group_names) return self.__db.model_ids(groups=groups, protocol=protocol) + def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): @@ -73,4 +74,5 @@ class VerafingerBioDatabase(BioDatabase): self.low_level_group_names, self.high_level_group_names) retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [VeinBioFile(f) for f in retval] + + return [File(f) for f in retval] diff --git a/doc/api.rst b/doc/api.rst index 69648f7..80510bd 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -15,7 +15,15 @@ which can be used for vein experiments. Database Interfaces ------------------- -.. automodule:: bob.bio.vein.database +Vera Fingervein Database +======================== + +.. automodule:: bob.bio.vein.database.verafinger + +UTFVP Database +============== + +.. automodule:: bob.bio.vein.database.utfvp Pre-processors -- GitLab