Tutorial - Image Capture
Tutorial - Image Capture
This tutorial shows how to capture the left image of the ZED camera and print its timestamp and image size in the terminal. The program will loop until it has successfully grabbed 50 images. We assume that you have read the Hello ZED tutorial before.
Getting Started
- First, download the latest version of the ZED SDK.
- Download the Image Capture sample code in C++, Python or C#.
Code Overview
Open the camera
As in the previous tutorial, here we create, configure and open the ZED. We set the 3D camera to dual HD 1080 resolution at 30 fps.
Capture Image Data
Now that the ZED is opened, we can capture the live stream coming from the camera. Let’s create a loop that captures 50 images and exits.
To capture an image and process it, you need to call the Camera::grab() function. This function can take runtime parameters as well, but we leave them to default in this tutorial.
If grab() returns SUCCESS, a new image has been captured and is now available. You can also check the status of grab() which tells you if there is an issue during capture.
Once the grab() method has been executed, you can retrieve the new image and its metadata. In this tutorial, we will retrieve the left image and its timestamp using retrieveImage() and getTimestamp().
retrieveImage() takes an sl::Mat as well as a VIEW mode as parameters. When creating the Mat, you don’t need to allocate memory. The first time retrieveImage() is called, the Mat is filled with image data and memory is allocated automatically.
Image timestamp is given in nanoseconds and Epoch format. You can compare the timestamps between two grab(): it should be close to the framerate time, if you don’t have any dropped frames.
For more information on Camera and Video parameters, read Using the Video API.
Close the Camera
Now that we have captured 50 images, let’s close the camera and exit the program.
Additional Example
To learn how to adjust camera settings like Exposure, Gain, Contrast, Sharpness, etc. and display the resulting image, check the Camera Control sample code.

