@@ -105,6 +105,23 @@ def test_convert_timeframe(self):
105
105
for times in zip ((3.337 , 6.674 ), vdh .convert_timeframe (self .mmif_obj , timeframe_ann , 's' )):
106
106
self .assertAlmostEqual (* times , places = 0 )
107
107
108
+ def test_extract_frams_as_images (self ):
109
+ frame_list = [5 , 10 , 15 ]
110
+ target_images = vdh .extract_frames_as_images (self .video_doc , frame_list , as_PIL = False )
111
+ self .assertEqual (3 , len (target_images ))
112
+ # check if the extract_frames_as_images destroy the input frame list
113
+ self .assertEqual (3 , len (frame_list ))
114
+ # check return empty list if the frame list is empty
115
+ empty_flist = []
116
+ empty_target_images = vdh .extract_frames_as_images (self .video_doc , empty_flist , as_PIL = False )
117
+ self .assertEqual ([], empty_target_images )
118
+ # check there is an error if there is a frame in the list that does not exist
119
+ tot_fcount = self .video_doc .get_property ('frameCount' )
120
+ frame_list .append (tot_fcount + 1 )
121
+ new_target_images = vdh .extract_frames_as_images (self .video_doc , frame_list , as_PIL = False )
122
+ self .assertEqual (4 , len (frame_list ))
123
+ self .assertEqual (3 , len (new_target_images ))
124
+
108
125
109
126
class TestSequenceHelper (unittest .TestCase ):
110
127
0 commit comments