Skip to content

Latest commit

 

History

History
 
 

01-Video-Capture

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

ZED Video Capture

The ZED API provides low-level access to the camera hardware and video features, facilitating camera control and high-quality video recording and streaming.

Overview

How It Works

The left and right video frames of the ZED Camera are synchronized and streamed as a single uncompressed video frame, and you can choose your preferred output format among the following :

  • Left or Right rectified
  • Side-by-side view
  • Left or Right unrectified
  • Left or Right grayscale

The ZED camera features an onboard ISP (Image Signal Processor) that performs various image processing algorithms on raw images captured by the dual image sensors.

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. Note that InitParameters contains a default configuration.

To read more about how to configure your camera using the API, read our dedicated section.

Getting Images

Live Image Capture

To capture images from the ZED, specify your RuntimeParameters and call grab() to grab a new frame and retrieveImage() to retrieve the grabbed frame. retrieveImage() lets you select between different views such as left, right, unrectified and grayscale images.

C++

sl::Mat image;
if (zed.grab() == SUCCESS) {
  // A new image is available if grab() returns SUCCESS
  zed.retrieveImage(image,VIEW_LEFT); // Retrieve the left image
}

Python

image = sl.Mat()
runtime_parameters = sl.RuntimeParameters()
if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
  # A new image is available if grab() returns SUCCESS
  zed.retrieve_image(image, sl.VIEW.VIEW_LEFT) # Retrieve the left image

C#

sl.Mat image = new sl.Mat();
RuntimeParameters runtimeParameters = new RuntimeParameters();
if (zed.Grab(ref runtimeParameters) == ERROR_CODE.SUCCESS) {
  // A new image is available if grab() returns SUCCESS
  zed.RetrieveImage(image,sl.VIEW.LEFT); // Retrieve the left image
}

Video Recording

The ZED SDK uses Stereolabs SVO format to store videos along with additional metadata such as timestamp and sensor data.

To record SVO files, you need to enable the Recording module with enableRecording(). Specify an output file name (eg: output.svo) and SVO_COMPRESSION_MODE, then save each grabbed frame using record(). SVO lets you record video and associated metadata (timestamp, IMU data and more if available).

C++

// Create a ZED camera object
Camera zed;

// Enable recording with the filename specified in argument
String output_path(argv[1]);
err = zed.enableRecording(output_path, SVO_COMPRESSION_MODE::H264);

while (!exit_app) {
    if (zed.grab() == SUCCESS) {
        // Each new frame is added to the SVO file
        zed.record();
    }
}
// Disable recording
zed.disableRecording();

Python

# Create a ZED camera object
zed = sl.Camera()

# Enable recording with the filename specified in argument
output_path = sys.argv[0]
err = zed.enable_recording(output_path, sl.SVO_COMPRESSION_MODE.H264)

while !exit_app :
    if zed.grab() == SUCCESS :
        # Each new frame is added to the SVO file
        zed.record()

# Disable recording
zed.disable_recording()

C#

// Create a ZED camera object
sl.Camera zed = new sl.Camera(0);
sl.RuntimeParameters runtimeParameters = new sl.RuntimeParameters();
// Enable recording with the filename specified in argument
string output_path = args[0];
err = zed.EnableRecording(output_path, sl.SVO_COMPRESSION_MODE.H264_BASED);

while (!exit_app) {
    // Each new frame is added to the SVO file
    zed.Grab(ref runtimeParameters);
}
// Disable recording
zed.DisableRecording();

Once your SVO is properly recorded, you can play it back or load it as an input to your ZED programs, enabling the ZED API to behave as if a ZED Camera was connected and live feed was available. Every module of the ZED API will be available: depth, tracking, spatial mapping and more.

Code Examples

For code examples, check out our Video Capture Tutorial, Camera Control, SVO Recording, SVO Playback and SVO Export samples in this repository.

Integrations

Check the Integrations list to use the ZED with your favorite suite of tools and libraries.

Documentation

For more information, read the Documentation or these specific sections:

You can also check out our API Reference for more details about the available functions provided by the SDK.