Skip to content
Snippets Groups Projects
Commit de2a8b76 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[advanced][databases][livdet2013] Add new version following V2 implementation

parent fc98ae01
No related branches found
No related tags found
1 merge request!28Add protocoltemplates
{
"description": "The LivDet 2013 Fingerprint Liveness Database",
"root_folder": "/idiap/resource/database/LivDet/LivDet2013",
"protocols": [
{
"name": "Biometrika",
"template": "simple_fingerprint_antispoofing/1",
"views": {
"train": {
"view": "All",
"parameters": {
"protocol": "Biometrika",
"group": "train"
}
},
"test": {
"view": "All",
"parameters": {
"protocol": "Biometrika",
"group": "test"
}
}
}
},
{
"name": "Italdata",
"template": "simple_fingerprint_antispoofing/1",
"views": {
"train": {
"view": "All",
"parameters": {
"protocol": "Italdata",
"group": "train"
}
},
"test": {
"view": "All",
"parameters": {
"protocol": "Italdata",
"group": "test"
}
}
}
},
{
"name": "CrossMatch",
"template": "simple_fingerprint_antispoofing/1",
"views": {
"train": {
"view": "All",
"parameters": {
"protocol": "CrossMatch",
"group": "train"
}
},
"test": {
"view": "All",
"parameters": {
"protocol": "CrossMatch",
"group": "test"
}
}
}
},
{
"name": "Swipe",
"template": "simple_fingerprint_antispoofing/1",
"views": {
"train": {
"view": "All",
"parameters": {
"protocol": "Swipe",
"group": "train"
}
},
"test": {
"view": "All",
"parameters": {
"protocol": "Swipe",
"group": "test"
}
}
}
},
{
"name": "Full",
"template": "simple_fingerprint_antispoofing/1",
"views": {
"train": {
"view": "All",
"parameters": {
"group": "train"
}
},
"test": {
"view": "All",
"parameters": {
"group": "test"
}
}
}
}
],
"schema_version": 2
}
\ No newline at end of file
###############################################################################
# #
# Copyright (c) 2018 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.examples module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
import os
import numpy as np
from collections import namedtuple
from beat.backend.python.database import View
import bob.io.base
import bob.io.image
from bob.db.livdet2013 import Database
#----------------------------------------------------------
class All(View):
"""Outputs:
- image: "{{ system_user.username }}/array_3d_uint8/1"
- spoof: "{{ system_user.username }}/boolean/1"
Several "image" are associated with a given "spoof".
--------------- --------------- --------------- ---------------
| image | | image | | image | | image |
--------------- --------------- --------------- ---------------
------------------------------- ------------------------------
| spoof | | spoof |
------------------------------- ------------------------------
"""
def index(self, root_folder, parameters):
Entry = namedtuple('Entry', ['spoof', 'image'])
# Open the database and load the objects to provide via the outputs
db = Database()
objs = sorted(db.objects(protocols=parameters.get('protocol'),
groups=parameters['group'],
classes=parameters.get('class')),
key=lambda x: x.is_live())
return [ Entry(x.is_live(), x.make_path(root_folder)) for x in objs ]
def get(self, output, index):
obj = self.objs[index]
if output == 'spoof':
return {
'value': obj.spoof
}
elif output == 'image':
return {
'value': bob.io.base.load(obj.image)
}
#----------------------------------------------------------
def setup_tests():
# Install a mock load function for the images
def mock_load(root_folder):
return np.ndarray((3, 10, 20), dtype=np.uint8)
bob.io.base.load = mock_load
#----------------------------------------------------------
# Test the behavior of the views (on fake data)
if __name__ == '__main__':
setup_tests()
view = All()
view.objs = view.index(
root_folder='',
parameters=dict(
protocol='Biometrika',
group='train'
)
)
view.get('spoof', 0)
view.get('image', 0)
The LivDet 2013 Fingerprint Liveness Database
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment