Visualizing zed2i pointcloud using o3d

Hey everyone!

As the title implies, I’m currently trying to visualize zed pointcloud data using o3d in real time. At the moment, the visualizer only displays a blank white screen. I can’t seem to find any information on this online however, the code I’m using is below.

The end goal is to be able to use the pointcloud data in open3D. I originally tried to use ROS2 foxy, however, I couldn’t find a way to convert PointCloud2 data to something usable for open3d.

import as sl
import open3d as o3d

# Initialize the ZED camera
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD720  # Set your desired resolution
zed = sl.Camera()
if not zed.is_opened():

# Create an Open3D visualizer
vis = o3d.visualization.Visualizer()

    while True:
        # Capture a frame
        runtime_parameters = sl.RuntimeParameters()
        if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
            # Retrieve the point cloud
            point_cloud = sl.Mat()
            zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)

            # Get the point cloud data as a numpy array
            point_cloud_data = point_cloud.get_data()

            # Extract the XYZ data
            xyz_data = point_cloud_data[:, :, :3]
            xyz_data = xyz_data.reshape(-1,3)

            # Create an Open3D point cloud
            point_cloud_o3d = o3d.geometry.PointCloud()
            point_cloud_o3d.points = o3d.utility.Vector3dVector(xyz_data)

            # Add the point cloud to the visualizer

            # Update the visualization

except KeyboardInterrupt:
    # Exit the loop when a keyboard interrupt (e.g., Ctrl+C) is detected

# Close the ZED camera and the visualizer

Any assistance would be amazing!


Sorry, I don’t know how open3d works. But it’s probably a matter of conversion betwwen the SDK format, and what open3d expects. More info about the ZED SDK point clouds here : MEASURE Class Reference | API Reference | Stereolabs


Did you solve this? Very interested :slight_smile:

Thanks a lot!