Commit 0d10d72a authored by Sushil BHATTACHARJEE's avatar Sushil BHATTACHARJEE
Browse files

committed changed files sent by artur

parent e0600f31
Pipeline #3076 failed with stage
in 18 minutes and 44 seconds
......@@ -60,6 +60,7 @@ def add_command(subparsers):
parser.add_argument('-c', '--class', dest="cls", default='', help="if given, limits the dump to a particular subset of the data that corresponds to the given class (defaults to '%(default)s')", choices=('real', 'attack', 'enroll'))
parser.add_argument('-g', '--group', dest="group", default='', help="if given, this value will limit the output files to those belonging to a particular protocolar group. (defaults to '%(default)s')", choices=db.groups())
parser.add_argument('-s', '--support', dest="support", default='', help="if given, this value will limit the output files to those using this type of attack support. (defaults to '%(default)s')", choices=db.attack_supports())
parser.add_argument('-st', '--sample_type', dest="sample_type", default='', help="if given, this value will limit the output files to those using this type of media (photo or video). (defaults to '%(default)s')", choices=db.attack_sample_types())
parser.add_argument('-x', '--protocol', dest="protocol", default='', help="if given, this value will limit the output files to those for a given protocol. (defaults to '%(default)s')", choices=protocols)
parser.add_argument('-l', '--light', dest="light", default='', help="if given, this value will limit the output files to those shot under a given lighting. (defaults to '%(default)s')", choices=db.lights())
parser.add_argument('-C', '--client', dest="client", default=None, type=int, help="if given, limits the dump to a particular client (defaults to '%(default)s')", choices=clients)
......
......@@ -127,7 +127,8 @@ class File(Base):
"""
if not directory: directory = ''
directory = os.path.join(directory, 'face-locations')
#directory = os.path.join(directory, 'face-locations')
directory = os.path.join(directory, 'faceloc/rect/')
return self.make_path(directory, '.face')
def bbx(self, directory=None):
......@@ -188,7 +189,8 @@ class File(Base):
raise RuntimeError("%s is not an attack" % self)
return self.attack[0]
def load(self, directory=None, extension='.hdf5'):
#def load(self, directory=None, extension='.hdf5'):
def load(self, directory=None, extension=None):
"""Loads the data at the specified location and using the given extension.
Keyword parameters:
......@@ -204,7 +206,31 @@ class File(Base):
[optional] The extension of the filename - this will control the type of
output and the codec for saving the input blob.
"""
return bob.io.base.load(self.make_path(directory, extension))
print 'video file extension:', extension
if extension is None:
extension = '.mov'
# if self.get_quality() == 'laptop':
# extension = '.mov'
# else:
# extension = '.mp4'
if extension == '.mov' or extension == '.mp4':
vfilename = self.make_path(directory, extension)
video = bob.io.video.reader(vfilename)
vin = video.load()
else:
vin = bob.io.base.load(self.make_path(directory, extension))
vin = numpy.rollaxis(vin, 3, 2)
if not self.is_tablet():
print "flipping mobile video"
vin = vin[:, :, ::-1,:]
# if self.is_rotated():
# vin = vin[:, :, ::-1,:]
return vin
#return bob.io.base.load(self.make_path(directory, extension))
def save(self, data, directory=None, extension='.hdf5'):
"""Saves the input data at the specified location and using the given
......@@ -353,3 +379,4 @@ class Attack(Base):
def __repr__(self):
return "<Attack('%s')>" % (self.file.path)
......@@ -63,7 +63,7 @@ class Database(object):
def objects(self, support=Attack.attack_support_choices,
protocol='grandtest', groups=Client.set_choices, cls=('attack', 'real'),
light=File.light_choices, clients=None ,device=File.device_choices):
light=File.light_choices, clients=None ,device=File.device_choices, sample_type= Attack.sample_type_choices):
"""Returns a list of unique :py:class:`.File` objects for the specific
query by the user.
......@@ -103,6 +103,11 @@ class Database(object):
One of the capture device as returned by device() or a combination
of the two (in a tuple), which is also the default.
sample_type
type of attack regarding with media displayed on mattescreen attacks.
'photo' refers to a kind of attack that shows and static imagen on a screen.
'video' refers to a attack manufactured presenting a video on a mattescreeen
Returns: A list of :py:class:`.File` objects.
"""
......@@ -147,6 +152,10 @@ class Database(object):
VALID_DEVICES = self.devices()
device = check_validity(device, "device", VALID_DEVICES, None)
# checks if the device is valid
VALID_SAMPLE_TYPE = self.attack_sample_types()
sample_type = check_validity(sample_type, "sample_type", VALID_SAMPLE_TYPE, None)
# now query the database
retval = []
......@@ -179,6 +188,7 @@ class Database(object):
if groups: q = q.filter(Client.set.in_(groups))
if clients: q = q.filter(Client.id.in_(clients))
if support: q = q.filter(Attack.attack_support.in_(support))
if sample_type: q = q.filter(Attack.sample_type.in_(sample_type))
if light: q = q.filter(File.light.in_(light))
if device: q = q.filter(File.device.in_(device))
q = q.filter(Protocol.name.in_(protocol))
......
......@@ -73,11 +73,12 @@ class Database(antispoofing.utils.db.Database):
if args is not None:
self.__kwargs = {
'protocol': args.replay_protocol,
'support' : args.replay_support,
'light' : args.replay_light,
'clients' : args.replay_client if args.replay_client else None,
'device' : args.replay_device,
'protocol' : args.replay_protocol,
'support' : args.replay_support,
'sample_type': args.replay_sample_types,
'light' : args.replay_light,
'clients' : args.replay_client if args.replay_client else None,
'device' : args.replay_device,
}
__init__.__doc__ = antispoofing.utils.db.Database.__init__.__doc__
......@@ -109,6 +110,10 @@ class Database(antispoofing.utils.db.Database):
p.add_argument('--support', type=str, dest='replay_support', choices=supports,
help="If you would like to select a specific support to be used, use this option (if unset, the default, use all)")
sample_type = ReplayAttackModel.sample_type_choices
p.add_argument('--sample_types', type=str, dest='replay_sample_types', choices=sample_type,
help="If you would like to select a specific media (photo or video) to be used, use this option (if unset, the default, use all)")
lights = ReplayFileModel.light_choices
p.add_argument('--light', type=str, choices=lights, dest='replay_light', help="Types of illumination conditions (if unset, the default, use all)")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment