API details.
indoor_sample_50.h5
was generated from csl_lobby/2020-03-05-16-35-19.bag.export.h5, sliced [0:50*30:30]
data = H5DatasetLoader('../samples/indoor_sample_50.h5')
frame_idx = 1
plt.figure()
plt.imshow(data['rgb'][frame_idx][..., ::-1])
plt.title(f'RGB frame {frame_idx}@{data["rgb_timestamp"][frame_idx]}')
plt.show()
plt.figure()
plt.imshow(data['depth'][frame_idx])
plt.title(f'Depth frame {frame_idx}@{data["depth_timestamp"][frame_idx]}')
plt.show()
Also available as iterator
count = 0
for radar_frame, rgb_frame, depth_frame in progress_bar(data.get_iterator(['radar', 'rgb', 'depth'])):
plt.figure()
plt.subplot(121)
plt.imshow(rgb_frame[:, :, ::-1])
plt.subplot(122)
plt.imshow(depth_frame)
plt.show()
# Stop after 2 frames so we don't spam the docs
count += 1
if count > 1:
break
Default streams can also be set so get_iterator()
isn't required
data = H5DatasetLoader('../samples/indoor_sample_50.h5', default_streams=['radar', 'rgb', 'depth'])
for radar_frame, rgb_frame, depth_frame in progress_bar(data):
np.mean(rgb_frame)
data_multiple_files = H5DatasetLoader(['../samples/indoor_sample_50.h5',
'../samples/indoor_sample_50.h5'],
default_streams=['radar', 'rgb', 'depth'])
assert len(data_multiple_files) == 100
count = 2
for radar_frame, rgb_frame, depth_frame in progress_bar(data_multiple_files):
np.mean(rgb_frame)
if count > 0:
count -= 1
plt.figure()
plt.subplot(121)
plt.imshow(rgb_frame[:, :, ::-1])
plt.subplot(122)
plt.imshow(depth_frame)
plt.show()
PyTorch interface is also available
torch_dataset = data.get_torch_dataset(streams=['rgb', 'radar'])
batch = torch_dataset[1:3]