def get_heightmap(self, obs, configs): """Reconstruct orthographic heightmaps with segmentation masks.""" heightmaps, colormaps = utils.reconstruct_heightmaps( obs['color'], obs['depth'], configs, self.bounds, self.pixel_size) colormaps = np.float32(colormaps) heightmaps = np.float32(heightmaps) # Fuse maps from different views. valid = np.sum(colormaps, axis=3) > 0 repeat = np.sum(valid, axis=0) repeat[repeat == 0] = 1 colormap = np.sum(colormaps, axis=0) / repeat[Ellipsis, None] colormap = np.uint8(np.round(colormap)) heightmap = np.max(heightmaps, axis=0) return colormap, heightmap
def get_heightmap(obs): """Following same implementation as in transporter.py.""" heightmaps, colormaps = U.reconstruct_heightmaps(obs['color'], obs['depth'], CAMERA_CONFIG, BOUNDS, PIXEL_SIZE) colormaps = np.float32(colormaps) heightmaps = np.float32(heightmaps) # Fuse maps from different views. valid = np.sum(colormaps, axis=3) > 0 repeat = np.sum(valid, axis=0) repeat[repeat == 0] = 1 colormap = np.sum(colormaps, axis=0) / repeat[..., None] colormap = np.uint8(np.round(colormap)) heightmap = np.max(heightmaps, axis=0) return colormap, heightmap
def get_true_image(self, env): """Get RGB-D orthographic heightmaps and segmentation masks.""" # Capture near-orthographic RGB-D images and segmentation masks. color, depth, segm = env.render(self.oracle_cams[0]) # Combine color with masks for faster processing. color = np.concatenate((color, segm[Ellipsis, None]), axis=2) # Reconstruct real orthographic projection from point clouds. hmaps, cmaps = utils.reconstruct_heightmaps( [color], [depth], self.oracle_cams, self.bounds, self.pix_size) # Split color back into color and masks. cmap = np.uint8(cmaps)[0, Ellipsis, :3] hmap = np.float32(hmaps)[0, Ellipsis] mask = np.int32(cmaps)[0, Ellipsis, 3:].squeeze() return cmap, hmap, mask
def get_heightmap(obs): """Reconstruct orthographic heightmaps with segmentation masks. Here, `obs` could be current or goal, either will work. See transporter.py, regression.py, task.py, dummy.py, and dataset.py. We use this pattern quite a lot. Copy from transporter.py version. """ heightmaps, colormaps = U.reconstruct_heightmaps(obs['color'], obs['depth'], CAMERA_CONFIG, BOUNDS, PIXEL_SIZE) colormaps = np.float32(colormaps) heightmaps = np.float32(heightmaps) # Fuse maps from different views. valid = np.sum(colormaps, axis=3) > 0 repeat = np.sum(valid, axis=0) repeat[repeat == 0] = 1 colormap = np.sum(colormaps, axis=0) / repeat[..., None] colormap = np.uint8(np.round(colormap)) heightmap = np.max(heightmaps, axis=0) return colormap, heightmap