Tutorial - Hello ZED

Open in ClaudeOpen in ChatGPT

This tutorial simply shows how to configure and open the ZED, print its serial number and close the camera. This is the most basic tutorial and a good start for using the ZED SDK.

Getting Started

  • First, download the latest version of the ZED SDK.
  • Download the Hello ZED sample code in C++, Python or C#.
  • Follow the instructions on how to build your project in C++ or run it in Python on Windows and Linux.

Code Overview

The ZED API provides low-level access to camera control and configuration. To use the ZED in your application, you will need to create and open a Camera object. The API can be used with two different video inputs: the ZED live video (Live mode) or video files recorded in SVO format with the ZED API (Playback mode).

Camera configuration

To configure the camera, create a Camera object and specify your InitParameters. Initial parameters let you adjust camera resolution, FPS, depth sensing parameters and more. These parameters can only be set before opening the camera and cannot be changed while the camera is in use.

1// Create a ZED camera object
2Camera zed;
3
4// Set configuration parameters
5InitParameters init_params;
6init_params.camera_resolution = RESOLUTION::HD1080;
7init_params.camera_fps = 30;

InitParameters contains a configuration by default. You can set the following initial parameters:

  • Camera configuration parameters, using the camera_* entries (resolution, image flip…).
  • SDK configuration parameters, using the sdk_* entries (verbosity, GPU device used…).
  • Depth configuration parameters, using the depth_* entries (depth mode, minimum distance…).
  • Coordinate frame configuration parameters, using the coordinate_* entries (coordinate system, coordinate units…).
  • SVO parameters to use StereoLabs video files with the ZED SDK (filename, real-time mode…)

To get the list of available parameters, see API documentation.

Open the camera

Once the initial configuration is done, open the camera.

1// Open the camera
2err = zed.open(init_params);
3if (err != ERROR_CODE::SUCCESS)
4 exit(-1);

Retrieve Camera Information

Camera parameters such as focal length, the field of view or stereo calibration can be retrieved for each eye and resolution. Those values are available in CalibrationParameters. They can be accessed using getCameraInformation(). You can also access IMU and sensor configuration using the Sensors API.

In this tutorial, we simply retrieve the serial number of the camera:

1// Get camera information (serial number)
2int zed_serial = zed.getCameraInformation().serial_number;
3printf("Hello! This is my serial number: %d\n", zed_serial);

In the console window, you should now see the serial number of the camera (also available on a sticker on the ZED USB cable).

Close the Camera

To close the camera properly, use zed.close() and exit the program.

1// Close the camera
2zed.close();