diff --git a/bob/pad/face/database/__init__.py b/bob/pad/face/database/__init__.py index a2f0469af1a62518e0817611b1d075c292b23973..12814bda6532ef69b43c9f4ac5425c6001f2d8ba 100644 --- a/bob/pad/face/database/__init__.py +++ b/bob/pad/face/database/__init__.py @@ -1,3 +1,4 @@ +from .database import VideoPadFile from .replay import ReplayPadDatabase from .replay_mobile import ReplayMobilePadDatabase from .msu_mfsd import MsuMfsdPadDatabase @@ -8,8 +9,8 @@ from .mifs import MIFSPadDatabase # gets sphinx autodoc done right - don't remove it def __appropriate__(*args): """Says object was actually declared here, and not in the import module. - Fixing sphinx warnings of not being able to find classes, when path is shortened. - Parameters: + Fixing sphinx warnings of not being able to find classes, when path is + shortened. Parameters: *args: An iterable of objects to modify @@ -22,6 +23,7 @@ def __appropriate__(*args): __appropriate__( + VideoPadFile, ReplayPadDatabase, ReplayMobilePadDatabase, MsuMfsdPadDatabase, diff --git a/bob/pad/face/database/aggregated_db.py b/bob/pad/face/database/aggregated_db.py index c8072e246b76f888f5f632124729ac26a3b7b71b..75e91b3291f7b83d0074b0bfedecbf5954301659 100644 --- a/bob/pad/face/database/aggregated_db.py +++ b/bob/pad/face/database/aggregated_db.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- #============================================================================== -from bob.pad.base.database import PadFile # Used in ReplayPadFile class +from bob.pad.face.database import VideoPadFile # Used in ReplayPadFile class from bob.pad.base.database import PadDatabase @@ -21,7 +21,7 @@ import numpy as np #============================================================================== -class AggregatedDbPadFile(PadFile): +class AggregatedDbPadFile(VideoPadFile): """ A high level implementation of the File class for the Aggregated Database uniting 4 databases: REPLAY-ATTACK, REPLAY-MOBILE, MSU MFSD and Mobio. @@ -190,7 +190,7 @@ class AggregatedDbPadFile(PadFile): #========================================================================== def load(self, directory=None, extension='.mov'): """ - Overridden version of the load method defined in the ``PadFile``. + Overridden version of the load method defined in the ``VideoPadFile``. **Parameters:** diff --git a/bob/pad/face/database/database.py b/bob/pad/face/database/database.py new file mode 100644 index 0000000000000000000000000000000000000000..5d029071f585acdb20d7169e63ceda7f928ad946 --- /dev/null +++ b/bob/pad/face/database/database.py @@ -0,0 +1,23 @@ +from bob.pad.base.database import PadFile +from bob.bio.video.database import VideoBioFile + + +class VideoPadFile(VideoBioFile, PadFile): + """A simple base class that defines basic properties of File object for the + use in PAD experiments + """ + + def __init__(self, attack_type, client_id, path, file_id=None): + VideoBioFile.__init__( + self, + client_id=client_id, + path=path, + file_id=file_id, + ) + PadFile.__init__( + self, + attack_type=attack_type, + client_id=client_id, + path=path, + file_id=file_id, + ) diff --git a/bob/pad/face/database/mifs.py b/bob/pad/face/database/mifs.py index f15ee12b8e855917585b33f55da3acd64a782d1d..d66cc4af01c0f568ac88102914c3e6e906a38eff 100644 --- a/bob/pad/face/database/mifs.py +++ b/bob/pad/face/database/mifs.py @@ -10,14 +10,14 @@ from bob.bio.video import FrameSelector, FrameContainer import bob.io.base import numpy as np -from bob.pad.base.database import PadFile # Used in ReplayPadFile class +from bob.pad.face.database import VideoPadFile # Used in ReplayPadFile class from bob.pad.base.database import FileListPadDatabase #============================================================================== -class MIFSPadFile(PadFile): +class MIFSPadFile(VideoPadFile): """ A high level implementation of the File class for the MIFS database. """ @@ -29,7 +29,7 @@ class MIFSPadFile(PadFile): #========================================================================== def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')): """ - Overridden version of the load method defined in the ``PadFile``. + Overridden version of the load method defined in the ``VideoPadFile``. **Parameters:** diff --git a/bob/pad/face/database/msu_mfsd.py b/bob/pad/face/database/msu_mfsd.py index 5432ced1c37f3fb25afdf887ea1b2845dab4bf19..6783d888873c33b3573f4fac6d2955216632d87e 100644 --- a/bob/pad/face/database/msu_mfsd.py +++ b/bob/pad/face/database/msu_mfsd.py @@ -5,7 +5,7 @@ # Used in ReplayMobilePadFile class from bob.bio.video import FrameSelector, FrameContainer -from bob.pad.base.database import PadFile # Used in MsuMfsdPadFile class +from bob.pad.face.database import VideoPadFile # Used in MsuMfsdPadFile class from bob.pad.base.database import PadDatabase @@ -15,7 +15,7 @@ import numpy as np #============================================================================== -class MsuMfsdPadFile(PadFile): +class MsuMfsdPadFile(VideoPadFile): """ A high level implementation of the File class for the MSU MFSD database. """ @@ -53,7 +53,7 @@ class MsuMfsdPadFile(PadFile): #========================================================================== def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')): """ - Overridden version of the load method defined in the ``PadFile``. + Overridden version of the load method defined in the ``VideoPadFile``. **Parameters:** diff --git a/bob/pad/face/database/replay.py b/bob/pad/face/database/replay.py index 203136c0a41e3f3e0cbe0ca13145bd0789fb82be..8a9ff58faa62266434d5053bf76460fbd9cd1b5f 100644 --- a/bob/pad/face/database/replay.py +++ b/bob/pad/face/database/replay.py @@ -6,14 +6,14 @@ # Used in ReplayMobilePadFile class from bob.bio.video import FrameSelector, FrameContainer -from bob.pad.base.database import PadFile # Used in ReplayPadFile class +from bob.pad.face.database import VideoPadFile # Used in ReplayPadFile class from bob.pad.base.database import PadDatabase #============================================================================== -class ReplayPadFile(PadFile): +class ReplayPadFile(VideoPadFile): """ A high level implementation of the File class for the REPLAY-ATTACK database. """ @@ -51,7 +51,7 @@ class ReplayPadFile(PadFile): #========================================================================== def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')): """ - Overridden version of the load method defined in the ``PadFile``. + Overridden version of the load method defined in the ``VideoPadFile``. **Parameters:** diff --git a/bob/pad/face/database/replay_mobile.py b/bob/pad/face/database/replay_mobile.py index 843dee928dbb091e9f339f78b428e6417adad433..75c23b7a51c9dff08e61c1d4a61da5a5dcc9ce98 100644 --- a/bob/pad/face/database/replay_mobile.py +++ b/bob/pad/face/database/replay_mobile.py @@ -5,13 +5,13 @@ # Used in ReplayMobilePadFile class from bob.bio.video import FrameSelector, FrameContainer -from bob.pad.base.database import PadFile # Used in ReplayMobilePadFile class +from bob.pad.face.database import VideoPadFile # Used in ReplayMobilePadFile class from bob.pad.base.database import PadDatabase #============================================================================== -class ReplayMobilePadFile(PadFile): +class ReplayMobilePadFile(VideoPadFile): """ A high level implementation of the File class for the Replay-Mobile database. """ @@ -49,7 +49,7 @@ class ReplayMobilePadFile(PadFile): #========================================================================== def load(self, directory=None, extension='.mov', frame_selector=FrameSelector(selection_style='all')): """ - Overridden version of the load method defined in the ``PadFile``. + Overridden version of the load method defined in the ``VideoPadFile``. **Parameters:** diff --git a/bootstrap-buildout.py b/bootstrap-buildout.py deleted file mode 100644 index 39449d35f43be61ca67e2ac481fb4ed2dc1d45bd..0000000000000000000000000000000000000000 --- a/bootstrap-buildout.py +++ /dev/null @@ -1,221 +0,0 @@ -############################################################################## -# -# Copyright (c) 2006 Zope Foundation and Contributors. -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# -############################################################################## -"""Bootstrap a buildout-based project - -Simply run this script in a directory containing a buildout.cfg. -The script accepts buildout command-line options, so you can -use the -c option to specify an alternate configuration file. -""" - -import os -import shutil -import sys -import tempfile - -from optparse import OptionParser - -__version__ = '2015-07-01' -# See zc.buildout's changelog if this version is up to date. - -tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') - -usage = '''\ -[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] - -Bootstraps a buildout-based project. - -Simply run this script in a directory containing a buildout.cfg, using the -Python that you want bin/buildout to use. - -Note that by using --find-links to point to local resources, you can keep -this script from going over the network. -''' - -parser = OptionParser(usage=usage) -parser.add_option( - "--version", - action="store_true", - default=False, - help=("Return bootstrap.py version.")) -parser.add_option( - "-t", - "--accept-buildout-test-releases", - dest='accept_buildout_test_releases', - action="store_true", - default=False, - help=("Normally, if you do not specify a --version, the " - "bootstrap script and buildout gets the newest " - "*final* versions of zc.buildout and its recipes and " - "extensions for you. If you use this flag, " - "bootstrap and buildout will get the newest releases " - "even if they are alphas or betas.")) -parser.add_option( - "-c", - "--config-file", - help=("Specify the path to the buildout configuration " - "file to be used.")) -parser.add_option( - "-f", - "--find-links", - help=("Specify a URL to search for buildout releases")) -parser.add_option( - "--allow-site-packages", - action="store_true", - default=False, - help=("Let bootstrap.py use existing site packages")) -parser.add_option( - "--buildout-version", help="Use a specific zc.buildout version") -parser.add_option( - "--setuptools-version", help="Use a specific setuptools version") -parser.add_option( - "--setuptools-to-dir", - help=("Allow for re-use of existing directory of " - "setuptools versions")) - -options, args = parser.parse_args() -if options.version: - print("bootstrap.py version %s" % __version__) - sys.exit(0) - -###################################################################### -# load/install setuptools - -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen - -ez = {} -if os.path.exists('ez_setup.py'): - exec (open('ez_setup.py').read(), ez) -else: - exec (urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) - -if not options.allow_site_packages: - # ez_setup imports site, which adds site packages - # this will remove them from the path to ensure that incompatible versions - # of setuptools are not in the path - import site - # inside a virtualenv, there is no 'getsitepackages'. - # We can't remove these reliably - if hasattr(site, 'getsitepackages'): - for sitepackage_path in site.getsitepackages(): - # Strip all site-packages directories from sys.path that - # are not sys.prefix; this is because on Windows - # sys.prefix is a site-package directory. - if sitepackage_path != sys.prefix: - sys.path[:] = [ - x for x in sys.path if sitepackage_path not in x - ] - -setup_args = dict(to_dir=tmpeggs, download_delay=0) - -if options.setuptools_version is not None: - setup_args['version'] = options.setuptools_version -if options.setuptools_to_dir is not None: - setup_args['to_dir'] = options.setuptools_to_dir - -ez['use_setuptools'](**setup_args) -import setuptools -import pkg_resources - -# This does not (always?) update the default working set. We will -# do it. -for path in sys.path: - if path not in pkg_resources.working_set.entries: - pkg_resources.working_set.add_entry(path) - -###################################################################### -# Install buildout - -ws = pkg_resources.working_set - -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - -# Fix sys.path here as easy_install.pth added before PYTHONPATH -cmd = [ - sys.executable, '-c', - 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + - 'from setuptools.command.easy_install import main; main()', '-mZqNxd', - tmpeggs -] - -find_links = os.environ.get( - 'bootstrap-testing-find-links', options.find_links - or ('http://downloads.buildout.org/' - if options.accept_buildout_test_releases else None)) -if find_links: - cmd.extend(['-f', find_links]) - -requirement = 'zc.buildout' -version = options.buildout_version -if version is None and not options.accept_buildout_test_releases: - # Figure out the most recent final version of zc.buildout. - import setuptools.package_index - _final_parts = '*final-', '*final' - - def _final_version(parsed_version): - try: - return not parsed_version.is_prerelease - except AttributeError: - # Older setuptools - for part in parsed_version: - if (part[:1] == '*') and (part not in _final_parts): - return False - return True - - index = setuptools.package_index.PackageIndex( - search_path=[setuptools_path]) - if find_links: - index.add_find_links((find_links, )) - req = pkg_resources.Requirement.parse(requirement) - if index.obtain(req) is not None: - best = [] - bestv = None - for dist in index[req.project_name]: - distv = dist.parsed_version - if _final_version(distv): - if bestv is None or distv > bestv: - best = [dist] - bestv = distv - elif distv == bestv: - best.append(dist) - if best: - best.sort() - version = best[-1].version -if version: - requirement = '=='.join((requirement, version)) -cmd.append(requirement) - -import subprocess -if subprocess.call(cmd) != 0: - raise Exception("Failed to execute command:\n%s" % repr(cmd)[1:-1]) - -###################################################################### -# Import and run buildout - -ws.add_entry(tmpeggs) -ws.require(requirement) -import zc.buildout.buildout - -if not [a for a in args if '=' not in a]: - args.append('bootstrap') - -# if -c was provided, we push it back into args for buildout' main function -if options.config_file is not None: - args[0:0] = ['-c', options.config_file] - -zc.buildout.buildout.main(args) -shutil.rmtree(tmpeggs) diff --git a/doc/api.rst b/doc/api.rst index 74a89cd7966719c5036ee9a6c69aa9c3fd0de4a9..d1dde96805b2dc695f9ba42f30a4d856d008d75a 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -12,6 +12,11 @@ This section lists all the functionality available in this library allowing to r Database Interfaces ------------------------------ +Base classes +============ + +.. autoclass:: bob.pad.face.database.VideoPadFile + REPLAY-ATTACK Database ======================== diff --git a/doc/installation.rst b/doc/installation.rst index 52f756617690c0ce2db3b482dcb13f422ef63e72..d1ee42e19a17150ca53d961c20b3e49b9e4bae36 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -14,8 +14,8 @@ Package Installation -------------------- To install this package, first follow our `installation`_ instructions. Then, -using the Python interpreter provided by the distribution, bootstrap and -buildout this package: +using the buildout command provided by the distribution, bootstrap this package +using buildout: .. code-block:: sh