|
| 1 | +import unittest |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +from test.testutil import set_default_576_324_videos_for_testing |
| 6 | +from vmaf.third_party.xiph.vmafexec_feature_extractor import PsnrhvsFeatureExtractor |
| 7 | + |
| 8 | + |
| 9 | +class FeatureExtractorTest(unittest.TestCase): |
| 10 | + |
| 11 | + def setUp(self): |
| 12 | + self.verificationErrors = [] |
| 13 | + self.maxDiff = None |
| 14 | + |
| 15 | + def tearDown(self): |
| 16 | + if hasattr(self, 'fextractor'): |
| 17 | + self.fextractor.remove_results() |
| 18 | + pass |
| 19 | + self.assertEqual([], self.verificationErrors) |
| 20 | + |
| 21 | + def test_run_psnrhvs_fextractor(self): |
| 22 | + ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing() |
| 23 | + self.fextractor = PsnrhvsFeatureExtractor( |
| 24 | + [asset, asset_original], |
| 25 | + None, fifo_mode=False, |
| 26 | + result_store=None |
| 27 | + ) |
| 28 | + self.fextractor.run(parallelize=True) |
| 29 | + results = self.fextractor.results |
| 30 | + try: self.assertAlmostEqual(results[0]['PSNRHVS_feature_psnr_hvs_score'], 31.33044560416667, places=4) |
| 31 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 32 | + try: self.assertAlmostEqual(results[0]['PSNRHVS_feature_psnr_hvs_y_score'], 30.578766166666668, places=4) |
| 33 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 34 | + try: self.assertAlmostEqual(results[0]['PSNRHVS_feature_psnr_hvs_cb_score'], 37.25849772916666, places=4) |
| 35 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 36 | + try: self.assertAlmostEqual(results[0]['PSNRHVS_feature_psnr_hvs_cr_score'], 38.2002601875, places=4) |
| 37 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 38 | + try: self.assertAlmostEqual(results[1]['PSNRHVS_feature_psnr_hvs_score'], np.float('inf'), places=4) |
| 39 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 40 | + try: self.assertAlmostEqual(results[1]['PSNRHVS_feature_psnr_hvs_y_score'], np.float('inf'), places=4) |
| 41 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 42 | + try: self.assertAlmostEqual(results[1]['PSNRHVS_feature_psnr_hvs_cb_score'], np.float('inf'), places=4) |
| 43 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
| 44 | + try: self.assertAlmostEqual(results[1]['PSNRHVS_feature_psnr_hvs_cr_score'], np.float('inf'), places=4) |
| 45 | + except AssertionError as e: self.verificationErrors.append(str(e)) |
0 commit comments