Python API

The Replay-Mobile Database accessors for Bob

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

Returns a string containing the configuration information.

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_device
attack_device_choices = ('print', 'mattescreen')
attack_support
attack_support_choices = ('fixed', 'hand')
file
file_id
id
protocols
sample_device
sample_type
sample_type_choices = ('video', 'photo')
type_device = ('mobile', 'tablet')
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

id
set
set_choices = ('train', 'devel', 'test')
class bob.db.replaymobile.Database(original_directory=None, original_extension=None)[source]

Bases: bob.db.base.Database

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.

assert_validity()[source]

Raise a RuntimeError if the database backend is not available

attack_devices()[source]

Returns attack devices available in the database

attack_sample_types()[source]

Returns attack sample types available in the database

attack_sampling_devices()[source]

Returns sampling devices available in the database

attack_supports()[source]

Returns attack supports available in the database

clients()[source]

Returns an iterable with all known clients

connect()[source]

Tries connecting or re-connecting to the database

devices()[source]

Returns capture devices available in the database

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.

groups()[source]

Returns the names of all registered groups

has_client_id(id)[source]

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

has_protocol(name)[source]

Tells if a certain protocol is available

is_valid()[source]

Returns if a valid session has been opened for reading the database

lights()[source]

Returns light variations available in 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.

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.

protocol(name)[source]

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

protocols()[source]

Returns all protocol objects.

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(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.
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.
class bob.db.replaymobile.File(client, path, light, device)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Generic file container

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.

client
client_id
device
device_choices = ('mobile', 'tablet')
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.

get_attack()[source]

Returns the attack object equivalent to this file or raise

get_realaccess()[source]

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

id
is_mobile()[source]

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

is_real()[source]

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

is_tablet()[source]

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

light
light_choices = ('lighton', 'lightoff', 'controlled', 'adverse', 'direct', 'lateral', 'diffuse')
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.
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.

path
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
[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.
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.

class bob.db.replaymobile.Protocol(name)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Replay mobile protocol

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

Bases: sqlalchemy.ext.declarative.api.Base

Defines Real-Accesses (licit attempts to authenticate)

device
file
file_id
id
protocols
purpose
purpose_choices = ('authenticate', 'enroll')
type_device = ('mobile', 'tablet')