Skip to content

Stream Point Cloud ​

SUMMARY

Stream Point Cloud continuously fuses depth and colour frames into colour-mapped 3D point clouds, returning each one as a PointCloud with .positions (Nx3 float XYZ) and .colors (Nx3 uint8 RGB) arrays. Select the camera at connect time, then log each cloud directly with rr.Points3D.

Available on: Intel RealSense.

The Skill ​

python
point_cloud = camera.capture_pointcloud()

Call repeatedly inside a loop. The camera is selected in connect:

python
camera.connect(serial_number="123456789012")

Example ​

The Code ​

python
"""
Stream a continuous colour-mapped point cloud from a RealSense camera.

Run from a terminal to avoid issues with Rerun's spawn mode.
"""
import time
from loguru import logger

import rerun as rr

from telekinesis.medulla.cameras import realsense


def main():
    camera = realsense.RealSenseD435I(name="my_realsense_camera")
    try:
        rr.init("RealSense_Pointcloud_Video_Example", spawn=True)
        rr.log("/", rr.ViewCoordinates.RDF, static=True)
        camera.connect(serial_number="123456789012")

        end_time = time.time() + 10
        while time.time() < end_time:
            point_cloud = camera.capture_pointcloud()
            if point_cloud is None:
                continue

            rr.log(
                "Continuous_Pointcloud_Capture",
                rr.Points3D(positions=point_cloud.positions, colors=point_cloud.colors),
            )
    except Exception as e:
        logger.error(f"Unable to stream point cloud. {type(e).__name__}: {e}")
    finally:
        rr.disconnect()
        camera.disconnect()


if __name__ == "__main__":
    main()

Running the Example ​

bash
python realsense_pointcloud_example.py

A Rerun viewer opens automatically. The 3D point cloud streams under Continuous_Pointcloud_Capture for 10 seconds, then the camera disconnects cleanly.

Parameter Configuration ​

capture_pointcloud() itself takes no parameters. The camera is chosen when connecting, and the colour stream used to colour the cloud must be an RGB or BGR format:

ParameterTypeDefaultDescription
serial_numberstrrequiredconnect() argument. Serial number of the RealSense device to open.

Stream resolution and frame rate can be changed with camera.configure_streams([...]) or the stream_profile parameter, using StreamProfile entries for the depth and colour streams. See set_parameter.

Returns ​

TypeDescription
datatypes.PointCloudColour-mapped point cloud with .positions (float32, shape (N, 3), XYZ in metres in the colour camera frame) and .colors (uint8, shape (N, 3), RGB). One point is kept per depth pixel; pixels with no valid depth have NaN positions.

Raises ​

ExceptionCondition
RuntimeErrorThe camera is not connected (the RealSense pipeline has not been started), or no frameset could be captured.
ValueErrorThe colour stream is not RGB8, BGR8, RGBA8 or BGRA8.

Where to Use the Skill ​

  • Live 3D monitoring — observe how the scene's 3D structure changes during robot motion.
  • Continuous grasp planning — feed a steady stream of point clouds into pose-estimation pipelines.
  • Calibration sanity checks — verify depth-colour alignment in real time.