|
| 1 | +import pathlib |
1 | 2 | import unittest
|
2 | 3 |
|
3 | 4 | import pytest
|
@@ -31,7 +32,7 @@ def setUp(self):
|
31 | 32 | "properties": {
|
32 | 33 | "mime": "video",
|
33 | 34 | "id": "d1",
|
34 |
| - "location": "file:///home/snewman/Documents/test_vid.mp4" |
| 35 | + "location": f"file://{pathlib.Path(__file__).parent}/black-2997fps.mp4" |
35 | 36 | }
|
36 | 37 | })
|
37 | 38 | self.video_doc.add_property('fps', self.fps)
|
@@ -105,6 +106,23 @@ def test_convert_timeframe(self):
|
105 | 106 | for times in zip((3.337, 6.674), vdh.convert_timeframe(self.mmif_obj, timeframe_ann, 's')):
|
106 | 107 | self.assertAlmostEqual(*times, places=0)
|
107 | 108 |
|
| 109 | + def test_extract_frames_as_images(self): |
| 110 | + frame_list = [5, 10, 15] |
| 111 | + target_images = vdh.extract_frames_as_images(self.video_doc, frame_list, as_PIL=False) |
| 112 | + self.assertEqual(3, len(target_images)) |
| 113 | + # check if the extract_frames_as_images destroy the input frame list |
| 114 | + self.assertEqual(3, len(frame_list)) |
| 115 | + # check return empty list if the frame list is empty |
| 116 | + empty_flist = [] |
| 117 | + empty_target_images = vdh.extract_frames_as_images(self.video_doc, empty_flist, as_PIL=False) |
| 118 | + self.assertEqual([], empty_target_images) |
| 119 | + # check there is an error if there is a frame in the list that does not exist |
| 120 | + tot_fcount = self.video_doc.get_property('frameCount') |
| 121 | + frame_list.append(tot_fcount + 1) |
| 122 | + new_target_images = vdh.extract_frames_as_images(self.video_doc, frame_list, as_PIL=False) |
| 123 | + self.assertEqual(4, len(frame_list)) |
| 124 | + self.assertEqual(3, len(new_target_images)) |
| 125 | + |
108 | 126 |
|
109 | 127 | class TestSequenceHelper(unittest.TestCase):
|
110 | 128 |
|
|
0 commit comments