예제 #1
0
    def _generate_result(self, asset):
        # routine to call the command-line executable and generate quality
        # scores in the log file.

        ref_workfile_path = asset.ref_workfile_path
        dis_workfile_path = asset.dis_workfile_path
        log_file_path = self._get_log_file_path(asset)

        current_dir = os.getcwd() + '/'

        ref_workfile_path = make_absolute_path(ref_workfile_path, current_dir)
        dis_workfile_path = make_absolute_path(dis_workfile_path, current_dir)
        log_file_path = make_absolute_path(log_file_path, current_dir)

        quality_width, quality_height = asset.quality_width_height

        strred_cmd = '''{matlab} -nodisplay -nosplash -nodesktop -r "run_strred('{ref}', '{dis}', {h}, {w}); exit;" >> {log_file_path}'''.format(
            matlab=VmafExternalConfig.get_and_assert_matlab(),
            ref=ref_workfile_path,
            dis=dis_workfile_path,
            w=quality_width,
            h=quality_height,
            log_file_path=log_file_path,
        )
        if self.logger:
            self.logger.info(strred_cmd)

        os.chdir(self.MATLAB_WORKSPACE)
        run_process(strred_cmd, shell=True)
        os.chdir(current_dir)
예제 #2
0
    def _generate_result(self, asset):
        # routine to call the command-line executable and generate quality
        # scores in the log file.

        ref_workfile_path = asset.ref_workfile_path
        dis_workfile_path = asset.dis_workfile_path
        log_file_path = self._get_log_file_path(asset)

        current_dir = os.getcwd() + '/'

        ref_workfile_path = make_absolute_path(ref_workfile_path, current_dir)
        dis_workfile_path = make_absolute_path(dis_workfile_path, current_dir)
        log_file_path = make_absolute_path(log_file_path, current_dir)

        quality_width, quality_height = asset.quality_width_height

        strred_cmd = '''{matlab} -nodisplay -nosplash -nodesktop -r "run_strred('{ref}', '{dis}', {h}, {w}); exit;" >> {log_file_path}'''.format(
            matlab=VmafExternalConfig.get_and_assert_matlab(),
            ref=ref_workfile_path,
            dis=dis_workfile_path,
            w=quality_width,
            h=quality_height,
            log_file_path=log_file_path,
        )
        if self.logger:
            self.logger.info(strred_cmd)

        os.chdir(self.MATLAB_WORKSPACE)
        run_process(strred_cmd, shell=True)
        os.chdir(current_dir)
예제 #3
0
    def _assert_an_asset(cls, asset):

        # needed by _generate_result, and by _open_dis_workfile if called
        assert asset.quality_width_height is not None

        if cls._need_ffmpeg(asset):
            VmafExternalConfig.get_and_assert_ffmpeg()

        # if crop_cmd or pad_cmd or etc. is specified, make sure quality_width and
        # quality_height are EXPLICITLY specified in asset_dict
        if asset.dis_crop_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If crop_cmd etc. is specified, must also EXPLICITLY specify quality_width and quality_height.'
        if asset.dis_pad_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If pad_cmd etc. is specified, must also EXPLICITLY specify quality_width and quality_height.'
예제 #4
0
파일: executor.py 프로젝트: stoth68000/vmaf
    def _assert_an_asset(cls, asset):

        # needed by _generate_result, and by _open_dis_workfile if called
        assert asset.quality_width_height is not None

        if cls._need_ffmpeg(asset):
            VmafExternalConfig.get_and_assert_ffmpeg()

        # if crop_cmd or pad_cmd is specified, make sure quality_width and
        # quality_height are EXPLICITLY specified in asset_dict
        if asset.crop_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If crop_cmd is specified, must also EXPLICITLY specify quality_width and quality_height.'
        if asset.pad_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If pad_cmd is specified, must also EXPLICITLY specify quality_width and quality_height.'
예제 #5
0
    def _custom_init(self):
        def run_stmad_cmd(stmad_cmd):

            current_dir = os.getcwd() + '/'
            os.chdir(self.MATLAB_WORKSPACE)
            run_process(stmad_cmd, shell=True)
            os.chdir(current_dir)

        stmad_mex_cmd_1 = '''{matlab} -nodisplay -nosplash -nodesktop -r "mex ical_std.c; exit;"'''.format(
            matlab=VmafExternalConfig.get_and_assert_matlab(), )

        run_stmad_cmd(stmad_mex_cmd_1)

        stmad_mex_cmd_2 = '''{matlab} -nodisplay -nosplash -nodesktop -r "mex ical_stat.c; exit;"'''.format(
            matlab=VmafExternalConfig.get_and_assert_matlab(), )

        run_stmad_cmd(stmad_mex_cmd_2)
예제 #6
0
파일: executor.py 프로젝트: zzzazzzz/vmaf
    def _open_ref_workfile(self, asset, fifo_mode):
        # For now, only works for YUV format -- all need is to copy from ref
        # file to ref workfile

        # only need to open ref workfile if the path is different from ref path
        assert asset.use_path_as_workpath is False and asset.ref_path != asset.ref_workfile_path

        # if fifo mode, mkfifo
        if fifo_mode:
            os.mkfifo(asset.ref_workfile_path)

        quality_width, quality_height = self._get_quality_width_height(asset)
        yuv_type = asset.ref_yuv_type
        resampling_type = self._get_resampling_type(asset)

        if yuv_type != 'notyuv':
            # in this case, for sure has ref_width_height
            width, height = asset.ref_width_height
            src_fmt_cmd = self._get_yuv_src_fmt_cmd(asset, height, width,
                                                    'ref')
        else:
            src_fmt_cmd = self._get_notyuv_src_fmt_cmd(asset, 'ref')

        workfile_yuv_type = self._get_workfile_yuv_type(asset)

        vframes_cmd, select_cmd = self._get_vframes_cmd(asset, 'ref')
        crop_cmd = self._get_filter_cmd(asset, 'crop', 'ref')
        pad_cmd = self._get_filter_cmd(asset, 'pad', 'ref')
        scale_cmd = 'scale={width}x{height}'.format(width=quality_width,
                                                    height=quality_height)

        filter_cmds = []
        for key in Asset.ORDERED_FILTER_LIST:
            if key is not 'crop' and key is not 'pad':
                filter_cmds.append(self._get_filter_cmd(asset, key, 'ref'))

        vf_cmd = ','.join(
            filter(lambda s: s != '',
                   [select_cmd, crop_cmd, pad_cmd, scale_cmd] + filter_cmds))

        ffmpeg_cmd = '{ffmpeg} {src_fmt_cmd} -i {src} -an -vsync 0 ' \
                     '-pix_fmt {yuv_type} {vframes_cmd} -vf {vf_cmd} -f rawvideo ' \
                     '-sws_flags {resampling_type} -y {dst}'
        ffmpeg_cmd = ffmpeg_cmd.format(
            ffmpeg=VmafExternalConfig.get_and_assert_ffmpeg(),
            src=asset.ref_path,
            dst=asset.ref_workfile_path,
            src_fmt_cmd=src_fmt_cmd,
            vf_cmd=vf_cmd,
            yuv_type=workfile_yuv_type,
            resampling_type=resampling_type,
            vframes_cmd=vframes_cmd,
        )

        if self.logger:
            self.logger.info(ffmpeg_cmd)

        run_process(ffmpeg_cmd, shell=True)
예제 #7
0
    def _open_dis_workfile(self, asset, fifo_mode):
        # For now, only works for YUV format -- all need is to copy from dis
        # file to dis workfile

        # only need to open dis workfile if the path is different from dis path
        assert asset.use_path_as_workpath is False and asset.dis_path != asset.dis_workfile_path

        # if fifo mode, mkfifo
        if fifo_mode:
            os.mkfifo(asset.dis_workfile_path)

        quality_width, quality_height = self._get_quality_width_height(asset)
        yuv_type = asset.dis_yuv_type
        resampling_type = self._get_resampling_type(asset)

        if yuv_type != 'notyuv':
            # in this case, for sure has dis_width_height
            width, height = asset.dis_width_height
            src_fmt_cmd = self._get_yuv_src_fmt_cmd(asset, height, width,
                                                    'dis')
        else:
            src_fmt_cmd = self._get_notyuv_src_fmt_cmd(asset, 'dis')

        workfile_yuv_type = self._get_workfile_yuv_type(asset)

        crop_cmd = self._get_dis_crop_cmd(asset)
        pad_cmd = self._get_dis_pad_cmd(asset)
        gblur_cmd = self._get_dis_gblur_cmd(asset)

        vframes_cmd, select_cmd = self._get_vframes_cmd(asset, 'dis')

        scale_cmd = 'scale={width}x{height}'.format(width=quality_width,
                                                    height=quality_height)

        vf_cmd = ','.join(
            filter(lambda s: s != '',
                   [select_cmd, crop_cmd, pad_cmd, scale_cmd, gblur_cmd]))

        ffmpeg_cmd = '{ffmpeg} {src_fmt_cmd} -i {src} -an -vsync 0 ' \
                     '-pix_fmt {yuv_type} {vframes_cmd} -vf {vf_cmd} -f rawvideo ' \
                     '-sws_flags {resampling_type} -y {dst}'.format(
            ffmpeg=VmafExternalConfig.get_and_assert_ffmpeg(),
            src=asset.dis_path, dst=asset.dis_workfile_path,
            src_fmt_cmd=src_fmt_cmd,
            vf_cmd=vf_cmd,
            yuv_type=workfile_yuv_type,
            resampling_type=resampling_type,
            vframes_cmd=vframes_cmd,
        )

        if self.logger:
            self.logger.info(ffmpeg_cmd)

        run_process(ffmpeg_cmd, shell=True)
예제 #8
0
    def _assert_an_asset(cls, asset):

        # needed by _generate_result, and by _open_ref_workfile or
        # _open_dis_workfile if called
        assert asset.quality_width_height is not None

        # if quality width/height do not to agree with ref/dis width/height,
        # must rely on ffmpeg for scaling
        if cls._need_ffmpeg(asset):
            VmafExternalConfig.get_and_assert_ffmpeg()

        # if crop_cmd or pad_cmd is specified, make sure quality_width and
        # quality_height are EXPLICITLY specified in asset_dict
        if asset.crop_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If crop_cmd is specified, must also EXPLICITLY specify quality_width and quality_height.'
        if asset.pad_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If pad_cmd is specified, must also EXPLICITLY specify quality_width and quality_height.'

        pass
예제 #9
0
파일: executor.py 프로젝트: jegusan/vmaf
    def _open_ref_workfile(self, asset, fifo_mode):
        # For now, only works for YUV format -- all need is to copy from ref
        # file to ref workfile

        # only need to open ref workfile if the path is different from ref path
        assert asset.use_path_as_workpath is False and asset.ref_path != asset.ref_workfile_path

        # if fifo mode, mkfifo
        if fifo_mode:
            os.mkfifo(asset.ref_workfile_path)

        quality_width, quality_height = asset.quality_width_height
        yuv_type = asset.ref_yuv_type
        resampling_type = asset.resampling_type

        if yuv_type != 'notyuv':
            # in this case, for sure has ref_width_height
            width, height = asset.ref_width_height
            src_fmt_cmd = self._get_yuv_src_fmt_cmd(asset, height, width,
                                                    'ref')
        else:
            src_fmt_cmd = self._get_notyuv_src_fmt_cmd(asset, 'ref')

        workfile_yuv_type = self._get_workfile_yuv_type(asset)

        crop_cmd = self._get_crop_cmd(asset)
        pad_cmd = self._get_pad_cmd(asset)

        vframes_cmd, select_cmd = self._get_vframes_cmd(asset, 'ref')

        ffmpeg_cmd = '{ffmpeg} {src_fmt_cmd} -i {src} -an -vsync 0 ' \
                     '-pix_fmt {yuv_type} {vframes_cmd} -vf {select_cmd}{crop_cmd}{pad_cmd}scale={width}x{height} -f rawvideo ' \
                     '-sws_flags {resampling_type} -y {dst}'
        ffmpeg_cmd = ffmpeg_cmd.format(
            ffmpeg=VmafExternalConfig.get_and_assert_ffmpeg(),
            src=asset.ref_path,
            dst=asset.ref_workfile_path,
            width=quality_width,
            height=quality_height,
            src_fmt_cmd=src_fmt_cmd,
            crop_cmd=crop_cmd,
            pad_cmd=pad_cmd,
            yuv_type=workfile_yuv_type,
            resampling_type=resampling_type,
            vframes_cmd=vframes_cmd,
            select_cmd=select_cmd,
        )

        if self.logger:
            self.logger.info(ffmpeg_cmd)

        run_process(ffmpeg_cmd, shell=True)
예제 #10
0
파일: executor.py 프로젝트: zzzazzzz/vmaf
    def _assert_an_asset(cls, asset):

        # needed by _generate_result, and by _open_ref_workfile or
        # _open_dis_workfile if called
        assert asset.quality_width_height is not None

        if cls._need_ffmpeg(asset):
            VmafExternalConfig.get_and_assert_ffmpeg()

        # ref_yuv_type and dis_yuv_type must match, unless any of them is notyuv.
        # also check the logic in _get_workfile_yuv_type
        assert (asset.ref_yuv_type == 'notyuv' or asset.dis_yuv_type == 'notyuv') \
               or (asset.ref_yuv_type == asset.dis_yuv_type)

        # if crop_cmd or pad_cmd or etc. is specified, make sure quality_width and
        # quality_height are EXPLICITLY specified in asset_dict
        if asset.ref_crop_cmd is not None or asset.dis_crop_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If crop_cmd or etc. is specified, must also EXPLICITLY specify quality_width and quality_height.'
        if asset.ref_pad_cmd is not None or asset.dis_pad_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If pad_cmd or etc. is specified, must also EXPLICITLY specify quality_width and quality_height.'
예제 #11
0
파일: executor.py 프로젝트: stoth68000/vmaf
    def _assert_an_asset(cls, asset):

        # needed by _generate_result, and by _open_ref_workfile or
        # _open_dis_workfile if called
        assert asset.quality_width_height is not None

        if cls._need_ffmpeg(asset):
            VmafExternalConfig.get_and_assert_ffmpeg()

        # ref_yuv_type and dis_yuv_type must match, unless any of them is notyuv.
        # also check the logic in _get_workfile_yuv_type
        assert (asset.ref_yuv_type == 'notyuv' or asset.dis_yuv_type == 'notyuv') \
               or (asset.ref_yuv_type == asset.dis_yuv_type)

        # if crop_cmd or pad_cmd is specified, make sure quality_width and
        # quality_height are EXPLICITLY specified in asset_dict
        if asset.crop_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If crop_cmd is specified, must also EXPLICITLY specify quality_width and quality_height.'
        if asset.pad_cmd is not None:
            assert 'quality_width' in asset.asset_dict and 'quality_height' in asset.asset_dict, \
                'If pad_cmd is specified, must also EXPLICITLY specify quality_width and quality_height.'
예제 #12
0
파일: executor.py 프로젝트: stoth68000/vmaf
    def _open_ref_workfile(self, asset, fifo_mode):
        # For now, only works for YUV format -- all need is to copy from ref
        # file to ref workfile

        # only need to open ref workfile if the path is different from ref path
        assert asset.use_path_as_workpath is False and asset.ref_path != asset.ref_workfile_path

        # if fifo mode, mkfifo
        if fifo_mode:
            os.mkfifo(asset.ref_workfile_path)

        quality_width, quality_height = self._get_quality_width_height(asset)
        yuv_type = asset.ref_yuv_type
        resampling_type = self._get_resampling_type(asset)

        if yuv_type != 'notyuv':
            # in this case, for sure has ref_width_height
            width, height = asset.ref_width_height
            src_fmt_cmd = self._get_yuv_src_fmt_cmd(asset, height, width, 'ref')
        else:
            src_fmt_cmd = self._get_notyuv_src_fmt_cmd(asset, 'ref')

        workfile_yuv_type = self._get_workfile_yuv_type(asset)

        crop_cmd = self._get_crop_cmd(asset)
        pad_cmd = self._get_pad_cmd(asset)

        vframes_cmd, select_cmd = self._get_vframes_cmd(asset, 'ref')

        ffmpeg_cmd = '{ffmpeg} {src_fmt_cmd} -i {src} -an -vsync 0 ' \
                     '-pix_fmt {yuv_type} {vframes_cmd} -vf {select_cmd}{crop_cmd}{pad_cmd}scale={width}x{height} -f rawvideo ' \
                     '-sws_flags {resampling_type} -y {dst}'
        ffmpeg_cmd = ffmpeg_cmd.format(
            ffmpeg=VmafExternalConfig.get_and_assert_ffmpeg(),
            src=asset.ref_path,
            dst=asset.ref_workfile_path,
            width=quality_width,
            height=quality_height,
            src_fmt_cmd=src_fmt_cmd,
            crop_cmd=crop_cmd,
            pad_cmd=pad_cmd,
            yuv_type=workfile_yuv_type,
            resampling_type=resampling_type,
            vframes_cmd=vframes_cmd,
            select_cmd=select_cmd,
        )

        if self.logger:
            self.logger.info(ffmpeg_cmd)

        run_process(ffmpeg_cmd, shell=True)
예제 #13
0
class NorefFeatureExtractorTest(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, 'fextractor'):
            self.fextractor.remove_results()
            pass

    @unittest.skipIf('apps' in VmafExternalConfig.ffmpeg_path(),
                     'ffmpeg should not be in apps')
    def test_noref_moment_fextractor_with_noref_asset_notyuv_gaussianblur(
            self):

        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = NorefAsset(dataset="test",
                           content_id=0,
                           asset_id=0,
                           workdir_root=VmafConfig.workdir_path(),
                           dis_path=dis_path,
                           asset_dict={
                               'yuv_type': 'notyuv',
                               'quality_width': 720,
                               'quality_height': 480,
                               'gblur_cmd': 'sigma=0.01:steps=1',
                           })

        self.fextractor = MomentNorefFeatureExtractor([asset],
                                                      None,
                                                      fifo_mode=False,
                                                      result_store=None)
        self.fextractor.run()

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['Moment_noref_feature_1st_score'],
                               63.25902145061728,
                               places=4)
        self.assertAlmostEqual(results[0]['Moment_noref_feature_2nd_score'],
                               5123.705637307099,
                               places=4)
        self.assertAlmostEqual(results[0]['Moment_noref_feature_var_score'],
                               1113.0346638689637,
                               places=4)
예제 #14
0
from __future__ import absolute_import

import unittest

from vmaf.config import VmafConfig, VmafExternalConfig
from vmaf.core.asset import Asset, NorefAsset
from vmaf.core.feature_extractor import VmafFeatureExtractor
from vmaf.core.noref_feature_extractor import MomentNorefFeatureExtractor
from vmaf.core.quality_runner import VmafQualityRunner, PsnrQualityRunner
from vmaf.core.result_store import FileSystemResultStore

if __name__ == '__main__':
    unittest.main(verbosity=2)


@unittest.skipIf(not VmafExternalConfig.ffmpeg_path()
                 or 'apps' in VmafExternalConfig.ffmpeg_path(),
                 'ffmpeg not installed or ffmpeg should not be in apps')
class ParallelFeatureExtractorTestNew(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, 'fextractor'):
            self.fextractor.remove_results()
        pass

    def test_run_vmaf_fextractor_with_gaussian_blurring(self):

        ref_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc01_576x324.yuv")
        asset = Asset(dataset="test",
import sys
import unittest

from vmaf.config import VmafConfig, VmafExternalConfig
from vmaf.core.asset import NorefAsset
from vmaf.core.noref_feature_extractor import MomentNorefFeatureExtractor

__copyright__ = "Copyright 2016-2020, Netflix, Inc."
__license__ = "BSD+Patent"


@unittest.skipIf(not VmafExternalConfig.ffmpeg_path(), "ffmpeg not installed")
class NorefFeatureExtractorTest(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, 'fextractor'):
            self.fextractor.remove_results()
            pass

    def test_noref_moment_fextractor_with_noref_asset_notyuv(self):

        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = NorefAsset(dataset="test",
                           content_id=0,
                           asset_id=0,
                           workdir_root=VmafConfig.workdir_path(),
                           dis_path=dis_path,
                           asset_dict={
                               'yuv_type': 'notyuv',
                               'quality_width': 720,
                               'quality_height': 480,
예제 #16
0
class ParallelFeatureExtractorTestNew(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, 'fextractor'):
            self.fextractor.remove_results()
        pass

    @unittest.skipIf('apps' in VmafExternalConfig.ffmpeg_path(),
                     'ffmpeg should not be in apps')
    def test_run_vmaf_fextractor_with_gaussian_blurring(self):

        ref_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc01_576x324.yuv")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=1,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'width': 576,
                          'height': 324,
                          'crop_cmd': '288:162:144:81',
                          'dis_gblur_cmd': 'sigma=0.01:steps=1',
                          'quality_width': 288,
                          'quality_height': 162,
                      })

        asset_original = Asset(dataset="test",
                               content_id=0,
                               asset_id=2,
                               workdir_root=VmafConfig.workdir_path(),
                               ref_path=ref_path,
                               dis_path=ref_path,
                               asset_dict={
                                   'width': 576,
                                   'height': 324,
                                   'crop_cmd': '288:162:144:81',
                                   'dis_gblur_cmd': 'sigma=0.01:steps=2',
                                   'quality_width': 288,
                                   'quality_height': 162,
                               })

        self.fextractor = VmafFeatureExtractor([asset, asset_original],
                                               None,
                                               fifo_mode=True)

        self.fextractor.run(parallelize=True)

        results = self.fextractor.results

        self.assertAlmostEqual(results[0]['VMAF_feature_vif_score'],
                               0.45136466666666664,
                               places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_motion_score'],
                               2.8779373333333331,
                               places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_adm2_score'],
                               0.9362876630569382,
                               places=4)
        self.assertAlmostEqual(results[0]['VMAF_feature_ansnr_score'],
                               24.110899416666665,
                               places=4)

        self.assertAlmostEqual(results[1]['VMAF_feature_vif_score'],
                               0.9789283541666666,
                               places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_motion_score'],
                               2.8779373333333331,
                               places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_adm2_score'],
                               0.9958889086049826,
                               places=4)
        self.assertAlmostEqual(results[1]['VMAF_feature_ansnr_score'],
                               31.128021979166665,
                               places=4)
예제 #17
0
 def _assert_class(cls):
     # override Executor._assert_class
     super(MatlabFeatureExtractor, cls)._assert_class()
     VmafExternalConfig.get_and_assert_matlab()
예제 #18
0
 def _assert_class(cls):
     # override Executor._assert_class
     super(MatlabFeatureExtractor, cls)._assert_class()
     VmafExternalConfig.get_and_assert_matlab()
예제 #19
0
                           'dis_start_frame': 6,
                           'dis_end_frame': 6,
                       })
        self.runner = PsnrQualityRunner([asset, asset2],
                                        None,
                                        fifo_mode=True,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run(parallelize=False)

        results = self.runner.results
        self.assertAlmostEqual(results[0]['PSNR_score'], 30.993823, places=4)
        self.assertAlmostEqual(results[1]['PSNR_score'], 19.393160, places=4)


@unittest.skipIf(not VmafExternalConfig.matlab_path(), "matlab not installed")
class ParallelMatlabQualityRunnerTest(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, 'runner'):
            self.runner.remove_results()
            pass

    def setUp(self):
        self.result_store = FileSystemResultStore()

    def test_run_strrred_runner(self):
        print 'test on running STRRED runner...'
        ref_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc01_576x324.yuv")
예제 #20
0
class QualityRunnerTest(unittest.TestCase):
    def tearDown(self):
        if hasattr(self, 'runner'):
            self.runner.remove_results()
            pass

    def setUp(self):
        self.result_store = FileSystemResultStore()

    @unittest.skipIf('apps' in VmafExternalConfig.ffmpeg_path(),
                     'ffmpeg should not be in apps')
    def test_run_psnr_runner_with_notyuv_gblur(self):

        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 720,
                          'quality_height': 480,
                          'dis_gblur_cmd': 'sigma=0.01:steps=1',
                      })
        self.runner = PsnrQualityRunner([asset],
                                        None,
                                        fifo_mode=False,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['PSNR_score'],
                               50.99313338666667,
                               places=4)

    @unittest.skipIf('apps' in VmafExternalConfig.ffmpeg_path(),
                     'ffmpeg should not be in apps')
    def test_run_vmaf_runner_with_notyuv_gblur(self):

        ref_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_30_480_1050.mp4")
        dis_path = VmafConfig.test_resource_path("mp4",
                                                 "Seeking_10_288_375.mp4")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'yuv_type': 'notyuv',
                          'quality_width': 360,
                          'quality_height': 240,
                          'dis_gblur_cmd': 'sigma=0.01:steps=1',
                      })
        self.runner = VmafQualityRunner([asset],
                                        None,
                                        fifo_mode=True,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'],
                               77.28938600125885,
                               places=4)

    def test_run_vmaf_runner_with_yuv_lutyuv(self):
        ref_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc00_576x324.yuv")
        dis_path = VmafConfig.test_resource_path("yuv",
                                                 "src01_hrc01_576x324.yuv")
        asset = Asset(dataset="test",
                      content_id=0,
                      asset_id=0,
                      workdir_root=VmafConfig.workdir_path(),
                      ref_path=ref_path,
                      dis_path=dis_path,
                      asset_dict={
                          'width': 576,
                          'height': 324,
                          'quality_width': 360,
                          'quality_height': 240,
                          'lutyuv_cmd': 'y=2*val',
                      })
        self.runner = VmafQualityRunner([asset],
                                        None,
                                        fifo_mode=False,
                                        delete_workdir=True,
                                        result_store=None)
        self.runner.run()

        results = self.runner.results
        self.assertAlmostEqual(results[0]['VMAF_score'],
                               77.18873019841408,
                               places=4)