diff --git a/bob/pad/face/config/extractor/video_lbp_histogram.py b/bob/pad/face/config/extractor/video_lbp_histogram.py index db62b37abd0a9333bb2be163b168027cae5e8916..7fc7bcb1b18caafc5925c9a1295ea9663b3193d4 100644 --- a/bob/pad/face/config/extractor/video_lbp_histogram.py +++ b/bob/pad/face/config/extractor/video_lbp_histogram.py @@ -1,6 +1,8 @@ #!/usr/bin/env python -from bob.pad.face.extractor import VideoLBPHistogram +from bob.pad.face.extractor import LBPHistogram + +from bob.bio.video.extractor import Wrapper #======================================================================================= # Define instances here: @@ -12,10 +14,10 @@ neighbors = 8 circ = False dtype = None -video_lbp_histogram_extractor_n8r1_uniform = VideoLBPHistogram( +video_lbp_histogram_extractor_n8r1_uniform = Wrapper(LBPHistogram( lbptype=lbptype, elbptype=elbptype, rad=rad, neighbors=neighbors, circ=circ, - dtype=dtype) + dtype=dtype)) diff --git a/bob/pad/face/config/lbp_svm.py b/bob/pad/face/config/lbp_svm.py index 0b7ff33efa23b097d369d0355ee315d953aa934b..3261e8ff815e23c2edd3609ce32d2a0b9f31a1af 100644 --- a/bob/pad/face/config/lbp_svm.py +++ b/bob/pad/face/config/lbp_svm.py @@ -54,7 +54,9 @@ below ``min_face_size`` threshold are discarded. The preprocessor is similar to #======================================================================================= # define extractor: -from ..extractor import VideoLBPHistogram +from ..extractor import LBPHistogram + +from bob.bio.video.extractor import Wrapper LBPTYPE = 'uniform' ELBPTYPE = 'regular' @@ -63,13 +65,13 @@ NEIGHBORS = 8 CIRC = False DTYPE = None -extractor = VideoLBPHistogram( +extractor = Wrapper(LBPHistogram( lbptype=LBPTYPE, elbptype=ELBPTYPE, rad=RAD, neighbors=NEIGHBORS, circ=CIRC, - dtype=DTYPE) + dtype=DTYPE)) """ In the feature extraction stage the LBP histograms are extracted from each frame of the preprocessed video. diff --git a/bob/pad/face/config/lbp_svm_aggregated_db.py b/bob/pad/face/config/lbp_svm_aggregated_db.py index d8698a51dc9fe392ca7bdd835b40905f9f1cc3e2..778364e8c7d69047cc4218cbec6136312e05161d 100644 --- a/bob/pad/face/config/lbp_svm_aggregated_db.py +++ b/bob/pad/face/config/lbp_svm_aggregated_db.py @@ -56,7 +56,9 @@ below ``min_face_size`` threshold are discarded. The preprocessor is similar to #======================================================================================= # define extractor: -from ..extractor import VideoLBPHistogram +from ..extractor import LBPHistogram + +from bob.bio.video.extractor import Wrapper LBPTYPE = 'uniform' ELBPTYPE = 'regular' @@ -65,13 +67,13 @@ NEIGHBORS = 8 CIRC = False DTYPE = None -extractor = VideoLBPHistogram( +extractor = Wrapper(LBPHistogram( lbptype=LBPTYPE, elbptype=ELBPTYPE, rad=RAD, neighbors=NEIGHBORS, circ=CIRC, - dtype=DTYPE) + dtype=DTYPE)) """ In the feature extraction stage the LBP histograms are extracted from each frame of the preprocessed video. The parameters are similar to the ones introduced in [CAM12]_. diff --git a/bob/pad/face/extractor/VideoLBPHistogram.py b/bob/pad/face/extractor/VideoLBPHistogram.py deleted file mode 100644 index 7c2bb8f387268dbba9c413be5ca1d80da385dc56..0000000000000000000000000000000000000000 --- a/bob/pad/face/extractor/VideoLBPHistogram.py +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -Created on Tue May 16 13:48:43 2017 - -@author: Olegs Nikisins -""" - -#============================================================================== -# Import what is needed here: - -from bob.bio.base.extractor import Extractor - -from bob.pad.face.extractor import LBPHistogram - -import bob.bio.video - -#============================================================================== -# Main body: - - -class VideoLBPHistogram(Extractor, object): - """ - This class is designed to extract LBP histograms for each frame in the input - video sequence/container. - - **Parameters:** - - ``lbptype`` : :py:class:`str` - The type of the LBP operator ("regular", "uniform" or "riu2"). - Default: uniform. - - ``elbptype`` : :py:class:`str` - The type of extended version of LBP (regular if not extended version - is used, otherwise transitional, direction_coded or modified). - Default: regular. - - ``rad`` : :py:class:`float` - The radius of the circle on which the points are taken (for circular - LBP). Default: 1 - - ``neighbors`` : :py:class:`int` - The number of points around the central point on which LBP is - computed. Possible options: (4, 8, 16). Default: 8. - - ``circ`` : :py:class:`bool` - Set to True if circular LBP is needed. Default: False. - - ``dtype`` : numpy.dtype - If specified in the constructor, the resulting features will have - that type of data. Default: None. - """ - - #========================================================================== - def __init__(self, - lbptype='uniform', - elbptype='regular', - rad=1, - neighbors=8, - circ=False, - dtype=None): - - super(VideoLBPHistogram, self).__init__( - lbptype=lbptype, - elbptype=elbptype, - rad=rad, - neighbors=neighbors, - circ=circ, - dtype=dtype) - - self.lbptype = lbptype - self.elbptype = elbptype - self.rad = rad - self.neighbors = neighbors - self.circ = circ - self.dtype = dtype - - # extractor to process a single image/frame: - extractor = LBPHistogram( - lbptype=lbptype, - elbptype=elbptype, - rad=rad, - neighbors=neighbors, - circ=circ, - dtype=dtype) - - # a wrapper allowing to apply above extractor to the whole video: - self.video_extractor = bob.bio.video.extractor.Wrapper(extractor) - - #========================================================================== - def __call__(self, frames): - """ - Extracts LBP histogram for each frame in the input video sequence/container.s - - **Parameters:** - - ``frames`` : FrameContainer - Video data stored in the FrameContainer, see ``bob.bio.video.utils.FrameContainer`` - for further details. - - **Returns:** - - ``lbp_histograms`` : FrameContainer - LBP histograms for each frame stored in the FrameContainer. - """ - - lbp_histograms = self.video_extractor(frames=frames) - - return lbp_histograms - - #========================================================================== - def write_feature(self, frames, file_name): - """ - Writes the given data (that has been generated using the __call__ function of this class) to file. - This method overwrites the write_data() method of the Extractor class. - - **Parameters:** - - ``frames`` : - Data returned by the __call__ method of the class. - - ``file_name`` : :py:class:`str` - Name of the file. - """ - - self.video_extractor.write_feature(frames, file_name) - - #========================================================================== - def read_feature(self, file_name): - """ - Reads the preprocessed data from file. - This method overwrites the read_data() method of the Extractor class. - - **Parameters:** - - ``file_name`` : :py:class:`str` - Name of the file. - - **Returns:** - - ``frames`` : :py:class:`bob.bio.video.FrameContainer` - Frames stored in the frame container. - """ - - frames = self.video_extractor.read_feature(file_name) - - return frames diff --git a/bob/pad/face/extractor/__init__.py b/bob/pad/face/extractor/__init__.py index e754647bb26ad991aa003f41e4817c592e1be35e..8ea9c9dbc1ff9b5eb7e1ccc9d726132a679cae39 100644 --- a/bob/pad/face/extractor/__init__.py +++ b/bob/pad/face/extractor/__init__.py @@ -1,5 +1,4 @@ from .LBPHistogram import LBPHistogram -from .VideoLBPHistogram import VideoLBPHistogram from .ImageQualityMeasure import ImageQualityMeasure from .VideoDataLoader import VideoDataLoader from .FrameDiffFeatures import FrameDiffFeatures @@ -25,7 +24,6 @@ def __appropriate__(*args): __appropriate__( LBPHistogram, - VideoLBPHistogram, ImageQualityMeasure, VideoDataLoader, FrameDiffFeatures, diff --git a/bob/pad/face/test/test.py b/bob/pad/face/test/test.py index ac4e429718b988b032962b53060641b6e68965f7..5693bb7fa89f2f775de938ee60d79d78fadf93f7 100644 --- a/bob/pad/face/test/test.py +++ b/bob/pad/face/test/test.py @@ -26,7 +26,7 @@ from ..preprocessor import FrameDifference from ..extractor import FrameDiffFeatures -from ..extractor import VideoLBPHistogram +from ..extractor import LBPHistogram from ..extractor import ImageQualityMeasure @@ -307,7 +307,7 @@ def test_frame_diff_features(): #============================================================================== def test_video_lbp_histogram(): """ - Test VideoLBPHistogram extractor. + Test LBPHistogram with Wrapper extractor. """ image = load(datafile('test_image.png', 'bob.pad.face.test')) @@ -349,13 +349,13 @@ def test_video_lbp_histogram(): CIRC = False DTYPE = None - extractor = VideoLBPHistogram( + extractor = bob.bio.video.extractor.Wrapper(LBPHistogram( lbptype=LBPTYPE, elbptype=ELBPTYPE, rad=RAD, neighbors=NEIGHBORS, circ=CIRC, - dtype=DTYPE) + dtype=DTYPE)) lbp_histograms = extractor(faces)