def get_rgbd_file(self, dirname, offset):
associations = self.seq_dir_map[dirname]['associations']
if associations[offset, 1].startswith('depth'):
rgb_filename = os.path.join(dirname, associations[offset, 3])
depth_filename = os.path.join(dirname, associations[offset, 1])
else:
rgb_filename = os.path.join(dirname, associations[offset, 1])
depth_filename = os.path.join(dirname, associations[offset, 3])
rgb_img = ndimage.imread(rgb_filename)
depth_img = ndimage.imread(depth_filename)
width = height = 224
# Reshape
depth_img = np.reshape(depth_img, list(depth_img.shape) + [1])
depth_img = 255 * depth_img / np.max(depth_img)
rgbd_img = np.concatenate((rgb_img, depth_img), 2)
# Resize
rgbd_img = transform.resize(rgbd_img, [width, height], preserve_range=True)
return rgb_filename, depth_filename, rgbd_img.astype(np.float32)
评论列表
文章目录