def test_opencv_decode(self):
        target_keys = ['frame_inds', 'imgs', 'original_shape']

        # test OpenCV with 2 dim input
        video_result = copy.deepcopy(self.video_results)
        video_result['frame_inds'] = np.arange(0, self.total_frames,
                                               2)[:, np.newaxis]
        opencv_init = OpenCVInit()
        opencv_init_result = opencv_init(video_result)
        video_result['video_reader'] = opencv_init_result['video_reader']

        opencv_decode = OpenCVDecode()
        opencv_decode_result = opencv_decode(video_result)
        assert self.check_keys_contain(opencv_decode_result.keys(),
                                       target_keys)
        assert opencv_decode_result['original_shape'] == (256, 340)
        assert np.shape(opencv_decode_result['imgs']) == (len(
            video_result['frame_inds']), 256, 340, 3)

        # test OpenCV with 1 dim input
        video_result = copy.deepcopy(self.video_results)
        video_result['frame_inds'] = np.arange(1, self.total_frames, 3)
        opencv_init = OpenCVInit()
        opencv_init_result = opencv_init(video_result)
        video_result['video_reader'] = opencv_init_result['video_reader']

        opencv_decode = OpenCVDecode()
        opencv_decode_result = opencv_decode(video_result)
        assert self.check_keys_contain(opencv_decode_result.keys(),
                                       target_keys)
        assert opencv_decode_result['original_shape'] == (256, 340)
        assert np.shape(opencv_decode_result['imgs']) == (len(
            video_result['frame_inds']), 256, 340, 3)
Exemple #2
0
 def test_opencv_init(self):
     target_keys = ['new_path', 'video_reader', 'total_frames']
     video_result = copy.deepcopy(self.video_results)
     opencv_init = OpenCVInit()
     opencv_init_result = opencv_init(video_result)
     assert self.check_keys_contain(opencv_init_result.keys(), target_keys)
     assert opencv_init_result['total_frames'] == len(
         opencv_init_result['video_reader'])
Exemple #3
0
 def test_opencv_init(self):
     target_keys = ['new_path', 'video_reader', 'total_frames']
     video_result = copy.deepcopy(self.video_results)
     opencv_init = OpenCVInit()
     opencv_init_result = opencv_init(video_result)
     assert assert_dict_has_keys(opencv_init_result, target_keys)
     assert opencv_init_result['total_frames'] == len(
         opencv_init_result['video_reader'])
     assert repr(opencv_init) == (f'{opencv_init.__class__.__name__}('
                                  f'io_backend=disk)')