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/extractor/video_quality_measure.py b/bob/pad/face/config/extractor/video_quality_measure.py index f5cc55985cc2bcb8ef98067b45f4a95f7950ea93..fc9af42b6aa334a514b1c2cbc4a5452712e41ca3 100644 --- a/bob/pad/face/config/extractor/video_quality_measure.py +++ b/bob/pad/face/config/extractor/video_quality_measure.py @@ -1,6 +1,8 @@ #!/usr/bin/env python -from bob.pad.face.extractor import VideoQualityMeasure +from bob.pad.face.extractor import ImageQualityMeasure + +import bob.bio.video #======================================================================================= # Define instances here: @@ -9,5 +11,4 @@ galbally = True msu = True dtype = None -video_quality_measure_galbally_msu = VideoQualityMeasure( - galbally=galbally, msu=msu, dtype=dtype) +video_quality_measure_galbally_msu = bob.bio.video.extractor.Wrapper(ImageQualityMeasure(galbally=galbally, msu=msu, 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/config/qm_lr.py b/bob/pad/face/config/qm_lr.py index 92ae19858fc467d263a4c43493cd48329e07e0f9..19a5d4221f0156c01e32d78a09ed848468416ff3 100644 --- a/bob/pad/face/config/qm_lr.py +++ b/bob/pad/face/config/qm_lr.py @@ -54,13 +54,15 @@ facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. #======================================================================================= # define extractor: -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure + +from bob.bio.video.extractor import Wrapper GALBALLY = True MSU = True DTYPE = None -extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) +extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) """ In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. diff --git a/bob/pad/face/config/qm_one_class_gmm.py b/bob/pad/face/config/qm_one_class_gmm.py index 16a44c01d6584566a72b99afd73a806a2cbe019a..182c71bbbe8ef8783c81c9d42a2467e6371d5d0c 100644 --- a/bob/pad/face/config/qm_one_class_gmm.py +++ b/bob/pad/face/config/qm_one_class_gmm.py @@ -54,13 +54,15 @@ facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. #======================================================================================= # define extractor: -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure + +from bob.bio.video.extractor import Wrapper GALBALLY = True MSU = True DTYPE = None -extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) +extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) """ In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. diff --git a/bob/pad/face/config/qm_one_class_svm_aggregated_db.py b/bob/pad/face/config/qm_one_class_svm_aggregated_db.py index efebc10857c0bbb32bada822b84be4783804211a..1216d66bf9af9cf324c0b8cc0c947eb342a78ecf 100644 --- a/bob/pad/face/config/qm_one_class_svm_aggregated_db.py +++ b/bob/pad/face/config/qm_one_class_svm_aggregated_db.py @@ -56,13 +56,15 @@ facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. #======================================================================================= # define extractor: -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure + +from bob.bio.video.extractor import Wrapper GALBALLY = True MSU = True DTYPE = None -extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) +extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) """ In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. diff --git a/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py b/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py index 6b63e29df4a5adae7707ba4cdfedf7c0dec0ca10..7fcc6122020478a7828f70e357e37cd5fa1e082f 100644 --- a/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py +++ b/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py @@ -56,13 +56,15 @@ facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. #======================================================================================= # define extractor: -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure + +from bob.bio.video.extractor import Wrapper GALBALLY = True MSU = True DTYPE = None -extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) +extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) """ In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. diff --git a/bob/pad/face/config/qm_svm.py b/bob/pad/face/config/qm_svm.py index 609ab7def5380090b5678d889c136460bfc512df..961a413fdbbc294ac325b2d5a694af3689cfae48 100644 --- a/bob/pad/face/config/qm_svm.py +++ b/bob/pad/face/config/qm_svm.py @@ -54,13 +54,15 @@ facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. #======================================================================================= # define extractor: -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure + +from bob.bio.video.extractor import Wrapper GALBALLY = True MSU = True DTYPE = None -extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) +extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) """ In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. diff --git a/bob/pad/face/config/qm_svm_aggregated_db.py b/bob/pad/face/config/qm_svm_aggregated_db.py index 01199315fef2bfd97d80b70e40a26ab004de2042..481c50b85b7ec42eaf5a1e4f59999d48bd38f605 100644 --- a/bob/pad/face/config/qm_svm_aggregated_db.py +++ b/bob/pad/face/config/qm_svm_aggregated_db.py @@ -56,13 +56,15 @@ facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. #======================================================================================= # define extractor: -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure + +from bob.bio.video.extractor import Wrapper GALBALLY = True MSU = True DTYPE = None -extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) +extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) """ In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. 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/VideoQualityMeasure.py b/bob/pad/face/extractor/VideoQualityMeasure.py deleted file mode 100644 index a48e05894ae2b8b0da4698e12b2a48faa4107dd2..0000000000000000000000000000000000000000 --- a/bob/pad/face/extractor/VideoQualityMeasure.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -Created on Wed May 31 16:39:34 2017 - -@author: Olegs Nikisins -""" - -#============================================================================== -# Import what is needed here: - -from bob.bio.base.extractor import Extractor - -from bob.pad.face.extractor import ImageQualityMeasure - -import bob.bio.video - -from bob.pad.face.extractor import VideoDataLoader - -import six - -#============================================================================== -# Main body: - - -class VideoQualityMeasure(Extractor, object): - """ - This class is designed to extract Quality Measures for each frame in the - input color video. For further documentation and description of features, - see "bob.ip.qualitymeasure". - - **Parameters:** - - ``galbally`` : :py:class:`bool` - If ``True``, galbally features will be added to the features. - Default: ``True``. - - ``msu`` : :py:class:`bool` - If ``True``, MSU features will be added to the features. - Default: ``True``. - - ``dtype`` : numpy.dtype - The data type of the resulting feature vector. - Default: ``None``. - """ - - #========================================================================== - def __init__(self, galbally=True, msu=True, dtype=None, **kwargs): - - super(VideoQualityMeasure, self).__init__( - galbally=galbally, msu=msu, dtype=dtype) - - self.galbally = galbally - self.msu = msu - self.dtype = dtype - - # extractor to process a single image/frame: - extractor = ImageQualityMeasure( - galbally=galbally, msu=msu, 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): - """ - Extract feature vectors containing Quality Measures for each frame - in the input color video sequence/container. The resulting features - will be saved to the FrameContainer too. - - **Parameters:** - - ``frames`` : FrameContainer or string. - Video data stored in the FrameContainer, - see ``bob.bio.video.utils.FrameContainer`` for further details. - If string, the name of the file to load the video data from is - defined in it. String is possible only when empty preprocessor is - used. In this case video data is loaded directly from the database. - - **Returns:** - - ``quality_measures`` : FrameContainer - Quality Measures for each frame stored in the FrameContainer. - """ - - if isinstance(frames, six.string_types): # if frames is a path(!) - - video_loader = VideoDataLoader() - - frames = video_loader(frames) # frames is now a FrameContainer - - -# import ipdb; ipdb.set_trace() - - quality_measures = self.video_extractor(frames=frames) - - return quality_measures - - #========================================================================== - 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 b8da75a8a5ce823c348ffa176a4b958fbe6b4aa3..8ea9c9dbc1ff9b5eb7e1ccc9d726132a679cae39 100644 --- a/bob/pad/face/extractor/__init__.py +++ b/bob/pad/face/extractor/__init__.py @@ -1,8 +1,6 @@ from .LBPHistogram import LBPHistogram -from .VideoLBPHistogram import VideoLBPHistogram from .ImageQualityMeasure import ImageQualityMeasure from .VideoDataLoader import VideoDataLoader -from .VideoQualityMeasure import VideoQualityMeasure from .FrameDiffFeatures import FrameDiffFeatures @@ -26,9 +24,7 @@ def __appropriate__(*args): __appropriate__( LBPHistogram, - VideoLBPHistogram, ImageQualityMeasure, - VideoQualityMeasure, VideoDataLoader, FrameDiffFeatures, ) diff --git a/bob/pad/face/test/test.py b/bob/pad/face/test/test.py index c66dadd51834b44d3be17ba5df515d6a01ef59dd..5693bb7fa89f2f775de938ee60d79d78fadf93f7 100644 --- a/bob/pad/face/test/test.py +++ b/bob/pad/face/test/test.py @@ -26,9 +26,9 @@ from ..preprocessor import FrameDifference from ..extractor import FrameDiffFeatures -from ..extractor import VideoLBPHistogram +from ..extractor import LBPHistogram -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure from ..utils import face_detection_utils @@ -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) @@ -369,7 +369,7 @@ def test_video_lbp_histogram(): #============================================================================== def test_video_quality_measure(): """ - Test VideoQualityMeasure extractor. + Test ImageQualityMeasure with Wrapper extractor. """ image = load(datafile('test_image.png', 'bob.pad.face.test')) @@ -381,7 +381,7 @@ def test_video_quality_measure(): MSU = True DTYPE = None - extractor = VideoQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE) + extractor = bob.bio.video.extractor.Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) features = extractor(video)