Samples - Virtual Stereo

Open in ClaudeOpen in ChatGPT

This sample shows how to pair two ZED X One monocular cameras into a calibrated virtual stereo rig, letting the ZED SDK compute depth from two independent mono sensors as if they were a single stereo camera like the ZED 2i or ZED X. For background on why and how to build such a rig (baseline selection, hardware synchronization), see Dual Camera Stereo Vision.

Getting Started

Overview

The sample opens two ZED X One cameras — identified either by camera ID or by serial number — and combines them into a virtual stereo pair using a generated virtual serial number:

C++
1// From the 2 ZED X One cameras serial numbers, defining the Left and Right cameras of the virtual stereo rig
2unsigned int virt_sn = generateVirtualStereoSerialNumber(serial_left, serial_right);
3init_parameters.input.setVirtualStereoFromSerialNumbers(serial_left, serial_right, virt_sn);
4
5// Or, identifying the cameras by their ID instead of their serial number
6init_parameters.input.setVirtualStereoFromCameraIDs(1, 0, virt_sn);

Once opened, the virtual stereo rig behaves like any other ZED camera: it exposes rectified left/right views and, if the rig has been calibrated, standard stereo depth. If the rig hasn’t been calibrated yet, only unrectified images (VIEW::LEFT_UNRECTIFIED / VIEW::RIGHT_UNRECTIFIED) and recording are available.

The two ZED X One cameras should be hardware-synchronized (via a ZED Link capture card, ZED Box Orin, or ZED Box Mini) for accurate depth perception.