Commit a096a142 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Fix imports

parent d9870e3f
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bob.bio.video import FrameSelector
from bob.extension import rc
from bob.io.video import reader
from bob.pad.base.database import PadDatabase
......@@ -126,28 +125,6 @@ class CasiaFasdPadFile(VideoPadFile):
annotations[str(i)].update(expected_eye_positions(bounding_box))
return annotations
def load(self, directory=None, extension='.avi',
frame_selector=FrameSelector(selection_style='all')):
"""Loads the video file and returns in a
:any:`bob.bio.video.FrameContainer`.
Parameters
----------
directory : :obj:`str`, optional
The directory to load the data from.
extension : :obj:`str`, optional
The extension of the file to load.
frame_selector : :any:`bob.bio.video.FrameSelector`, optional
Which frames to select.
Returns
-------
:any:`bob.bio.video.FrameContainer`
The loaded frames inside a frame container.
"""
directory = directory or self.original_directory
return frame_selector(self.make_path(directory, extension))
class CasiaFasdPadDatabase(PadDatabase):
"""
......
......@@ -5,7 +5,6 @@
import os
import numpy as np
import bob.io.video
from bob.bio.video import FrameSelector, FrameContainer
from bob.pad.face.database import VideoPadFile
from bob.pad.base.database import PadDatabase
......@@ -54,7 +53,7 @@ class CasiaSurfPadFile(VideoPadFile):
path=s.id)
def load(self, directory=rc['bob.db.casiasurf.directory'], extension='.jpg', frame_selector=FrameSelector(selection_style='all')):
def load(self, directory=rc['bob.db.casiasurf.directory'], extension='.jpg'):
"""Overloaded version of the load method defined in ``VideoPadFile``.
Parameters
......
......@@ -25,8 +25,7 @@ class CELEBAPadFile(PadFile):
super(CELEBAPadFile, self).__init__(client_id, path, attack_type, file_id)
# ==========================================================================
def load(self, directory=None, extension=None,
frame_selector=bob.bio.video.FrameSelector(selection_style='all')):
def load(self):
"""
Overridden version of the load method defined in the ``PadFile``.
......
......@@ -20,6 +20,9 @@ class VideoPadFile(PadFile):
annotation_directory=None,
annotation_extension=None,
annotation_type=None,
selection_style=None,
max_number_of_frames=None,
step_size=None,
):
super().__init__(
attack_type=attack_type,
......@@ -32,10 +35,12 @@ class VideoPadFile(PadFile):
annotation_extension=annotation_extension,
annotation_type=annotation_type,
)
self.selection_style = selection_style or "all"
self.max_number_of_frames = max_number_of_frames
self.step_size = step_size
def load(
self,
frame_selector=bob.bio.video.FrameSelector(selection_style="all"),
):
"""Loads the video file and returns in a `bob.bio.video.FrameContainer`.
......@@ -49,9 +54,7 @@ class VideoPadFile(PadFile):
:any:`bob.bio.video.FrameContainer`
The loaded frames inside a frame container.
"""
path = self.make_path(
self.original_directory, self.original_extension
)
path = self.make_path(self.original_directory, self.original_extension)
video = bob.bio.video.VideoAsArray(
path,
selection_style=frame_selector.selection_style,
......
......@@ -4,7 +4,6 @@
import os
import numpy as np
import bob.io.video
from bob.bio.video import FrameSelector, FrameContainer
from bob.pad.face.database import VideoPadFile
from bob.pad.base.database import PadDatabase
......@@ -42,30 +41,6 @@ class MaskAttackPadFile(VideoPadFile):
attack_type=attack_type,
file_id=f.id)
def load(self, directory=None, extension='.avi', frame_selector=FrameSelector(selection_style='all')):
"""Overridden version of the load method defined in ``VideoPadFile``.
Parameters
----------
directory : :py:class:`str`
String containing the path to the 3DMAD database
(generated sequences from original data).
extension : :py:class:`str`
Extension of the video files
frame_selector : :py:class:`bob.bio.video.FrameSelector`
The frame selector to use.
Returns
-------
video_data : :py:class:`bob.bio.video.utils.FrameContainer`
video data stored in a FrameContainer
"""
vfilename = self.make_path(directory, extension)
video = bob.io.video.reader(vfilename)
video_data_array = video.load()
return frame_selector(video_data_array)
class MaskAttackPadDatabase(PadDatabase):
"""High level implementation of the Database class for the 3DMAD database.
......
......@@ -6,7 +6,6 @@
#==============================================================================
# Used in ReplayMobilePadFile class
from bob.bio.video import FrameSelector, FrameContainer
import bob.io.base
import numpy as np
......@@ -27,7 +26,7 @@ class MIFSPadFile(VideoPadFile):
file_id)
#==========================================================================
def load(self, directory=None, extension=None, frame_selector=FrameSelector(selection_style='all')):
def load():
"""
Overridden version of the load method defined in the ``VideoPadFile``.
......
......@@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
# Used in ReplayMobilePadFile class
from bob.bio.video import FrameSelector
from bob.pad.base.database import PadDatabase
from bob.pad.face.database import VideoPadFile
from bob.pad.face.utils import number_of_frames
......@@ -51,8 +50,7 @@ class ReplayMobilePadFile(VideoPadFile):
attack_type=attack_type,
file_id=f.id)
def load(self, directory=None, extension='.mov',
frame_selector=FrameSelector(selection_style='all')):
def load(self):
"""
Overridden version of the load method defined in the ``VideoPadFile``.
......
from ..utils import extract_patches
from bob.bio.base.preprocessor import Preprocessor
from bob.bio.video import FrameContainer
from bob.bio.video.preprocessor import Wrapper
from bob.bio.video.transformer import VideoWrapper
from collections import OrderedDict
......@@ -32,7 +31,7 @@ class ImagePatches(Preprocessor):
return fc
class VideoPatches(Wrapper):
class VideoPatches(VideoWrapper):
"""Extracts patches of images from video containers and returns it in a
FrameContainer.
"""
......
from bob.bio.base.test.utils import atnt_database_directory
from bob.bio.video.utils import FrameContainer
import bob.io.base
import os
from bob.pad.face.database import VideoPadFile
......
Markdown is supported
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