25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

51 satır
1.8 KiB

  1. """test_feature_extractors_functional.py -- functional tests for feature extractors
  2. This module contains functional tests for FEs using crafted and/or generated media files
  3. to verify that the FEs are working as expected:
  4. - laughter detection -- uses videos with laughs at known times
  5. - video activity -- uses videos with visual activity at known times
  6. - audio loudness -- uses videos with audio at known times
  7. etc.
  8. These tests are marked slow to avoid running them during normal test runs.
  9. """
  10. import unittest
  11. import pipeline.feature_extractors as extractors
  12. import test.mocks as mocks
  13. class FEFunctionalTest(unittest.TestCase):
  14. """FEFunctionalTest -- base class for functional tests for feature extractors
  15. """
  16. SAMPLE_DIR = "/home/robert/code/softdev2023-24/summerproject/highlights/test/sample_videos"
  17. class TestVideoActivityFEFunctional(FEFunctionalTest):
  18. """TestVisualActivityFEFunctional -- functional tests for visual activity feature extractor
  19. """
  20. def test_visual_activity_functional(self):
  21. """Test visual activity feature extractor
  22. use:
  23. - sample_videos/sample-manual-visualactivity.mp4 :: activity at 15-20s -- pass if activity detected anywhere in this range
  24. """
  25. SAMPLE_VIDEO = f"{self.SAMPLE_DIR}/sample-manual-visualactivity.mp4"
  26. START_TIME = 15
  27. END_TIME = 20
  28. # create mock source with the video
  29. source = mocks.MockSource(path=SAMPLE_VIDEO)
  30. # create the feature extractor
  31. testfe = extractors.VideoActivityFeatureExtractor(input_files=[source])
  32. testfe.setup()
  33. testfe.run()
  34. testfe.teardown()
  35. # check if the feature was extracted:
  36. self.assertTrue(testfe.features)
  37. # check if the feature interval is within the expected range
  38. self.assertTrue(testfe.features[0].interval.start >= START_TIME)