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/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/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..e754647bb26ad991aa003f41e4817c592e1be35e 100644 --- a/bob/pad/face/extractor/__init__.py +++ b/bob/pad/face/extractor/__init__.py @@ -2,7 +2,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 @@ -28,7 +27,6 @@ __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..ac4e429718b988b032962b53060641b6e68965f7 100644 --- a/bob/pad/face/test/test.py +++ b/bob/pad/face/test/test.py @@ -28,7 +28,7 @@ from ..extractor import FrameDiffFeatures from ..extractor import VideoLBPHistogram -from ..extractor import VideoQualityMeasure +from ..extractor import ImageQualityMeasure from ..utils import face_detection_utils @@ -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)