Exemplo n.º 1
0
class RealAccess(Base):
  """Defines Real-Accesses (licit attempts to authenticate)"""

  __tablename__ = 'realaccess'

  purpose_choices = ('authenticate', 'enroll')
  """Types of purpose for this video"""

  id = Column(Integer, primary_key=True)
  """Unique identifier for this real-access object"""

  file_id = Column(Integer, ForeignKey('file.id'))  # for SQL
  """The file identifier the current real-access is bound to"""

  purpose = Column(Enum(*purpose_choices))
  """The purpose of this video"""

  take = Column(Integer)
  """Take number"""

  # for Python
  file = relationship(File, backref=backref('realaccess', order_by=id))
  """A direct link to the :py:class:`.File` object this real-access belongs to"""

  protocols = relationship("Protocol", secondary=realaccesses_protocols,
                           backref='realaccesses')
  """A direct link to the protocols this file is linked to"""

  def __init__(self, file, purpose, take):
    self.file = file
    self.purpose = purpose
    self.take = take

  def __repr__(self):
    return "RealAccess('%s')" % (self.file.path)
Exemplo n.º 2
0
class ProtocolPurpose(Base):
    """SCface protocol purposes"""

    __tablename__ = 'protocolPurpose'

    # Unique identifier for this protocol purpose object
    id = Column(Integer, primary_key=True)
    # Id of the protocol associated with this protocol purpose object
    protocol_id = Column(Integer, ForeignKey('protocol.id'))  # for SQL
    # Group associated with this protocol purpose object
    group_choices = ('world', 'dev', 'eval')
    sgroup = Column(Enum(*group_choices))
    # Purpose associated with this protocol purpose object
    purpose_choices = ('train', 'enroll', 'probe')
    purpose = Column(Enum(*purpose_choices))

    # For Python: A direct link to the Protocol object that this ProtocolPurpose belongs to
    protocol = relationship("Protocol",
                            backref=backref("purposes", order_by=id))
    # For Python: A direct link to the File objects associated with this ProtcolPurpose
    files = relationship("File",
                         secondary=protocolPurpose_file_association,
                         backref=backref("protocol_purposes", order_by=id))

    def __init__(self, protocol_id, sgroup, purpose):
        self.protocol_id = protocol_id
        self.sgroup = sgroup
        self.purpose = purpose

    def __repr__(self):
        return "ProtocolPurpose('%s', '%s', '%s')" % (
            self.protocol.name, self.sgroup, self.purpose)
Exemplo n.º 3
0
class Subset(Base):
    """VERA protocol subsets"""

    __tablename__ = 'subset'

    id = Column(Integer, primary_key=True)

    protocol_id = Column(Integer, ForeignKey('protocol.id'))
    protocol = relationship("Protocol", backref=backref("subsets"))

    group_choices = ('train', 'dev', 'eval')
    group = Column(Enum(*group_choices))

    purpose_choices = ('train', 'enroll', 'probe')
    purpose = Column(Enum(*purpose_choices))

    files = relationship("File",
                         secondary=subset_file_association,
                         backref=backref("subsets"))

    avoid_self_probe = Column(Boolean, default=False)

    def __init__(self, protocol, group, purpose):
        self.protocol = protocol
        self.group = group
        self.purpose = purpose

    def __repr__(self):
        return "Subset(%s, %s, %s)" % (self.protocol, self.group, self.purpose)
Exemplo n.º 4
0
class File(Base, bob.db.base.File):
    """Generic file container"""

    __tablename__ = 'file'

    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # Session identifier
    session_id = Column(Integer)
    # Camera identifier
    camera_choices = ('ca0', 'caf', 'wc')
    camera = Column(Enum(*camera_choices))
    # Shot identifier
    shot_id = Column(Integer)

    # for Python
    client = relationship("Client", backref=backref("files", order_by=id))
    annotation = relationship("Annotation",
                              backref=backref("file"),
                              uselist=False)

    def __init__(self, client_id, path, session_id, camera, shot_id):
        # call base class constructor
        bob.db.base.File.__init__(self, path=path)
        self.client_id = client_id

        self.session_id = session_id
        self.camera = camera
        self.shot_id = shot_id
Exemplo n.º 5
0
class Pair(Base):
    """Information of the pairs (as given in the pairs.txt files) of the LFW database."""
    __tablename__ = 'pair'

    id = Column(Integer, primary_key=True)
    # train and test for view1, the folds for view2
    protocol = Column(
        Enum('train', 'test', 'fold1', 'fold2', 'fold3', 'fold4', 'fold5',
             'fold6', 'fold7', 'fold8', 'fold9', 'fold10', 'view2'))
    enroll_file_id = Column(String(100), ForeignKey('file.id'))
    probe_file_id = Column(String(100), ForeignKey('file.id'))
    enroll_file = relationship("File",
                               backref=backref("enroll_files", order_by=id),
                               primaryjoin="Pair.enroll_file_id==File.id")
    probe_file = relationship("File",
                              backref=backref("probe_files", order_by=id),
                              primaryjoin="Pair.probe_file_id==File.id")
    is_match = Column(Boolean)

    def __init__(self, protocol, enroll_file_id, probe_file_id, is_match):
        self.protocol = protocol
        self.enroll_file_id = enroll_file_id
        self.probe_file_id = probe_file_id
        self.is_match = is_match

    def __repr__(self):
        return "<Pair('%s', '%s', '%s', '%d')>" % (
            self.protocol, self.enroll_file_id, self.probe_file_id,
            1 if self.is_match else 0)
Exemplo n.º 6
0
class File(Base, bob.db.base.File):
    """Information about the files of the LFW database."""
    __tablename__ = 'file'

    # Unique key identifier for the file; here we use strings
    id = Column(Integer, primary_key=True)
    # Unique name identifier for the file
    name = Column(String(100), unique=True)
    # Identifier for the client
    client_id = Column(String(100), ForeignKey('client.id'))
    # Unique path to this file inside the database
    path = Column(String(100))
    # Identifier for the current image number of the client
    shot_id = Column(Integer)

    # a back-reference from file to client
    client = relationship("Client", backref=backref("files", order_by=id))
    # many-to-one relationship between annotations and files
    annotations = relationship("Annotation",
                               backref=backref("file",
                                               order_by=id,
                                               uselist=False))

    def __init__(self, client_id, shot_id):
        # call base class constructor
        fn = filename(client_id, shot_id)
        bob.db.base.File.__init__(self, path=os.path.join(client_id, fn))
        self.client_id = client_id

        self.shot_id = shot_id
        self.name = fn
Exemplo n.º 7
0
class ProtocolFiles(Base):
    """Database clients, marked by an integer identifier and the set they belong
    to"""

    __tablename__ = 'protocolfiles'

    id = Column(Integer, primary_key=True)
    """Key identifier for Protocols"""

    protocol_id = Column(String, ForeignKey('protocol.id'))  # for SQL
    """The protocol identifier that the file is linked to"""

    # for Python
    protocol = relationship(Protocol,
                            backref=backref('protocolfiles', order_by=id))
    """A direct link to the protocol object that refers to the given file"""

    file_id = Column(String, ForeignKey('file.id'))  # for SQL
    """The file id that the protocol references"""

    # for Python
    file = relationship(File, backref=backref('protocolfiles', order_by=id))
    """A direct link to the file object that the protocol references"""
    def __init__(self, protocol, file):
        self.protocol = protocol
        self.file = file

    def __repr__(self):
        return "ProtocolFiles('%s, %s')" % (self.protocol_id, self.file_id)
Exemplo n.º 8
0
class File(Base, bob.db.base.File):
    """The file of the GBU database consists of an integral id
  as well as the 'presentation' as read from the file lists.
  Each file has one annotation and one associated client."""
    __tablename__ = 'file'

    id = Column(Integer, primary_key=True)
    client_id = Column(
        Integer,
        ForeignKey('client.id'))  # The client id; should start with nd1
    path = Column(String(100),
                  unique=True)  # The relative path where to find the file

    client = relationship("Client", backref=backref("files", order_by=id))
    # one-to-one relationship between annotations and files
    annotation = relationship("Annotation",
                              backref=backref("file",
                                              order_by=id,
                                              uselist=False),
                              uselist=False)

    def __init__(self, presentation, signature, path):
        # call base class function
        bob.db.base.File.__init__(self, path=path)
        self.client_id = client_id_from_signature(signature)
        # signature and presentation are not stored, but needed for creation
        self.signature = signature
        self.presentation = presentation
Exemplo n.º 9
0
class File(Base, bob.db.verification.utils.File):
    """Generic file container"""

    __tablename__ = 'file'

    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # Session identifier
    session_id = Column(Integer)
    # Whether it is a darkened image (left 'l' or right 'r') or not 'n'
    darkened = Column(Enum('n', 'l', 'r'))  # none, left, right
    # Shot identifier
    shot_id = Column(Integer)

    # For Python: A direct link to the client object that this file belongs to
    client = relationship("Client", backref=backref("files", order_by=id))
    annotation = relationship("Annotation",
                              backref=backref("file",
                                              order_by=id,
                                              uselist=False),
                              uselist=False)

    def __init__(self, client_id, path, session_id, darkened, shot_id):
        # call base class constructor
        bob.db.verification.utils.File.__init__(self,
                                                client_id=client_id,
                                                path=path)

        self.session_id = session_id
        self.darkened = darkened
        self.shot_id = shot_id
Exemplo n.º 10
0
class File(Base, bob.db.base.File):
    """Generic file container"""

    __tablename__ = 'file'

    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # Camera identifier
    camera = Column(String(8))
    # Distance identifier
    distance = Column(Integer)

    # For Python: A direct link to the client object that this file belongs to
    client = relationship("Client", backref=backref("files", order_by=id))
    annotation = relationship("Annotation",
                              backref=backref("file",
                                              order_by=id,
                                              uselist=False),
                              uselist=False)

    def __init__(self, client_id, path, camera, distance):
        # call base class constructor
        bob.db.base.File.__init__(self, path=path)
        self.client_id = client_id
        # set the remaining information of the file
        self.camera = camera
        self.distance = distance
        self.client_id = client_id
Exemplo n.º 11
0
class TModel(Base):
  """T-Norm models"""

  __tablename__ = 'tmodel'

  # Unique identifier for this TModel object
  id = Column(Integer, primary_key=True)
  # Model id (only unique for a given protocol)
  mid = Column(String(9))
  client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
  protocol_id = Column(Integer, ForeignKey('protocol.id'))  # for SQL

  # for Python: A direct link to the client
  client = relationship("Client", backref=backref("tmodels", order_by=id))
  # for Python: A direct link to the protocol
  protocol = relationship("Protocol", backref=backref("tmodels", order_by=id))
  # for Python: A direct link to the files
  files = relationship("File", secondary=tmodel_file_association, backref=backref("tmodels", order_by=id))

  def __init__(self, mid, client_id, protocol_id):
    self.mid = mid
    self.client_id = client_id
    self.protocol_id = protocol_id

  def __repr__(self):
    return "TModel('%s', '%s')" % (self.mid, self.protocol_id)
Exemplo n.º 12
0
class File(Base, bob.db.base.File):
    """Generic file container"""

    __tablename__ = 'file'

    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # Identifier of the claimed client associated with this file
    claimed_id = Column(
        Integer
    )  # not always the id of an existing client model -> not a ForeignKey
    # Identifier of the shot
    shot_id = Column(Integer)
    # Identifier of the session
    session_id = Column(Integer)

    # For Python: A direct link to the client object that this file belongs to
    real_client = relationship("Client", backref=backref("files", order_by=id))
    annotation = relationship("Annotation",
                              backref=backref("file"),
                              uselist=False)

    def __init__(self, client_id, path, claimed_id, shot_id, session_id):
        # call base class constructor
        bob.db.base.File.__init__(self, path=path)
        self.client_id = client_id

        self.claimed_id = claimed_id
        self.shot_id = shot_id
        self.session_id = session_id
Exemplo n.º 13
0
class File(Base, bob.db.base.File):
    """Information about the files of the AR face database. Each file includes

  * the session (first, second)
  * the expression (neutral, smile, anger, scream)
  * the illumination (front, left, right, all)
  * the occlusion (none, sunglasses, scarf)
  * the client id
  """
    __tablename__ = 'file'

    # We define the possible values for the member variables as STATIC class
    # variables
    session_choices = ('first', 'second')
    purpose_choices = ('enroll', 'probe')
    expression_choices = ('neutral', 'smile', 'anger', 'scream')
    illumination_choices = ('front', 'left', 'right', 'all')
    occlusion_choices = ('none', 'sunglasses', 'scarf')

    id = Column(String(100), primary_key=True)
    path = Column(String(100), unique=True)
    client_id = Column(String(100), ForeignKey('client.id'))
    session = Column(Enum(*session_choices))
    purpose = Column(Enum(*purpose_choices))
    expression = Column(Enum(*expression_choices))
    illumination = Column(Enum(*illumination_choices))
    occlusion = Column(Enum(*occlusion_choices))

    # a back-reference from the client class to a list of files
    client = relationship("Client", backref=backref("files", order_by=id))
    annotation = relationship("Annotation",
                              backref=backref("file"),
                              uselist=False)

    def __init__(self, image_name):
        # call base class constructor
        bob.db.base.File.__init__(self, path=image_name, file_id=image_name)
        self.client_id = image_name[:5]

        # get shot id
        shot_id = int(os.path.splitext(image_name)[0][6:])
        # automatically fill member variables according to shot id
        self.session = self.session_choices[int((shot_id - 1) / 13)]
        shot_id = (shot_id - 1) % 13 + 1

        self.purpose = self.purpose_choices[0 if shot_id == 1 else 1]

        self.expression = self.expression_choices[shot_id - 1] if shot_id in (
            2, 3, 4) else self.expression_choices[0]

        self.illumination = self.illumination_choices[shot_id - 4]  if shot_id in (5, 6, 7) else \
            self.illumination_choices[shot_id - 8]  if shot_id in (9, 10) else \
            self.illumination_choices[shot_id - 11] if shot_id in (12, 13) else \
            self.illumination_choices[0]

        self.occlusion = self.occlusion_choices[1] if shot_id in (8, 9, 10) else \
            self.occlusion_choices[2] if shot_id in (11, 12, 13) else \
            self.occlusion_choices[0]
Exemplo n.º 14
0
class Attack(Base):
    """Defines Spoofing Attacks (illicit attempts to authenticate)"""

    __tablename__ = 'attack'

    attack_support_choices = ('fixed', 'hand')
    """Types of attack support"""

    attack_device_choices = ('print', 'mattescreen')
    """Types of devices used for spoofing"""

    sample_type_choices = ('video', 'photo')
    """Original sample type"""

    type_device = ('mobile', 'tablet')
    """List of devices"""

    id = Column(Integer, primary_key=True)
    """Unique identifier for this attack"""

    file_id = Column(Integer, ForeignKey('file.id'))  # for SQL
    """The file identifier this attack is linked to"""

    attack_support = Column(Enum(*attack_support_choices))
    """The attack support"""

    attack_device = Column(Enum(*attack_device_choices))
    """The attack device"""

    sample_type = Column(Enum(*sample_type_choices))
    """The attack sample type"""

    sample_device = Column(Enum(*type_device))
    """The attack sample device"""

    # for Python
    file = relationship(File, backref=backref('attack', order_by=id))
    """A direct link to the :py:class:`.File` object bound to this attack"""

    protocols = relationship("Protocol",
                             secondary=attacks_protocols,
                             backref='attacks')
    """A direct link to the protocols this file is linked to"""
    def __init__(self, file, attack_support, attack_device, sample_type,
                 sample_device):
        self.file = file
        self.attack_support = attack_support
        self.attack_device = attack_device
        self.sample_type = sample_type
        self.sample_device = sample_device

    def __repr__(self):
        return "<Attack('%s')>" % (self.file.path)
Exemplo n.º 15
0
class File(Base, bob.db.verification.utils.File):
    """Generic file container"""

    __tablename__ = 'file'

    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # Session identifier
    session_id = Column(Integer)
    # Shot identifier
    shot_id = Column(Integer)
    # Finger identifier - left/right, index/middle
    finger_choices = ('li', 'lm', 'ri', 'rm')
    finger = Column(Enum(*finger_choices))
    # Sensor identifier
    sensor_choices = ('optical', 'thermal')
    sensor = Column(Enum(*sensor_choices))

    # For Python: A direct link to the client object that this file belongs to
    client = relationship("Client", backref=backref("files", order_by=id))

    def __init__(self, client_id, path, session_id, shot_id, finger, sensor):
        # call base class constructor
        bob.db.verification.utils.File.__init__(self,
                                                client_id=client_id,
                                                path=path)

        self.session_id = session_id
        self.shot_id = shot_id
        self.finger = finger
        self.sensor = sensor
Exemplo n.º 16
0
class Directory(Base, bob.db.base.File):
    """Information about the directories of the Youtube Faces database."""
    __tablename__ = 'directory'

    id = Column(
        Integer, primary_key=True
    )  # For the id's, we use running indices; this should correspond to the indices used in the "Splits" field

    # Identifier for the client
    client_id = Column(Integer, ForeignKey('client.id'))
    # Unique path to this file inside the database
    path = Column(String(50))
    # Identifier for the current image number of the client; this is not in consecutive order
    shot_id = Column(Integer)

    # a back-reference from file to client
    client = relationship("Client",
                          backref=backref("directories", order_by=id))

    def __init__(self, file_id, client_id, path):
        # call base class constructor
        shot_id = int(os.path.basename(path))
        bob.db.base.File.__init__(self, file_id=file_id, path=path)
        self.client_id = client_id
        self.shot_id = shot_id
Exemplo n.º 17
0
class File(Base, bob.db.verification.utils.File):
    """Generic file container"""

    __tablename__ = 'file'

    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(String(100), ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # Session identifier
    session_id = Column(Integer)
    # Shot identifier
    shot_id = Column(Integer)

    # For Python: A direct link to the client object that this file belongs to
    client = relationship("Client", backref=backref("files", order_by=id))

    def __init__(self, client_id, path, session_id, shot_id):
        # call base class constructor
        bob.db.verification.utils.File.__init__(self,
                                                client_id=client_id,
                                                path=path)

        self.session_id = session_id
        self.shot_id = shot_id
Exemplo n.º 18
0
class File(Base, bob.db.verification.utils.File):
    """
  Information about the files of the CUHK-CUFS database.

  Each file includes
  * the client id
  """
    __tablename__ = 'file'

    modality_choices = ('photo', 'sketch')

    id = Column(String(100), primary_key=True, autoincrement=True)
    path = Column(String(100), unique=True)
    client_id = Column(Integer, ForeignKey('client.id'))
    modality = Column(Enum(*modality_choices))

    # a back-reference from the client class to a list of files
    client = relationship("Client", backref=backref("files", order_by=id))
    all_annotations = relationship("Annotation",
                                   backref=backref("file"),
                                   uselist=True,
                                   order_by=Annotation.index)

    def __init__(self, id, image_name, client_id, modality):
        # call base class constructor
        bob.db.verification.utils.File.__init__(self,
                                                file_id=id,
                                                client_id=client_id,
                                                path=image_name)
        #bob.db.verification.utils.File.__init__(self, client_id = client_id, path = image_name)
        self.modality = modality

    def annotations(self, annotation_type="eyes_center"):
        if annotation_type == "eyes_center":
            return {
                'reye':
                (self.all_annotations[16].y, self.all_annotations[16].x),
                'leye':
                (self.all_annotations[18].y, self.all_annotations[18].x)
            }
        else:
            data = {}
            for i in range(len(self.all_annotations)):
                a = self.all_annotations[i]
                data[i] = (a.y, a.x)

            return data
Exemplo n.º 19
0
class Pair(Base):
    """Information of the pairs (as given in the pairs.txt files) of the LFW database."""
    __tablename__ = 'pair'

    id = Column(Integer, primary_key=True)
    # the folds are called 'splits' in Youtube faces, but to be consistent with LFW, we call them 'folds'
    protocol = Column(
        Enum('fold1', 'fold2', 'fold3', 'fold4', 'fold5', 'fold6', 'fold7',
             'fold8', 'fold9', 'fold10'))

    enroll_directory_id = Column(Integer, ForeignKey('directory.id'))
    probe_directory_id = Column(Integer, ForeignKey('directory.id'))
    enroll_directory = relationship(
        "Directory",
        backref=backref("enroll_directories", order_by=id),
        primaryjoin="Pair.enroll_directory_id==Directory.id")
    probe_directory = relationship(
        "Directory",
        backref=backref("probe_directories", order_by=id),
        primaryjoin="Pair.probe_directory_id==Directory.id")

    enroll_client_id = Column(Integer, ForeignKey('client.id'))
    probe_client_id = Column(Integer, ForeignKey('client.id'))
    enroll_client = relationship(
        "Client",
        backref=backref("enroll_clients", order_by=id),
        primaryjoin="Pair.enroll_client_id==Client.id")
    probe_client = relationship("Client",
                                backref=backref("probe_clients", order_by=id),
                                primaryjoin="Pair.probe_client_id==Client.id")

    is_match = Column(Boolean)

    def __init__(self, protocol, enroll_id, probe_id, enroll_client_id,
                 probe_client_id, is_match):
        self.protocol = protocol
        self.enroll_directory_id = enroll_id
        self.probe_directory_id = probe_id
        self.enroll_client_id = enroll_client_id
        self.probe_client_id = probe_client_id
        self.is_match = is_match

    def __repr__(self):
        return "<Pair('%s', '%s', '%s', '%d')>" % (
            self.protocol, self.enroll_directory_id, self.probe_directory_id,
            1 if self.is_match else 0)
Exemplo n.º 20
0
class File(Base, bob.db.base.File):
    """
    NOTE:this interface is the variant of the CASME2 database which does not use the video files, but rather the ones converted
    into frames of images. (i.e. the ones in the "CROPPED" folder). As such, this folder is supposed to be an abstract
    representation of the video file - in this case, its a fodler containing the video frames.


    This is represent the video file directory containing the frames.
    * the emotions ('happiness', 'repression', 'disgust', 'surprise', 'sadness', 'others') for the client
    * the client id, in this case, each file is a frame in the video
    """
    __tablename__ = 'file'

    # The definitions of the various emotions/expressions from the micro-expression databse in CASME2
    emotion_choices = ('happiness', 'repression', 'disgust', 'surprise',
                       'sadness', 'fear', 'others')

    ###### COLUMNS #########
    id = Column(Integer, primary_key=True, autoincrement=True)
    #path to the file directory, in this case - its the path to the folder containing the frames
    path = Column(String)
    #directory containing the video frames for the CASME2 database
    #client in the file
    client_id = Column(Integer, ForeignKey('client.id'))
    #emotion expressed in the file
    emotion = Column(Enum(*emotion_choices))
    #onset of the emotion
    onset = Column(Integer)
    #apex of the emotion
    apex = Column(Integer)
    #offset of the emotions
    offset = Column(Integer)

    ##### RELATIONSHIPS #####
    # a back-reference from the client class to a list of files
    client = relationship("Client", backref=backref("files", order_by=id))

    def __init__(self, client_id, path, emotion, onset, apex, offset):
        # call base class constructor
        bob.db.base.File.__init__(self, path=path)

        self.client_id = client_id
        self.path = path
        self.emotion = emotion
        #emotion
        self.onset = onset
        #onset
        self.apex = apex
        #apex
        self.offset = offset
        #offset

    def __repr__(self):
        return "<File(filename:'%s', Client_id:'%s, emotion:'%s', onset: %d, apex: %d, offset: %d)>" % (
            self.path, self.client_id, self.emotion, self.onset, self.apex,
            self.offset)
Exemplo n.º 21
0
class Subworld(Base):
  """Database clients belonging to the world group are split in subsets"""

  __tablename__ = 'subworld'

  # Key identifier for this Subworld object
  id = Column(Integer, primary_key=True)
  # Subworld to which the client belongs to
  name = Column(String(20), unique=True)

  # for Python: A direct link to the client
  clients = relationship("Client", secondary=subworld_client_association, backref=backref("subworld", order_by=id))
  # for Python: A direct link to the files
  files = relationship("File", secondary=subworld_file_association, backref=backref("subworld", order_by=id))

  def __init__(self, name):
    self.name = name

  def __repr__(self):
    return "Subworld('%s')" % (self.name)
Exemplo n.º 22
0
class Attack(Base):
    """Defines Spoofing Attacks (illicit attempts to authenticate)"""

    __tablename__ = 'attack'

    attack_support_choices = ('replay', 'voice_conversion', 'speech_synthesis')
    """Types of attacks support"""

    attack_device_choices = ('laptop', 'laptop_HQ_speaker', 'phone1', 'phone2', 'logical_access',
                             'physical_access', 'physical_access_HQ_speaker')
    """Types of devices and types of access used for spoofing"""

    id = Column(Integer, primary_key=True)
    """Unique identifier for this attack"""

    file_id = Column(Integer, ForeignKey('file.id'))  # for SQL
    """The file identifier this attack is linked to"""

    attack_support = Column(Enum(*attack_support_choices))
    """The attack support"""

    attack_device = Column(Enum(*attack_device_choices))
    """The attack device"""

    # for Python
    file = relationship(File, backref=backref('attack', order_by=id))
    """A direct link to the :py:class:`.File` object bound to this attack"""

    protocols = relationship("Protocol", secondary=attacks_protocols,
                             backref='attack')
    """A direct link to the protocols this file is linked to"""

    def __init__(self, file, attack_support, attack_device):
        self.file = file
        self.attack_support = attack_support
        self.attack_device = attack_device

    def __repr__(self):
        return "Attack('%s')" % self.file.path
Exemplo n.º 23
0
class RealAccess(Base):
    """Defines Real-Accesses (licit attempts to authenticate)"""

    __tablename__ = 'realaccess'

    id = Column(Integer, primary_key=True)
    """Unique identifier for this real-access object"""

    file_id = Column(Integer, ForeignKey('file.id'))  # for SQL
    """The file identifier the current real-access is bound to"""

    # for Python
    file = relationship(File, backref=backref('realaccess', order_by=id))
    """A direct link to the :py:class:`.File` object this real-access belongs to"""

    protocols = relationship("Protocol", secondary=realaccesses_protocols,
                             backref='realaccess')
    """A direct link to the protocols this file is linked to"""

    def __init__(self, file):
        self.file = file

    def __repr__(self):
        return "RealAccess('%s')" % self.file.path
Exemplo n.º 24
0
class File(Base, bob.db.base.File):
    """Generic file container"""
    __tablename__ = 'file'
    # Key identifier for the file
    id = Column(Integer, primary_key=True)
    # Key identifier of the client associated with this file
    client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
    # Unique path to this file inside the database
    path = Column(String(100), unique=True)
    # extra identificators:
    #  session_choices = ("1","2","3")
    #  session = Column(Enum(*session_choices))
    #  attempt_choices = ("1","2","3", "4", "5")
    #  attempt = Column(Enum(*attempt_choices))
    #  image_no_choices = ("1","2","3", "4", "5")
    #  image_no = Column(Enum(*image_no_choices))

    # For Python: A direct link to the client object that this file belongs to:
    client = relationship("Client", backref=backref("files", order_by=id))
    # For Python: A direct link to the annotation object that file belongs to this file:
    #annotation = relationship("Annotation", backref=backref("file", order_by=id, uselist=False), uselist=False)

    # this column is not really required as it can be computed from other
    # information already in the database, it is only an optimisation to allow us
    # to quickly filter files by ``model_id``
    model_id = Column(String(9), unique=True)

    def __init__(self, client_id, path,
                 nr):  # , f_session, f_attempt, f_image_no
        # call base class constructor, client ID - SQL table ID;
        # path - A relative path, which includes file name but excludes file extension
        # Because this is an SQL database, you SHOULD NOT assign the file_id
        bob.db.base.File.__init__(self, path=path)
        self.client_id = client_id
        self.model_id = "c_{}_i_{}".format(client_id, nr)
#    self.session = f_session
#    self.attempt = f_attempt
#    self.image_no = f_image_no

    def __repr__(self):
        return "\nFile(assigned SQL id = {}, Client id = {}, path = {})"\
        .format(self.id, self.client_id, self.path)

    @property
    def get_client_id(self):
        """Unique name for a given file (image) in the database"""

        return self.client_id
Exemplo n.º 25
0
class File(Base, bob.db.base.File):
  """Generic file container"""

  __tablename__ = 'file'

  # Key identifier for the file
  id = Column(Integer, primary_key=True)
  # Key identifier of the client associated with this file
  client_id = Column(Integer, ForeignKey('client.id'))  # for SQL
  # Unique path to this file inside the database
  path = Column(String(100), unique=True)
  # Identifier of the session
  session_id = Column(Integer)
  # Speech type
  speech_type_choices = ('p', 'l', 'r', 'f')
  speech_type = Column(Enum(*speech_type_choices))
  # Identifier of the shot
  shot_id = Column(Integer)
  # Identifier of the environment
  environment_choices = ('i', 'o')
  environment = Column(Enum(*environment_choices))
  # Identifier of the device
  device_choices = ('mobile', 'laptop')
  device = Column(Enum(*device_choices))
  # Identifier of the channel
  channel_id = Column(Integer)

  # For Python: A direct link to the client object that this file belongs to
  client = relationship("Client", backref=backref("files", order_by=id))

  def __init__(self, client_id, path, session_id, speech_type, shot_id, environment, device, channel_id):
    # call base class constructor
    bob.db.base.File.__init__(self, path=path)

    # fill the remaining bits of the file information
    self.client_id = client_id
    self.session_id = session_id
    self.speech_type = speech_type
    self.shot_id = shot_id
    self.environment = environment
    self.device = device
    self.channel_id = channel_id
Exemplo n.º 26
0
class Subworld(Base):
    """The subworld class defines different training set sizes.
  It is created from the 'x1', 'x2', 'x4' and 'x8' training lists from the GBU database."""
    __tablename__ = 'subworld'

    subworld_choices = ('x1', 'x2', 'x4', 'x8')

    id = Column(Integer, primary_key=True)
    name = Column(Enum(*subworld_choices))

    # back-reference from the file to the subworlds
    files = relationship("File",
                         secondary=subworld_file_association,
                         backref=backref("subworlds", order_by=id))

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return "<Subworld('%s')>" % (self.name)
Exemplo n.º 27
0
class TClient(Base):
    """Database T-clients, marked by an integer identifier and the group they belong to"""

    __tablename__ = 'tclient'

    # Key identifier for the client
    id = Column(String(20), primary_key=True)  # speaker_pin
    gender_choices = ('male', 'female')
    gender = Column(Enum(*gender_choices))

    # For Python: A direct link to the File objects associated with this T-Norm client
    files = relationship("File",
                         secondary=tclient_file_association,
                         backref=backref("tclients", order_by=id))

    def __init__(self, id, gender):
        self.id = id
        self.gender = gender

    def __repr__(self):
        return "TClient(%s, %s)" % (self.id, self.gender)
Exemplo n.º 28
0
class Finger(Base):
    """Unique fingers in the database, referred by a string

  Fingers have the format ``0003_3`` (i.e. <client>_<finger>)
  """

    __tablename__ = 'finger'

    id = Column(Integer, primary_key=True)

    client_id = Column(Integer, ForeignKey('client.id'))
    client = relationship("Client", backref=backref("fingers", order_by=id))

    name_choices = ('1', '2', '3', '4', '5', '6')
    name = Column(Enum(*name_choices))

    UniqueConstraint('client_id', 'name')

    # finger name enumerations relationship with human-readable versions
    finger_names = {
        '1': 'left ring',
        '2': 'left middle',
        '3': 'left index',
        '4': 'right index',
        '5': 'right middle',
        '6': 'right ring',
    }

    def __init__(self, client, name):
        self.client = client
        self.name = name

    def name_display(self):
        """Returns a representation of the finger side"""

        return Finger.finger_names[self.name]

    def __repr__(self):
        return "Finger(%04d_%s)" % (self.client.id, self.name)
Exemplo n.º 29
0
class ActionUnits(Base):

    __tablename__ = 'actionunits'

    #In this part, we describe the facial action units. There is a prefix attached to the action unit which describes
    # the side of the face which the action unit is activated. For example AU2L, means action unit 2 on the left part of
    # the face,
    # R - Right side of the face
    # L - Left side of the face

    #In addition to that, -1 is used for the apex column of one of the subjects which is supposed to represent an undecided',
    # or unavailable option.

    id = Column(Integer, primary_key=True, autoincrement=True)
    file_id = Column(Integer, ForeignKey('file.id'))
    actionunit = Column(String)

    actionunits = relationship("File",
                               backref=backref("actionunits", order_by=id))

    def __repr__(self):
        return "<ActionUnit(file_id: %d, value: %s)" % (self.file_id,
                                                        self.actionunit)
Exemplo n.º 30
0
class Frame(Base, bob.db.base.File):
    """
    This is represents the frames in the video file (in this case, contained in the folder)

    It contains the sequence of frames for each file recorded for the subjects in CASME2
    """

    __tablename__ = 'frame'

    id = Column(Integer, primary_key=True, autoincrement=True)
    client_id = Column(Integer, ForeignKey('client.id'))
    # the client id the fram belongs to
    frame_no = Column('frame_no', Integer)
    # the frame number
    file_id = Column(Integer, ForeignKey("file.id"))
    #file id the frame belongs to
    filename = Column(
        String)  # the filename of the jpeg image file - i.e. the frame itself.

    # a back-reference from the client class to a list of files
    files = relationship("File", backref=backref("frames", order_by=frame_no))

    def __init__(self, path, client_id, file_id, frame_no, filename):
        # call base class constructor
        bob.db.base.File.__init__(self, path=path)
        self.client_id = client_id

        #set the variables
        self.file_id = file_id
        self.frame_no = frame_no
        self.filename = filename

    def __repr__(self):
        #returns representation in string form
        return "Frame<(file_id: %d, frame_no: %d)>" % (self.file_id,
                                                       self.frame_no)