Skip to content

Rayrai Example: Active Stereo Depth ​

Overview ​

Puts two depth cameras on one fixed mount, both with the Intel RealSense D435 preset (848 x 480, its focal length and clip planes): one with the IDEAL depth model and one with the ACTIVE_STEREO model. They look at a white wall, two boxes, a glass panel, a mirror and a dark box. A 2 x 2 grid shows:

  • the color image from the depth camera's pose,
  • the ideal depth,
  • the active-stereo depth,
  • the active-stereo return strength.

Depth runs from red (0.2 m) to blue (4 m); black has no depth. The titles give the share of pixels with depth in each image.

Target ​

CMake target: rayrai_active_stereo_depth.

Run ​

From the repository root, build the target and run it:

bash
source ./raisim_env.sh
cmake --build build-examples --target rayrai_active_stereo_depth --parallel 2
./build-examples/examples/rayrai_active_stereo_depth

See Build examples to configure a new build directory.

On Windows, run rayrai_active_stereo_depth.exe instead. This example renders in process with rayrai and does not need rayrai_tcp_viewer.

What you see ​

Compared with the ideal depth, the active-stereo depth has:

  • Stereo shadows: a band without depth to the left of the near boxes, where the background is hidden from the second imager, 50 mm to the camera's right. The return-strength panel marks these pixels red.
  • No depth on the dark box: its near-infrared reflectance of 3% returns too little light at its distance.
  • The wall behind the glass panel: glass outside the glint angle passes the pattern through, so the camera measures what is behind it.
  • No depth on the mirror: a mirror turned away from the camera sends the pattern elsewhere and returns nothing.
  • Noise and edges: depth noise that grows with the square of the distance, disparity steps, and depth edges that jitter and spread over the background.

The noise is drawn again every frame from the sensor's seeded stream.

Save the window ​

The capture that the rayrai examples share (see rayrai/example_common.hpp) saves the window as a PNG and exits:

bash
RAYRAI_EXAMPLE_CAPTURE=active_stereo.png ./build-examples/examples/rayrai_active_stereo_depth

Details ​

  • Applies DepthCamera::DepthCameraProperties::realSenseD435() to both cameras, keeping their names, sets depthModel, and calls updateRayDirections().
  • Gives the physics materials their near-infrared look with World::setSensorMaterial(): white (reflectance 0.8), glass (transmission 0.9), mirror (specularity 0.95) and dark (reflectance 0.03). The boxes take the material name in World::addBox(..., mass, material).
  • Renders each camera with RayraiWindow::renderDepthPlaneDistance(sensor, camera), which for ACTIVE_STEREO also renders the second imager and the return strength, and reads it with Camera::getRawImage(sensor), which applies the stochastic part of the model.
  • Shows DepthCamera::getReturnStrengthArray(): the effective reflectance times the cosine of the incidence angle, negative where the second imager does not see the point.

See Active stereo depth cameras for the model, its parameters and the sources of the preset values, Sensor materials for the materials, and Active stereo depth for the rendered version.

RaiSim — physics for robotics and AI.