Skip to content

Commit

Permalink
Image copying in CVAT format (cvat-ai#2091)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max authored Sep 2, 2020
1 parent e52ff96 commit ae6ec40
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cvat/apps/dataset_manager/formats/cvat.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,16 @@ def _export(dst_file, task_data, anno_callback, save_images=False):
frame_provider = FrameProvider(task_data.db_task.data)
frames = frame_provider.get_frames(
frame_provider.Quality.ORIGINAL,
frame_provider.Type.NUMPY_ARRAY)
frame_provider.Type.BUFFER)
for frame_id, (frame_data, _) in enumerate(frames):
frame_name = task_data.frame_info[frame_id]['path']
if '.' in frame_name:
save_image(osp.join(img_dir, frame_name),
frame_data, jpeg_quality=100, create_dir=True)
else:
save_image(osp.join(img_dir, frame_name + '.png'),
frame_data, create_dir=True)
ext = ''
if not '.' in osp.basename(frame_name):
ext = '.png'
img_path = osp.join(img_dir, frame_name + ext)
os.makedirs(osp.dirname(img_path), exist_ok=True)
with open(img_path, 'wb') as f:
f.write(frame_data.getvalue())

make_zip_archive(temp_dir, dst_file)

Expand Down

0 comments on commit ae6ec40

Please sign in to comment.