diff --git a/bob/bio/vein/configurations/utfvp.py b/bob/bio/vein/configurations/utfvp.py index 6b40cc56f670662c451852e13f734ce83a0bc817..0a58bed17d1e8d61b806bad8f71f55cbb7b3e5fa 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 9b642101ecfc00ea4879a2e6e1c2541c3652f2fc..21c332018459fa8314c0b5237984eddc091ff35f 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 e4da7db23a776c7d7ee84297a86009e46fd04959..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 b8f09a049d3cfea5a8216b27d4ea6ccc4cb75aa6..ee924674f8564396c439980cd87104ce70bb3e1f 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 d3f49fddea72a2ca2189574d913e76fe7cf28175..2968dec168f177117e824badd62728e109951b62 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 69648f71996570fd8df3468082a962348322d57a..80510bde729cb75e3bd8771f9cb6fc88a6d8b10d 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