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
-
client_fold1
¶
-
client_fold2
¶
-
client_fold3
¶
-
client_fold4
¶
-
client_fold5
¶
-
fold1_choices
= ('train', 'devel', 'test')¶
-
fold2_choices
= ('train', 'devel', 'test')¶
-
fold3_choices
= ('train', 'devel', 'test')¶
-
fold4_choices
= ('train', 'devel', 'test')¶
-
fold5_choices
= ('train', 'devel', 'test')¶
-
fold_choices
= ('fold1', 'fold2', 'fold3', 'fold4', 'fold5')¶
-
group_choices
= ('train', 'devel', 'test')¶
-
id
¶
-
-
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 ofFile
objects.
-
-
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
-
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 thenumpy.ndarray
corresponds for one frame. The five columns of thenumpy.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.
-
client
¶
-
client_id
¶
-
cls
¶
-
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.
-
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.
-
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’
-
get_quality
()[source]¶ Returns quality of the video recording as a string. Possible return-value: ‘laptop’, or ‘mobile’.
-
id
¶
-
instrument
¶
-
instrument_choices
= ('video_hd', 'video_mobile', 'print', '')¶
-
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.
-
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
¶
-
presentation_choices
= ('real', 'attack')¶
-
quality
¶
-
quality_choices
= ('laptop', 'mobile')¶
-
rotate
¶
-
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.
-