Python API

The VERA Database for finger verification

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 ids

Parameters
  • ids (list or tuple) – The ids of the object in the database table “file”. This object should be a python iterable (such as a tuple or list).

  • 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 File objects.

Return type

list

finger_name_from_model_id(model_id)[source]

Returns the unique finger name in the database given a model_id

fingers()[source]

Returns a list of all supported finger values

genders()[source]

Returns a list of all supported gender values

groups()[source]

Returns a list of all supported groups

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 to dev, eval or an iterator that yields both.

Returns

A list of string corresponding model identifiers with the specified filtering criteria

Return type

list

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

list

original_file_name(file)

This function returns the original file name for the given File object.

Parameters

filebob.db.base.File or a derivative The File objects for which the file name should be retrieved

Returns

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

list

protocol_names()[source]

Returns a list of all supported protocols

purposes()[source]

Returns a list of all supported purposes

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’s

Parameters
  • paths (list) – The filename stems (list of str) to query for. This object should be a python iterable (such as a tuple or list)

  • preserve_order (bool, optional) – If True (the default) the order of elements is preserved, but the execution time increases.

Returns

A list (that may be empty).

Return type

list

sessions()[source]

Returns a list of all supported session values

sides()[source]

Returns a list of all supported side values

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.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')
gender_display()[source]

Returns a representation of the client gender

id
metadata = MetaData(bind=None)
occupation
occupation_choices = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'x')
occupation_display()[source]

Returns a representation of the client occupation

skin_color
skin_color_choices = ('1', '2', '3', '4', '5', '6', 'x')
skin_color_display()[source]

Returns a representation of the client skin color

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')
name_display()[source]

Returns a representation of the finger name

side
side_choices = ('l', 'r')
side_display()[source]

Returns a representation of the finger side

property unique_name

Unique name for a given finger in the database

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 RoI

Return 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 where D’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
  • directory (str, optional) – An optional directory name that will be prefixed to the returned result.

  • extension (str, optional) – An optional extension that will be suffixed to the returned filename. The extension normally includes the leading . character as in .jpg or .hdf5.

Returns

Returns a string containing the newly generated file path.

Return type

str

metadata = MetaData(bind=None)
property 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.

session
session_choices = ('1', '2', '3')
snapshot
snapshot_choices = ('1', '2', '3', '4', '5')
class bob.db.fv3d.Protocol(name)

Bases: sqlalchemy.ext.declarative.api.Base

3D Fingervein protocols

id
metadata = MetaData(bind=None)
name
training_set
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
class bob.db.fv3d.Probe(group, protocol, file)

Bases: sqlalchemy.ext.declarative.api.Base

Unique probes in the database associated to a protocol and a single file

file
file_id
group
group_choices = ('dev', 'eval')
id
metadata = MetaData(bind=None)
protocol
protocol_id
bob.db.fv3d.get_config()[source]

Returns a string containing the configuration information.