Commit 1e894452 authored by André Anjos's avatar André Anjos

Merge branch 'putvein_db_hldi' into 'master'

Putvein Database Closes #9 See merge request !36
parents 9dc69b71 e7c5942b
Pipeline #13222 passed with stages
in 14 minutes 42 seconds
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Mon 26 Sep 2016 17:21:42 CEST
"""`PUT Vein`_ is a database for biometric palm and wrist vein recognition.
PUT Vein pattern database consists of 2400 images presenting human vein patterns.
Half of images (1200 images) contain a palm vein pattern and the remaining images contain a wrist vein pattern (another 1200 images).
Data was acquired from both hands of 50 students. Thus, it has 100 different patterns for palm and wrist region.
Pictures ware taken in 3 series, 4 pictures each, with at least one week interval between each series.
Images in database have 1280x960 resolution and are stored as 24-bit bitmap. Database consist of 2 main splits:
hand and wrist, allowing to investigate both modalities.
The reference citation is [KK10]_.
You can download the raw data of the `PUT Vein`_ database by following
the link.
"""
from ..database.putvein import PutveinBioDatabase
_putvein_directory = "[YOUR_PUTVEIN_IMAGE_DIRECTORY]"
"""Value of ``~/.bob_bio_databases.txt`` for this database"""
database = PutveinBioDatabase(
original_directory = _putvein_directory,
original_extension = '.bmp',
)
"""The :py:class:`bob.bio.base.database.BioDatabase` derivative with PUT Vein
database settings
.. warning::
This class only provides a programmatic interface to load data in an orderly
manner, respecting usage protocols. It does **not** contain the raw
datafiles. You should procure those yourself.
Notice that ``original_directory`` is set to ``[YOUR_PUTVEIN_IMAGE_DIRECTORY]``.
You must make sure to create ``${HOME}/.bob_bio_databases.txt`` setting this
value to the place where you actually installed the PUT Vein Database, as
explained in the section :ref:`bob.bio.vein.baselines`.
"""
protocol = 'wrist-LR_1'
"""The default protocol to use for tests
You may modify this at runtime by specifying the option ``--protocol`` on the
command-line of ``verify.py`` or using the keyword ``protocol`` on a
configuration file that is loaded **after** this configuration resource.
"""
# vim: set fileencoding=utf-8 :
"""
PUTVEIN database implementation of bob.bio.db.BioDatabase interface.
It is an extension of low level database interface, which directly talks to
PUTVEIN database for verification experiments (good to use in bob.bio.base
framework).
"""
from bob.bio.base.database import BioFile, BioDatabase
import bob.ip.color
import numpy as np
class File(BioFile):
"""
Implements extra properties of vein files for the PUTVEIN 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
def load(self, directory=None, extension='.bmp'):
"""
The image returned by the ``bob.db.putvein`` is RGB (with shape
(3, 768, 1024)). This method converts image to a greyscale (shape
(768, 1024)) and then rotates image by 270 deg so that images can be
used with ``bob.bio.vein`` algorythms designed for the
``bob.db.biowave_v1`` database.
Output images dimentions - (1024, 768).
"""
color_image = self.f.load(directory=directory,
extension=extension)
grayscale_image = bob.ip.color.rgb_to_gray(color_image)
grayscale_image = np.rot90(grayscale_image, k=3)
return grayscale_image
class PutveinBioDatabase(BioDatabase):
"""
Implements verification API for querying PUTVEIN database.
This class allows to use the following protocols:
palm-L_1
palm-LR_1
palm-R_1
palm-RL_1
palm-R_BEAT_1
palm-L_4
palm-LR_4
palm-R_4
palm-RL_4
palm-R_BEAT_4
wrist-L_1
wrist-LR_1
wrist-R_1
wrist-RL_1
wrist-R_BEAT_1
wrist-L_4
wrist-LR_4
wrist-R_4
wrist-RL_4
wrist-R_BEAT_4
"""
def __init__(self, **kwargs):
super(PutveinBioDatabase, self).__init__(name='putvein', **kwargs)
from bob.db.putvein.query import Database as LowLevelDatabase
self.__db = LowLevelDatabase()
self.low_level_group_names = ('train', 'dev', 'eval')
self.high_level_group_names = ('world', 'dev', 'eval')
def groups(self):
return self.convert_names_to_highlevel(self.__db.groups(),
self.low_level_group_names, self.high_level_group_names)
def __protocol_split__(self, prot_name):
"""
Overrides the "high level" database names (see the list abowe) to the
low level ``protocols`` (currently there are 8 low level protocols:
L_1;
LR_1;
R_1;
RL_1;
R_BEAT_1;
L_4;
LR_4;
R_4;
RL_4;
R_BEAT_4;
And the kinds - wrist or palm.
The low level protocols are derived from the original 4:
L;
R;
LR;
RL;
please read the ``bob.db.putvein`` documentation.
"""
allowed_prot_names = ["palm-L_1",
"palm-LR_1",
"palm-R_1",
"palm-RL_1",
"palm-R_BEAT_1",
"palm-L_4",
"palm-LR_4",
"palm-R_4",
"palm-RL_4",
"palm-R_BEAT_4",
"wrist-L_1",
"wrist-LR_1",
"wrist-R_1",
"wrist-RL_1",
"wrist-R_BEAT_1",
"wrist-L_4",
"wrist-LR_4",
"wrist-R_4",
"wrist-RL_4",
"wrist-R_BEAT_4"]
if prot_name not in allowed_prot_names:
raise IOError("Protocol name {} not allowed. Allowed names - {}".\
format(prot_name, allowed_prot_names))
kind, prot = prot_name.split("-")
return kind, prot
def client_id_from_model_id(self, model_id, group='dev'):
"""Required as ``model_id != client_id`` on this database"""
return self.__db.client_id_from_model_id(model_id)
def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs):
"""model_ids_with_protocol(groups = None, protocol = None, **kwargs) -> ids
Returns a list of model ids for the given groups and given protocol.
**Parameters:**
groups : one or more of ``('world', 'dev', 'eval')``
The groups to get the model ids for.
protocol: a protocol name
**Returns:**
ids : [int]
The list of (unique) model ids for the given groups.
"""
kind, prot = self.__protocol_split__(protocol)
groups = self.convert_names_to_lowlevel(groups, self.low_level_group_names, self.high_level_group_names)
return self.__db.model_ids(protocol=prot,
groups=groups,
kinds=kind)
def objects(self, protocol=None, groups=None, purposes=None, model_ids=None, kinds=None, **kwargs):
kind, prot = self.__protocol_split__(protocol)
groups = self.convert_names_to_lowlevel(groups, self.low_level_group_names, self.high_level_group_names)
retval = self.__db.objects(protocol=prot,
groups=groups,
purposes=purposes,
model_ids=model_ids,
kinds=kind)
return [File(f) for f in retval]
def annotations(self, file):
return None
......@@ -42,3 +42,14 @@ def test_fv3d():
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('putvein')
def test_putvein():
module = bob.bio.base.load_resource('putvein', 'config',
preferred_package='bob.bio.vein')
try:
check_database(module.database, protocol='wrist-LR_1', groups=('dev',))
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
\ No newline at end of file
......@@ -15,7 +15,7 @@
.. _vera fingervein: https://www.idiap.ch/dataset/vera-fingervein
.. _3d fingervein: https://www.idiap.ch/dataset/3d-fingervein
.. _utfvp: http://scs.ewi.utwente.nl/downloads/show,Finger%20Vein/
.. _put: http://biometrics.put.poznan.pl/vein-dataset/
.. _put vein: http://biometrics.put.poznan.pl/vein-dataset/
.. _installation: https://www.idiap.ch/software/bob/install
.. _dependencies: https://gitlab.idiap.ch/bob/bob/wikis/Dependencies
.. _mailing list: https://www.idiap.ch/software/bob/discuss
......
......@@ -24,3 +24,6 @@
.. [TVM14] *Pedro Tome, Matthias Vanoni and Sébastien Marcel*, **On the Vulnerability of Finger Vein Recognition to Spoofing**, in: IEEE International Conference of the Biometrics Special Interest Group (BIOSIG), Darmstadt, Germay, pages 1 - 10, IEEE, 2014
.. [TV13] *B. Ton and R. Veldhuis*, **A high quality finger vascular pattern dataset collected using a custom designed capturing device**, in: IAPR International Conference on Biometrics (ICB), 2013.
.. [KK10] *R. Kabacinski and *M. Kowalski, **Human Vein Pattern Segmentation from Low Quality Images - A Comparison of Methods**, in: Image Processing and Communications Challenges 2, pp. 105-112, 2010.
......@@ -52,6 +52,16 @@ UTFVP Database
.. automodule:: bob.bio.vein.configurations.fv3d
:members:
.. _bob.bio.vein.resources.database.putvein:
PUT Vein Databas
======================
.. automodule:: bob.bio.vein.configurations.putvein
:members:
.. _bob.bio.vein.resources.recognition:
Recognition Systems
......
......@@ -36,6 +36,7 @@ setup(
'verafinger = bob.bio.vein.configurations.verafinger',
'utfvp = bob.bio.vein.configurations.utfvp',
'fv3d = bob.bio.vein.configurations.fv3d',
'putvein = bob.bio.vein.configurations.putvein',
# baselines
'mc = bob.bio.vein.configurations.maximum_curvature',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment