Python API

The Replay-Mobile Database accessors for Bob

class bob.db.replaymobile.Attack(file, attack_support, attack_device, sample_type, sample_device)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Defines Spoofing Attacks (illicit attempts to authenticate)

attack_support_choices = ('fixed', 'hand')

Types of attack support

attack_device_choices = ('print', 'mattescreen')

Types of devices used for spoofing

sample_type_choices = ('video', 'photo')

Original sample type

type_device = ('mobile', 'tablet')

List of devices

id

Unique identifier for this attack

file_id

The file identifier this attack is linked to

protocols

A direct link to the protocols this file is linked to

file

A direct link to the File object bound to this attack

attack_support

The attack support

attack_device

The attack device

sample_type

The attack sample type

sample_device

The attack sample device

class bob.db.replaymobile.Client(id, set)[source]

Bases: sqlalchemy.ext.declarative.api.Base

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

set_choices = ('train', 'devel', 'test')

Possible groups to which clients may belong to

id

Key identifier for clients

set

Set to which this client belongs to

class bob.db.replaymobile.Database(original_directory=None, original_extension='.mov', annotation_directory=None, annotation_extension='.json', annotation_type='json')[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(support='fixed', 'hand', protocol='grandtest', groups='train', 'devel', 'test', cls='attack', 'real', light='lighton', 'lightoff', 'controlled', 'adverse', 'direct', 'lateral', 'diffuse', clients=None, device='mobile', 'tablet', sample_type='video', 'photo')[source]

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

Keyword parameters:

support

One of the valid support types as returned by attack_supports() 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.

protocol

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”.

groups

One of the protocolar subgroups of data as returned by groups() or a tuple with several of them. 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.

cls

Either “attack”, “real”, “enroll” or any combination of those (in a tuple). Defines the class of data to be retrieved. If you set this parameter to an empty string or the value None, we use reset it to the default, (“real”, “attack”).

light

One of the lighting conditions as returned by lights() or a combination of the two (in a tuple), which is also the default.

clients

If set, should be a single integer or a list of integers that define the client identifiers from which files should be retrieved. If ommited, set to None or an empty list, then data from all clients is retrieved.

device

One of the capture device as returned by device() or a combination of the two (in a tuple), which is also the default.

sample_type

type of attack regarding with media displayed on mattescreen attacks. ‘photo’ refers to a kind of attack that shows and static imagen on a screen. ‘video’ refers to a attack manufactured presenting a video on a mattescreeen

Returns: A list of File objects.

files(directory=None, extension=None, **object_query)[source]

Returns a set of filenames for the specific query by the user.

Deprecated since version 1.1.0: This function is deprecated, use Database.objects() instead.

Keyword Parameters:

directory

A directory name that will be prepended to the final filepath returned

extension

A filename extension that will be appended to the final filepath returned

object_query

All remaining arguments are passed to Database.objects() untouched. Please check the documentation for such method for more details.

Returns: A dictionary containing the resolved filenames considering all the filtering criteria. The keys of the dictionary are unique identities for each file in the replay attack database. Conserve these numbers if you wish to save processing results later on.

clients()[source]

Returns an iterable with all known clients

has_client_id(id)[source]

Returns True if we have a client with a certain integer identifier

protocols()[source]

Returns all protocol objects.

has_protocol(name)[source]

Tells if a certain protocol is available

protocol(name)[source]

Returns the protocol object in the database given a certain name. Raises an error if that does not exist.

groups()[source]

Returns the names of all registered groups

lights()[source]

Returns light variations available in the database

devices()[source]

Returns capture devices available in the database

attack_supports()[source]

Returns attack supports available in the database

attack_devices()[source]

Returns attack devices available in the database

attack_sampling_devices()[source]

Returns sampling devices available in the database

attack_sample_types()[source]

Returns attack sample types available in the database

paths(ids, prefix='', suffix='')[source]

Returns a full file paths considering particular file ids, a given directory and an extension

Keyword Parameters:

id

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

prefix

The bit of path to be prepended to the filename stem

suffix

The extension determines the suffix that will be appended to the filename stem.

Returns a list (that may be empty) of the fully constructed paths given the file ids.

reverse(paths)[source]

Reverses the lookup: from certain stems, returning file ids

Keyword Parameters:

paths

The filename stems I’ll query for. This object should be a python iterable (such as a tuple or list)

Returns a list (that may be empty).

save_one(id, obj, directory, extension)[source]

Saves a single object supporting the bob save() protocol.

Deprecated since version 1.1.0: This function is deprecated, use File.save() instead.

This method will call save() on the the given object using the correct database filename stem for the given id.

Keyword Parameters:

id

The id of the object in the database table “file”.

obj

The object that needs to be saved, respecting the bob save() protocol.

directory

This is the base directory to which you want to save the data. The directory is tested for existence and created if it is not there with os.makedirs()

extension

The extension determines the way each of the arrays will be saved.

save(data, directory, extension)[source]

This method takes a dictionary of blitz arrays or bob.database.Array’s and saves the data respecting the original arrangement as returned by files().

Deprecated since version 1.1.0: This function is deprecated, use File.save() instead.

Keyword Parameters:

data

A dictionary with two keys ‘real’ and ‘attack’, each containing a dictionary mapping file ids from the original database to an object that supports the bob “save()” protocol.

directory

This is the base directory to which you want to save the data. The directory is tested for existence and created if it is not there with os.makedirs()

extension

The extension determines the way each of the arrays will be saved.

class bob.db.replaymobile.File(client, path, light, device)[source]

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

Generic file container

light_choices = ('lighton', 'lightoff', 'controlled', 'adverse', 'direct', 'lateral', 'diffuse')

List of illumination conditions for data taking

device_choices = ('mobile', 'tablet')

List of devices

id

Key identifier for files

client_id

The client identifier to which this file is bound to

client

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

path

The (unique) path to this file inside the database

light

The illumination condition in which the data for this file was taken

device

The device

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.

facefile(directory=None)[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 (int)

  • Bounding box top-left X coordinate (int)

  • Bounding box top-left Y coordinate (int)

  • Bounding box width (int)

  • Bounding box height (int)

Note that not all the frames may contain detected faces.

is_real()[source]

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

is_mobile()[source]

True if the video file is originally recorded with mobile device, False otherwise

is_tablet()[source]

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

get_realaccess()[source]

Returns the real-access object equivalent to this file or raise

get_attack()[source]

Returns the attack object equivalent to this file or raise

load(directory=None, extension='.mov')[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.

property annotations
property frames
property number_of_frames
property frame_shape
class bob.db.replaymobile.Protocol(name)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Replay mobile protocol

id

Unique identifier for the protocol (integer)

name

Protocol name

class bob.db.replaymobile.RealAccess(file, purpose, device)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Defines Real-Accesses (licit attempts to authenticate)

purpose_choices = ('authenticate', 'enroll')

Types of purpose for this video

type_device = ('mobile', 'tablet')

List of devices

id

Unique identifier for this real-access object

file_id

The file identifier the current real-access is bound to

protocols

A direct link to the protocols this file is linked to

file

A direct link to the File object this real-access belongs to

purpose

The purpose of this video

device

The devices

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

Returns a string containing the configuration information.