Source code for bob.bio.face.database.multipie

#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# Sat 20 Aug 15:43:10 CEST 2016

"""
  Multipie database implementation of bob.bio.base.database.Database interface.
  It is an extension of an SQL-based database interface, which directly talks to Multipie database, for
  verification experiments (good to use in bob.bio.base framework).
"""

from .database import FaceBioFile
from bob.bio.base.database import ZTBioDatabase


class MultipieBioFile(FaceBioFile):

    def __init__(self, f):
        super(MultipieBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id)
        self._f = f


class MultipieBioDatabase(ZTBioDatabase):
    """
    Multipie database implementation of bob.bio.base.database.Database interface.
    It is an extension of an SQL-based database interface, which directly talks to Multipie database, for
    verification experiments (good to use in bob.bio.base framework).
    """

    def __init__(
            self,
            original_directory=None,
            original_extension='.png',
            annotation_directory=None,
            annotation_extension='.pos',
            **kwargs
    ):
        # call base class constructors to open a session to the database
        super(MultipieBioDatabase, self).__init__(
            name='multipie',
            original_directory=original_directory,
            original_extension=original_extension,
            annotation_directory=annotation_directory,
            annotation_extension=annotation_extension,
            **kwargs)

        from bob.db.multipie.query import Database as LowLevelDatabase
        self._db = LowLevelDatabase(original_directory,
                                    original_extension,
                                    annotation_directory,
                                    annotation_extension)

[docs] def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): return self._db.model_ids(groups=groups, protocol=protocol)
[docs] def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) return [MultipieBioFile(f) for f in retval]
[docs] def tmodel_ids_with_protocol(self, protocol=None, groups=None, **kwargs): return self._db.tmodel_ids(protocol=protocol, groups=groups, **kwargs)
[docs] def tobjects(self, groups=None, protocol=None, model_ids=None, **kwargs): retval = self._db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) return [MultipieBioFile(f) for f in retval]
[docs] def zobjects(self, groups=None, protocol=None, **kwargs): retval = self._db.zobjects(groups=groups, protocol=protocol, **kwargs) return [MultipieBioFile(f) for f in retval]
[docs] def annotations(self, myfile): return self._db.annotations(myfile._f)