Skip to content

Commit

Permalink
[Enhance]: use JPEG format in waymo convert when saving images to red…
Browse files Browse the repository at this point in the history
…uce storage (#1759)
  • Loading branch information
zzj403 authored and ZwwWayne committed Dec 16, 2022
1 parent d6a1593 commit 9689a65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion tools/data_converter/kitti_data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def get_image_path(idx,
relative_path=True,
exist_check=True,
info_type='image_2',
file_tail='.png',
use_prefix_id=False):
return get_kitti_info_path(idx, prefix, info_type, '.png', training,
return get_kitti_info_path(idx, prefix, info_type, file_tail, training,
relative_path, exist_check, use_prefix_id)


Expand Down Expand Up @@ -378,6 +379,7 @@ def gather_single(self, idx):
self.training,
self.relative_path,
info_type='image_0',
file_tail='.jpg',
use_prefix_id=True)
if self.with_imageshape:
img_path = image_info['image_path']
Expand Down
10 changes: 6 additions & 4 deletions tools/data_converter/waymo_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def __len__(self):
return len(self.tfrecord_pathnames)

def save_image(self, frame, file_idx, frame_idx):
"""Parse and save the images in png format.
"""Parse and save the images in jpg format. Jpg is the original format
used by Waymo Open dataset. Saving in png format will cause huge (~3x)
unnesssary storage waste.
Args:
frame (:obj:`Frame`): Open dataset frame proto.
Expand All @@ -140,9 +142,9 @@ def save_image(self, frame, file_idx, frame_idx):
for img in frame.images:
img_path = f'{self.image_save_dir}{str(img.name - 1)}/' + \
f'{self.prefix}{str(file_idx).zfill(3)}' + \
f'{str(frame_idx).zfill(3)}.png'
img = mmcv.imfrombytes(img.image)
mmcv.imwrite(img, img_path)
f'{str(frame_idx).zfill(3)}.jpg'
with open(img_path, 'wb') as fp:
fp.write(img.image)

def save_calib(self, frame, file_idx, frame_idx):
"""Parse and save the calibration data.
Expand Down

0 comments on commit 9689a65

Please sign in to comment.