Python API

Basic database interface

The msu_mfsd_mod face-spoof Database accessors for Bob

bob.db.msu_mfsd_mod.get_config()[source]

Returns a string containing the configuration information.

class bob.db.msu_mfsd_mod.Client(client_num, client_fold1, client_fold2, client_fold3, client_fold4, client_fold5)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Database clients, marked by an integer identifier and the set they belong to

group_choices = ('train', 'devel', 'test')
fold_choices = ('fold1', 'fold2', 'fold3', 'fold4', 'fold5')
fold1_choices = ('train', 'devel', 'test')

Possible groups to which clients may belong to

fold2_choices = ('train', 'devel', 'test')
fold3_choices = ('train', 'devel', 'test')
fold4_choices = ('train', 'devel', 'test')
fold5_choices = ('train', 'devel', 'test')
id

Key identifier for clients

client_fold1

Client’s group in this fold.

client_fold2

Client’s group in this fold.

client_fold3

Client’s group in this fold.

client_fold4

Client’s group in this fold.

client_fold5

Client’s group in this fold.

class bob.db.msu_mfsd_mod.Database(original_directory=None, original_extension=None)[source]

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.

objects(quality=('laptop', 'mobile'), instrument=('video_hd', 'video_mobile', 'print', ''), fold='fold1', group=('train', 'devel', 'test'), cls=('real', 'attack'), ids=[])[source]

Returns a list of unique File objects for the specific query by the user.

Keyword parameters:

quality

One of the valid support types as returned by file_qualities() or all, as a tuple. If you set this parameter to an empty string or the value None, we use reset it to the default, which is to get all.

instrument

Specify the attack-instruments of interest (‘video_hd’, ‘video_mobile’, ‘print’). Several instruments may be specified together, as a tuple. If the parameter is not specified, or is specified as an empty string or as the value None, then the parameter value is considered to be the set of all instruments.

group

One of the subgroups of data (‘train’, ‘devel’, ‘test’) as returned by groups() or any combination of them in a tuple. If set to an empty string or the value None, it is reset to the default which is to get all subgroups.

cls

Either “attack”, or “real”, or both (in a tuple). Defines the presentation of the data to be retrieved. If parameter is set to an empty string or the value None, the value is reset to the default: (“real”, “attack”).

fold:

One of 5 folds supported (‘fold1’, ‘fold2’, ‘fold3’, ‘fold4’, ‘fold5’). If not specified, ‘fold1’ is the default value used. If the parameter is set to empty string, of the value None, its value is reset to the default. If desired, several folds may be specified together, as a tuple.

ids:

The id of the client whose videos need to be retrieved. Should be an integer number belonging this list: [‘01’, ‘02’, ‘03’, ‘05’, ‘06’, ‘07’, ‘08’, ‘09’, ‘11’, ‘12’, ‘13’, ‘14’, ‘21’, ‘22’, ‘23’, ‘24’, ‘26’, ‘28’, ‘29’, ‘30’, ‘32’, ‘33’, ‘34’, ‘35’, ‘36’, ‘37’, ‘39’, ‘42’, ‘48’, ‘49’, ‘50’, ‘51’, ‘53]

# protocol –NOT USED FOR NOW. THIS COMMENT WILL BE REMOVED. # The protocol for the attack. One of the ones returned by protocols(). If # you set this parameter to an empty string or the value None, we use reset # it to the default, “grandtest”.

Returns: A list of File objects.

groups()[source]

Returns the names of all registered groups

folds()[source]

Returns list of supported folds in the database

qualities()[source]

Returns the available video-qualities (of sampling devices) in the database

attack_instruments()[source]

Returns attack devices available in the database

presentation_classes()[source]

Returns the kinds of presentation (real or attack) available in the database

class bob.db.msu_mfsd_mod.File(fId, client, path, presentation, quality, atype, rotation=False)[source]

Bases: sqlalchemy.ext.declarative.api.Base, bob.db.base.File

Generic file container

quality_choices = ('laptop', 'mobile')

List of options for quality of device used for data-capture

instrument_choices = ('video_hd', 'video_mobile', 'print', '')

List of options for attack-instruments (‘video_hd’==ipad, ‘video_mobile’==iphone_video, ‘print’==printed_photo

presentation_choices = ('real', 'attack')

List of possible presentations

id

Key identifier for files

path

The (unique) path to this file inside the database

client

A direct link to the client object that this file belongs to

client_id

The client identifier to which this file is bound to

cls

real or attack

Type

presentation-class

quality

Quality of device used to acquire video

instrument

Attack-type

rotate

To rotate or not to rotate…

make_path(directory=None, extension=None)[source]

Wraps the current path so that a complete path is formed

Keyword parameters:

directory

An optional directory name that will be prefixed to the returned result.

extension

An optional extension that will be suffixed to the returned filename. The extension normally includes the leading . character as in .jpg or .hdf5.

Returns a string containing the newly generated file path.

get_quality()[source]

Returns quality of the video recording as a string. Possible return-value: ‘laptop’, or ‘mobile’.

get_instrument()[source]

Returns the attack-instrument (formerly, type) associated with the file-object. Return: String, one of: ‘video_hd’, ‘video_mobile’, ‘print’, or None Returns None only when the presentation is ‘real’

videofile(directory=None)[source]

Returns the path to the database video file for this object Keyword parameters: directory: An optional directory name that will be prefixed to the returned result.

Returns a string containing the video file path.

get_file(pc)[source]

Returns the full file path given the path components pc

facefile(directory='')[source]

Returns the path to the companion face bounding-box file

Keyword parameters: directory: An optional directory name that will be prefixed to the returned result.

Returns a string containing the face file path.

bbx(directory=None)[source]

Reads the file containing the face locations for the frames in the current video

Keyword parameters: directory: A directory name that will be prepended to the final filepaths where the face bounding boxes are located, if not on the current directory.

Returns

A numpy.ndarray containing information about the located faces in the videos. Each row of the numpy.ndarray corresponds for one frame. The five columns of the numpy.ndarray are (all integers): * Frame number (float) * Bounding box top-left X coordinate (float) * Bounding box top-left Y coordinate (float) * Bounding box width (float) * Bounding box height (float) * Left eye X coordinate (float) * Left eye Y coordinate (float) * Right eye X coordinate (float) * Right eye Y coordinate (float)

Note that not all the frames may contain detected faces.

get_client_id()[source]

The ID of the client. Value from 1 to 50. Clients in the train and devel set may have IDs from 1 to 20; clients in the test set have IDs from 21 to 50.

is_real()[source]

Returns True if this file belongs to a real access, False otherwise

is_rotated()[source]

True if the video file is originally recorded rotated by 180 degrees, False otherwise

load(directory=None, extension=None)[source]

Loads the data at the specified location and using the given extension.

Keyword parameters: data: The data blob to be saved (normally a numpy.ndarray).

directory: [optional] If not empty or None, this directory is prefixed to the final file destination

extension: [optional] The extension of the filename - this will control the type of output and the codec for saving the input blob.

save(data, directory=None, extension='.hdf5')[source]

Saves the input data at the specified location and using the given extension.

Keyword parameters: data: The data blob to be saved (normally a numpy.ndarray). directory: If specified (not empty and not None), this directory is prefixed to the final file destination extension: The filename-extension - this determines the type of output and the codec for saving the input blob.

bob.db.msu_mfsd_mod.VerificationDatabase

alias of bob.db.msu_mfsd_mod.verificationprotocol.Database

bob.db.msu_mfsd_mod.VerificationFile

alias of bob.db.msu_mfsd_mod.verificationprotocol.File