Python API¶
The VERA Database for finger verification
-
class
bob.db.fv3d.
Client
(id, gender, age, skin_color, occupation)¶ Bases:
sqlalchemy.ext.declarative.api.Base
Unique clients in the database, referred by a single integer
-
age
¶
-
gender
¶
-
gender_choices
= ('m', 'f')¶
-
id
¶
-
metadata
= MetaData(bind=None)¶
-
occupation
¶
-
occupation_choices
= ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'x')¶
-
skin_color
¶
-
skin_color_choices
= ('1', '2', '3', '4', '5', '6', 'x')¶
-
-
class
bob.db.fv3d.
Database
(original_directory=None, original_extension=None)¶ Bases:
bob.db.base.SQLiteDatabase
The dataset class opens and maintains a connection opened to the Database.
It provides many different ways to probe for the characteristics of the data and for the data itself inside the database.
-
all_files
(**kwargs)¶ Returns the list of all File objects that satisfy your query.
For possible keyword arguments, please check the implemention’s
objects()
method.
-
assert_validity
()¶ Raise a RuntimeError if the database back-end is not available.
-
check_parameter_for_validity
(parameter, parameter_description, valid_parameters, default_parameter=None)¶
-
check_parameters_for_validity
(parameters, parameter_description, valid_parameters, default_parameters=None)¶
-
convert_names_to_highlevel
(names, low_level_names, high_level_names)¶
-
convert_names_to_lowlevel
(names, low_level_names, high_level_names)¶
-
file_names
(files, directory, extension)¶
-
files
(ids, preserve_order=True)¶ Returns a list of
File
objects with the given file idsParameters: Returns: a list (that may be empty) of
File
objects.Return type:
-
finger_name_from_model_id
(model_id)[source]¶ Returns the unique finger name in the database given a
model_id
-
is_valid
()¶ Returns if a valid session has been opened for reading the database.
-
model_ids
(protocol=None, groups=None)[source]¶ Returns a set of models identifiers for a given protocol/group
Parameters: - protocol (
str
,list
, optional) – One or more of the supported protocols. If not set, returns data from all protocols - groups (
str
,list
, optional) – One or more of the supported groups. If not set, returns data from all groups. Notice this parameter should either not set or set todev
,eval
or an iterator that yields both.
Returns: A list of string corresponding model identifiers with the specified filtering criteria
Return type: - protocol (
-
objects
(protocol=None, groups=None, purposes=None, model_ids=None, genders=None, sides=None, fingers=None, sessions=None)[source]¶ Returns objects filtered by criteria
Parameters: - protocol (
str
,list
, optional) – One or more of the supported protocols. If not set, returns data from all protocols - groups (
str
,list
, optional) – One or more of the supported groups. If not set, returns data from all groups - purposes (
str
,list
, optional) – One or more of the supported purposes. If not set, returns data for all purposes - model_ids (
str
,list
, optional) – If set, limit output using the provided model identifiers - genders (
str
,list
, optional) – If set, limit output using the provided gender identifiers - sides (
str
,list
, optional) – If set, limit output using the provided side identifier - fingers (
str
,list
, optional) – If set, limit output using the provided finger identifiers - sessions (
str
,list
, optional) – If set, limit output using the provided session identifiers
Returns: A list of
File
objects corresponding to the filtering criteria.Return type: - protocol (
-
original_file_name
(file)¶ This function returns the original file name for the given File object.
Parameters: file – bob.db.base.File
or a derivative The File objects for which the file name should be retrievedReturns: The original file name for the given bob.db.base.File
object.Return type: str Raises: ValueError
– if the file is not found.
-
original_file_names
(files)¶ Returns the full path of the original data of the given File objects.
Parameters: files (list of bob.db.base.File
) – The list of file object to retrieve the original data file names for.Returns: The paths extracted for the files, in the same order. Return type: list of str
-
paths
(ids, prefix=None, suffix=None, preserve_order=True)¶ Returns a full file paths considering particular file ids
Parameters: - ids (
list
or :obj`tuple`) – The ids of the object in the database table “file”. This object should be a python iterable (such as a tuple or list). - prefix (
str
, optional) – The bit of path to be prepended to the filename stem - suffix (
str
, optional) – The extension determines the suffix that will be appended to the filename stem. - preserve_order (bool) – If True (the default) the order of elements is preserved, but the execution time increases.
Returns: A list (that may be empty) of the fully constructed paths given the file ids.
Return type: - ids (
-
query
(*args)¶ Creates a query to the database using the given arguments.
-
reverse
(paths, preserve_order=True)¶ Reverses the lookup from certain paths, returns a list of
bob.db.base.File
’sParameters: Returns: A list (that may be empty).
Return type:
-
sort
(files)¶
-
uniquify
(file_list)¶ Sorts the given list of File objects and removes duplicates from it.
Parameters: file_list ([ bob.db.base.File
]) – A list of File objects to be handled. Also other objects can be handled, as long as they are sortable.Returns: A sorted copy of the given file_list
with the duplicates removed.Return type: list
-
-
class
bob.db.fv3d.
File
(finger, session, attempt, snapshot, camera)¶ Bases:
sqlalchemy.ext.declarative.api.Base
,bob.db.base.File
Unique files in the database, referred by a string
Filenames inside the 3D Fingervein are like these:
<client>/<session>/<attempt>/<client>-<age>-<gender><skin><occ><side><finger><session><attempt><snap><cam>.png
The fields can have these values:
- client: integer > 0
- age = integer > 0
- gender = str, ‘m’ or ‘f’
- skin (color) = str, ‘1’..‘6’ or ‘x’
- occ(upation) = str, ‘0’..‘9’ or ‘x’
- side = str, ‘l’ or ‘r’
- finger = str, ‘t’, ‘i’, ‘m’, ‘r’, ‘l’
- session = int > 0
- attempt = int > 0
- snap = int > 0
- cam = str, one of ‘1’, ‘2’, ‘3’ or ‘S’ (‘stitched’)
-
attempt
¶
-
attempt_choices
= ('1', '2')¶
-
camera
¶
-
camera_choices
= ('1', '2', '3', 'S')¶
-
finger
¶
-
finger_id
¶
-
has_roi
()[source]¶ Tells if the RoI for a sample is available
Returns: True
if this sample has an RoIReturn type: bool
-
id
¶
-
load
(directory=None, extension='.png')[source]¶ Loads the image for this file entry
Parameters: directory (str) – The path to the root of the database installation. This is the path leading to directories named DDD
whereD
’s correspond to digits.Returns: - A 2D array of unsigned integers corresponding to the input
- image for this file in (y,x) notation (Bob-style).
Return type: numpy.ndarray
-
make_path
(directory=None, extension=None)[source]¶ Wraps the current path so that a complete path is formed
Parameters: Returns: Returns a string containing the newly generated file path.
Return type:
-
metadata
= MetaData(bind=None)¶
-
path
¶
-
roi
()[source]¶ Loads region-of-interest annotations for a particular image
The returned points (see return value below) correspond to a polygon in the 2D space delimiting the finger image. It is up to you to generate a mask out of these annotations.
Returns: - A 2D array of 8-bit unsigned integers corresponding to
- annotations for the given fingervein image. Points are loaded in (y,x) format so, the first column of the returned array correspond to the y-values while the second column to the x-values of each coordinate.
Return type: numpy.ndarray
-
save
(data, directory=None, extension='.hdf5', create_directories=True)[source]¶ Saves the input data at the specified location and using the given extension. Override it if you need to save differently.
Parameters: - data (object) – The data blob to be saved (normally a
numpy.ndarray
). - directory (
str
, optional) – If not empty or None, this directory is prefixed to the final file destination - extension (
str
, optional) – The extension of the filename - this will control the type of output and the codec for saving the input blob. - create_directories (
bool
, optional) – Whether to create the required directories to save the data.
- data (object) – The data blob to be saved (normally a
-
session
¶
-
session_choices
= ('1', '2', '3')¶
-
snapshot
¶
-
snapshot_choices
= ('1', '2', '3', '4', '5')¶
-
class
bob.db.fv3d.
Finger
(client, side, name)¶ Bases:
sqlalchemy.ext.declarative.api.Base
Unique fingers in the database, referred by a string
Fingers have the format
003_L
(i.e. <client>_<finger>)-
client
¶
-
client_id
¶
-
id
¶
-
metadata
= MetaData(bind=None)¶
-
name
¶
-
name_choices
= ('t', 'i', 'm', 'r', 'l')¶
-
side
¶
-
side_choices
= ('l', 'r')¶
-
unique_name
¶ Unique name for a given finger in the database
-
-
class
bob.db.fv3d.
Model
(name, group, finger, protocol)¶ Bases:
sqlalchemy.ext.declarative.api.Base
Unique models in the database, referred by a string and associate to a protocol
-
files
¶
-
finger
¶
-
finger_id
¶
-
group
¶
-
group_choices
= ('dev', 'eval')¶
-
id
¶
-
metadata
= MetaData(bind=None)¶
-
name
¶
-
protocol
¶
-
protocol_id
¶
-