API details.
2022-06-07 18:36:52.304104: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2022-06-07 18:36:52.304144: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

class H5DatasetIterator[source]

H5DatasetIterator(dset, streams)

Iterates through aligned frames dataset

class H5DatasetLoader[source]

H5DatasetLoader(filenames, default_streams=None)

A thin wrapper around h5py to provide convenience functions for training

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
2.00% [1/50 00:00<00:12]

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)
94.00% [47/50 00:00<00:00]
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()
87.00% [87/100 00:00<00:00]

PyTorch interface is also available

torch_dataset = data.get_torch_dataset(streams=['rgb', 'radar'])

batch = torch_dataset[1:3]