diff --git a/advanced/databases/livdet2013/5.json b/advanced/databases/livdet2013/5.json new file mode 100644 index 0000000000000000000000000000000000000000..92d712a2fd79686c315e865a79d4daffeea50f99 --- /dev/null +++ b/advanced/databases/livdet2013/5.json @@ -0,0 +1,105 @@ +{ + "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 diff --git a/advanced/databases/livdet2013/5.py b/advanced/databases/livdet2013/5.py new file mode 100644 index 0000000000000000000000000000000000000000..a0bc58c960856e54c59ddb57f43817256cc92958 --- /dev/null +++ b/advanced/databases/livdet2013/5.py @@ -0,0 +1,109 @@ +############################################################################### +# # +# 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) diff --git a/advanced/databases/livdet2013/5.rst b/advanced/databases/livdet2013/5.rst new file mode 100644 index 0000000000000000000000000000000000000000..0cf3ad568f8f06b3d091630b28abca710a38d29c --- /dev/null +++ b/advanced/databases/livdet2013/5.rst @@ -0,0 +1 @@ +The LivDet 2013 Fingerprint Liveness Database \ No newline at end of file