def open3dVis(self, depth, normal=None, color=None): """Visualize 3d map points from eigen depth Args: depth: depth map normal: normal map color: rgb image """ points = get3dpoints(depth, color) points = np.asarray(points) pcd = PointCloud() pcd.points = Vector3dVector(points) if color is not None: color = np.reshape(color, [-1, 3]) pcd.colors = Vector3dVector(color / 255.) if normal is not None: normal = np.reshape(normal, [-1, 3]) else: _, normal, _ = self.compute_local_planes(points[:, 0], points[:, 1], points[:, 2]) normal = np.reshape(normal, [-1, 3]) pcd.normals = Vector3dVector(normal) draw_geometries([pcd])
def open3dVis(self, data): """Visualize through open3d Args: data: dict containing, input, depth, normal """ pcd = PointCloud() depth = data['depth'][0, 0] xyz, _ = self.get_point_cloud(depth, data['image'][0]) if 'normal' in data.keys(): normals = np.transpose(data['normal'][0], (1, 2, 0)) normals = normals.reshape((-1, 3)) else: _, normals, _ = self.__compute_local_planes( xyz[:, 0], xyz[:, 1], xyz[:, 2]) normals = normals.reshape((-1, 3)) color = np.transpose(data['image'][0], [1, 2, 0]).reshape((-1, 3)) pcd.points = Vector3dVector(xyz) pcd.colors = Vector3dVector(color / 255.) pcd.normals = Vector3dVector(normals) draw_geometries([pcd])
return current_r, current_t # To get the now_pc and next_pc, there are two ways: #(1) you can load from RGBD image by from open3d import Image as IMG from open3d import create_point_cloud_from_rgbd_image, create_rgbd_image_from_color_and_depth, read_pinhole_camera_intrinsic color_image = np.array(Image.open("{0}/rgb/{1}".format(data_root, rgb_name))) depth_im = np.array(Image.open("{0}/depth/{1}".format(data_root, dep_name))) / 1000.0 color_raw = IMG(color_image) depth_raw = IMG(depth_im.astype(np.float32)) rgbd_image = create_rgbd_image_from_color_and_depth( color_raw, depth_raw, depth_scale=1.0, convert_rgb_to_intensity=False) pinhole_camera_intrinsic = read_pinhole_camera_intrinsic("camera_redwood.json") new_pc = create_point_cloud_from_rgbd_image(rgbd_image, pinhole_camera_intrinsic) # you can get the next_pc in the same way #(2) direct change from .xyz from open3d import PointCloud new_pc = PointCloud() new_pc.points = Vector3dVector(verts) new_pc.normals = Vector3dVector(norms) new_pc.colors = Vector3dVector(colors / 255.) # you can get the next_pc in the same way