fileio_tests.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:GulpIO 作者: TwentyBN 项目源码 文件源码
def test_read_frames_fixed_length(self):
        # use 'write_frame' to write a single image
        self.gulp_chunk.meta_dict = OrderedDict()
        self.gulp_chunk.fp = BytesIO()
        image = np.ones((1, 4), dtype='uint8')
        with mock.patch('cv2.imencode') as imencode_mock:
            imencode_mock.return_value = '', np.ones((1, 4), dtype='uint8')
            self.gulp_chunk._write_frame(0, image)
        self.gulp_chunk.meta_dict['0']['meta_data'].append({})
        with mock.patch('cv2.imdecode', lambda x, y:
                        np.array(x).reshape((1, 4))):
            with mock.patch('cv2.cvtColor', lambda x, y: x):
                # recover the single frame using 'read'
                frames, meta = self.gulp_chunk.read_frames('0')
        npt.assert_array_equal(image, np.array(frames[0]))
        self.assertEqual({}, meta)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号