IMSHOW = True import h5py # path to the HDF5 file dirname = '/mnt/md0/captures/2019May09-rover/camera/' fname = 'images.h5' # open file for reading f = h5py.File(dirname + fname, 'r') # images from the port side camera are named 'port/XXXXXX' # images from the starboard side camera are named 'star/XXXXXX' # # to view the names of all images from the port side camera: # print(f['port'].keys()) # # as an example, we load the images 'port/000500' and 'star/000500' im_port = f['port/000500'] im_star = f['star/000500'] # every image has an attributes dictionary # # the following attributes are available: # 'frame_id' -- frame ID as reported by the camera # 'tstamp' -- UNIX timestamp, seconds since 00:00:00 UTC on 1 Jan 1970 # 'exposure_t' -- image exposure time # # note: calibration images only possess the 'tstamp' attribute port_attrs = im_port.attrs star_attrs = im_star.attrs print('Camera: Port') print(f"Frame ID: {port_attrs['frame_id']}") print(f"UNIX timestamp: {port_attrs['tstamp']}") print(f"Exposure time: {port_attrs['exposure_t']}") print() print('Camera: Starboard') print(f"Frame ID: {star_attrs['frame_id']}") print(f"UNIX timestamp: {star_attrs['tstamp']}") print(f"Exposure time: {star_attrs['exposure_t']}") if IMSHOW: import matplotlib.pyplot as plt fig,(ax0,ax1) = plt.subplots(2, 1, sharex=True, sharey=True, figsize=(16,9)) ax0.imshow(im_port, cmap='gray') ax0.set_title("Camera: Port " + f"Frame ID: {port_attrs['frame_id']}, " + f"UNIX timestamp: {port_attrs['tstamp']}, " + f"Exposure time: {port_attrs['exposure_t']}") ax1.imshow(im_star, cmap='gray') ax1.set_title("Camera: Starboard, " + f"Frame ID: {star_attrs['frame_id']}, " + f"UNIX timestamp: {star_attrs['tstamp']}, " + f"Exposure time: {star_attrs['exposure_t']}") plt.show()