diff --git a/bob/bio/vein/database/utfvp.py b/bob/bio/vein/database/utfvp.py index ee924674f8564396c439980cd87104ce70bb3e1f..e9099b89d70d4f709283104aaecf9f1f18848cec 100644 --- a/bob/bio/vein/database/utfvp.py +++ b/bob/bio/vein/database/utfvp.py @@ -19,7 +19,7 @@ class File(BioFile): def __init__(self, f): super(File, self).__init__(client_id=f.client_id, path=f.path, - file_id=f.id) + file_id=f.id) self.__f = f @@ -32,18 +32,19 @@ class Database(BioDatabase): super(Database, self).__init__(name='utfvp', **kwargs) from bob.db.utfvp.query import Database as LowLevelDatabase - self.__db = 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) - + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, - model_ids=None, **kwargs): + model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, - purposes=purposes, model_ids=model_ids, **kwargs) + retval = self._db.objects(groups=groups, protocol=protocol, + purposes=purposes, model_ids=model_ids, **kwargs) return [File(f) for f in retval] + + def annotations(self, file): + return None diff --git a/bob/bio/vein/database/verafinger.py b/bob/bio/vein/database/verafinger.py index 69d1b025881c06f9e97b8a7fdd7570c58f2612fa..d8cea83446963e276c4f321abe28b1775359d518 100644 --- a/bob/bio/vein/database/verafinger.py +++ b/bob/bio/vein/database/verafinger.py @@ -7,81 +7,77 @@ from bob.bio.base.database import BioFile, BioDatabase class File(BioFile): - """ - Implements extra properties of vein files for the Vera Fingervein database + """ + Implements extra properties of vein files for the Vera Fingervein database - Parameters: + Parameters: - f (object): Low-level file (or sample) object that is kept inside + f (object): Low-level file (or sample) object that is kept inside - """ + """ - def __init__(self, f): + def __init__(self, f): - super(File, self).__init__(client_id=f.unique_finger_name, path=f.path, - file_id=f.id) - self.__f = f + super(File, self).__init__(client_id=f.unique_finger_name, path=f.path, + file_id=f.id) + self.__f = f + def mask(self): + """Returns the binary mask from the ROI annotations available""" - def mask(self): - """Returns the binary mask from the ROI annotations available""" + from ..preprocessor.utils import poly_to_mask - from ..preprocessor.utils import poly_to_mask + # The size of images in this database is (250, 665) pixels (h, w) + return poly_to_mask((250, 665), 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()) + def load(self, *args, **kwargs): + """(Overrides base method) Loads both image and mask""" + image = super(File, self).load(*args, **kwargs) - def load(self, *args, **kwargs): - """(Overrides base method) Loads both image and mask""" - - image = super(File, self).load(*args, **kwargs) - - return image, self.mask() - + return image, self.mask() class Database(BioDatabase): - """ - Implements verification API for querying Vera Fingervein database. - """ - - def __init__(self, **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') + """ + Implements verification API for querying Vera Fingervein database. + """ + def __init__(self, **kwargs): - def groups(self): + super(Database, self).__init__(name='verafinger', **kwargs) + from bob.db.verafinger.query import Database as LowLevelDatabase + self._db = LowLevelDatabase() - return self.convert_names_to_highlevel(self.__db.groups(), - self.low_level_group_names, self.high_level_group_names) + self.low_level_group_names = ('train', 'dev') + self.high_level_group_names = ('world', 'dev') + def groups(self): - def client_id_from_model_id(self, model_id, group='dev'): - """Required as ``model_id != client_id`` on this database""" + return self.convert_names_to_highlevel(self._db.groups(), + self.low_level_group_names, self.high_level_group_names) - return self.__db.finger_name_from_model_id(model_id) + 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): + 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) + 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): - def objects(self, groups=None, protocol=None, purposes=None, - model_ids=None, **kwargs): + groups = self.convert_names_to_lowlevel(groups, + 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) - groups = self.convert_names_to_lowlevel(groups, - 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 [File(f) for f in retval] - return [File(f) for f in retval] + def annotations(self, file): + return None