Frame Rate and Latency
Set the camera grab rate, avoid dropped frames, choose between read() and grab(), and minimize the glass-to-glass latency
The grab rate, set with the camera_fps parameter, is the frame rate at which the camera captures images. The available values depend on the camera model and on the selected resolution, and the grab rate directly affects three aspects of your application:
- Latency: the capture pipeline has a fixed latency measured in frames, so a higher frame rate reduces the time between the moment a scene is captured and the moment your application receives the image.
- Image quality: the exposure time cannot exceed the frame period. A higher frame rate allows shorter exposure times, which reduce motion blur on fast-moving scenes.
- Computation load: by default, the ZED SDK processes every captured frame, so a higher frame rate increases the CPU and GPU load of the host.
This page explains how to:
- select the grab rate for your camera model,
- detect and avoid the frames that
grab()drops when your application cannot keep up, - acquire the frames with
read()instead ofgrab(), - combine the highest frame rate with the
grab_compute_capping_fpsparameter to get the lowest latency without overloading the host.
Available frame rates by camera model
The available frame rates depend on the camera model and on the video mode:
ZED 2i, ZED 2, ZED Mini
ZED X, ZED X Mini, ZED X Nano
ZED X One GS, ZED X One S, ZED X One Core
ZED X One 4K
A virtual stereo camera built with two ZED X One cameras uses the frame rates of the ZED X One model it is made of.
Set the grab rate
Select the resolution and the frame rate with the camera_resolution and camera_fps initialization parameters, before opening the camera:
Keep in mind the following rules:
- If
camera_fpsis set to0, the default value, the ZED SDK uses the highest frame rate available for the selected resolution. - If the requested frame rate is not available for the selected resolution, the ZED SDK uses the closest available frame rate.
- If
camera_resolutionis left atAUTO, the default value, the ZED SDK selectsHD1200for the ZED X and ZED X Mini, andHD720for the other cameras. - The resolution and the frame rate cannot be changed while the camera is open. Close and reopen the camera to change them.
To check the frame rate actually reached by your application, call getCurrentFPS() (get_current_fps() in Python) while grabbing. It returns the rate at which frames are acquired, computed from the camera timestamps of two consecutive frames. Frames are acquired by grab(), or by read() when your application uses it (see Acquire frames without processing them with read()).
Host limits on the grab rate
The frame rate that your system can sustain can be lower than the maximum frame rate of the camera:
- USB cameras: the USB 3.0 bandwidth of a controller is shared by all the cameras connected to it. When the bandwidth is exceeded, corrupted frames appear and cameras can disconnect.
- GMSL2 cameras: each camera uses a dedicated link of the ZED Link capture card or of the ZED Box, but the number of cameras, the resolutions, and the frame rates are limited by the capture card and by the Jetson™ module.
- Computation: if the processing of each frame (depth, positional tracking, object detection, and so on) takes longer than the frame period,
grab()runs slower thancamera_fpsand frames are dropped, as explained in How grab() delivers frames.
The Multi-Camera page gives hardware recommendations for USB and GMSL2 setups.
How grab() delivers frames
grab() does not keep a queue of the captured frames: each call returns the most recent frame captured by the camera.
- If your loop is faster than the camera,
grab()blocks until the next frame is captured, so every frame is returned once. - If your loop is slower than the camera, several frames are captured between two
grab()calls.grab()returns the newest one, and the older ones are dropped: they never reach your application.
This keeps the latency as low as possible, but it means that a slow loop silently loses frames. For example, with a camera at 30 fps (a frame every 33 ms) and a loop iteration that takes 50 ms, about one frame in three is dropped.
A dropped frame is also lost for every feature that relies on the acquired frames:
- SVO recording: only the acquired frames are written to the file. The file holds fewer frames per second than
camera_fps, with timestamp gaps where frames were dropped. - ZED SDK modules: positional tracking, object detection, body tracking, and spatial mapping only process the grabbed frames.
- Fusion: a camera that publishes with
startPublishing()sends its data from itsgrab()loop, so the Fusion module receives only the grabbed frames.
The IMU samples are not affected: getSensorsDataBatch() returns all the samples received since the previous frame acquisition, including those received during the dropped frames. With a live camera, the ZED SDK keeps up to 2.5 seconds of IMU samples with the ZED 2 and ZED 2i, and 0.5 seconds with the other cameras: a longer gap between two acquisitions loses the older samples.
When reading an SVO file, grab() returns every frame of the file in order, whatever the speed of your loop, so no frame is dropped during the playback. The only exception is the real-time mode (svo_real_time_mode set to true), which skips frames to follow the recording timing. During playback, getFrameDroppedCount() reports the frames dropped during the recording.
When grab_compute_capping_fps is set, frames are dropped on purpose: grab() skips frames to stay at or below the capping rate. See Reduce the computation load with grab_compute_capping_fps.
Detect dropped frames
There are three ways to detect dropped frames:
getFrameDroppedCount()(get_frame_dropped_count()in Python,GetFrameDroppedCount()in C#) returns the number of frames dropped since the firstgrab(). The frames skipped because ofgrab_compute_capping_fpsare included. The counter can already be non-zero after the firstgrab(), because it also counts the frames captured before that call, for example while the depth model is loading.getCurrentFPS()(get_current_fps()in Python) returns a value lower thancamera_fpswhen frames are dropped.- The difference between the image timestamps of two consecutive grabbed frames is larger than the frame period. A difference of N frame periods means that N - 1 frames were dropped.
The following example checks both the counter and the timestamps after each grab():
Avoid dropped frames
To make sure that every frame is acquired:
- Move the heavy processing to another thread. Keep the
grab()loop short: grab, retrieve the data you need, copy it, and hand it over to a worker thread. The ZED SDK modules, the SVO recording, and the Fusion publishing then get every frame, even if your own processing runs at a lower rate. When recording, checkgetFrameDroppedCount()to make sure that the file has the expected frame rate. See the example below. - Lower the frame rate to a value that your loop can sustain. A lower
camera_fpsincreases the latency. If the latency matters more than processing every frame, usegrab_compute_capping_fpsinstead, which drops frames on purpose. - Reduce the workload of each frame: select a lower resolution, a lighter depth mode, or disable the modules that your application does not need. You can also skip the depth computation of a frame by setting the
enable_depthruntime parameter tofalse. - Acquire the frames with
read()when only some frames, or none, need the processing ofgrab(), for example to record or stream. See Acquire frames without processing them with read().
The following example, a complete program in C++ and Python, keeps the grab() loop at the camera frame rate while a worker thread runs 100 ms of processing on the most recent image. The worker skips the images that arrive while it is busy, but grab() itself does not drop any frame:
Acquire frames without processing them with read()
grab() performs two steps on each frame:
- Acquisition: it waits for a new frame and makes the most recent one available, together with its IMU samples.
- Processing: it runs the processing enabled in your application, such as depth computation, positional tracking, object detection, body tracking, or spatial mapping.
read() (read() in Python, Read() in C#) performs only the acquisition step. It is available for sl::Camera, and for sl::CameraOne in C++. When grab() is called after read(), it does not acquire a new frame: it processes the frame acquired by read(). When grab() is called without read(), it acquires a new frame first.
Differences between read() and grab()
Both functions follow the same frame delivery rules, described in How grab() delivers frames:
- The frames dropped by
read()are counted bygetFrameDroppedCount(). getCurrentFPS()reports the acquisition rate: if you callread()on every frame andgrab()on only some of them, it returns theread()rate.grab_compute_capping_fpsalso limits the rate ofread().- When reading an SVO file, each
read()moves to the next frame of the file, and agrab()that follows processes that same frame. - The IMU samples returned by
getSensorsDataBatch()belong to the last acquired frame. If you callread()twice without reading the batch in between, the samples of the first frame are lost: read the batch after eachread().
read() does not update the data computed by grab(). After a read(), retrieveMeasure() and getPosition() still return the depth and the pose computed by the last grab(), but labeled with the timestamp of the frame acquired by read(). Use the measures and the pose only after a grab().
When to use read() instead of grab()
Use grab() alone when your application needs the processing of the ZED SDK on every frame: it is the simplest loop.
Use read() in the following cases:
- Images at full rate, processing at a lower rate: call
read()on every frame to retrieve the images, andgrab()only every N frames to compute the depth or the other measures. Your application gets every image, whereasgrab_compute_capping_fpswould lower the image rate too. The Split Process tutorial shows this pattern. - Recording or streaming only: since ZED SDK 5.4, SVO recording and streaming run from
read(). A loop that only callsread()records or streams every frame without paying for the depth computation or the image rectification. Before ZED SDK 5.4, agrab()was required to record or stream a frame. - Custom depth before the ZED SDK processing: with
DEPTH_MODE::CUSTOM, callread(), retrieve the rectified images, compute your own depth map, pass it withingestCustomDepth(), then callgrab()to run the ZED SDK modules on it. See the Custom Depth sample.
The following example retrieves the left image of every frame with read(), and computes the depth every 6 frames with grab():
Minimize the glass-to-glass latency
The glass-to-glass latency is the time between the moment a scene is captured by the camera sensor and the moment the corresponding image is displayed or used by your application. The part introduced by the camera and the ZED SDK capture pipeline is fixed when measured in frames:
- about 2 to 3 frames for GMSL2 cameras,
- about 3 to 4 frames for USB cameras.
This latency is therefore proportional to the frame period: the higher the grab rate, the lower the latency. To minimize it, set camera_fps to the highest frame rate offered by the selected resolution that your host can sustain, as described in Host limits on the grab rate. If latency matters more than image resolution, also consider a lower resolution with a higher maximum frame rate, for example SVGA at 120 fps on a ZED X.
The following table gives the expected latency of the grab operation at the highest frame rate of each video mode:
These values refer to the pure grab operation, that is, the time needed to capture a frame and make it available through grab() or read(). The processing performed by the ZED SDK on each frame, such as image rectification, depth computation, positional tracking, or object detection, adds its own time, which depends on the enabled modules and on the processing power of the host. On a less powerful host, or with heavier settings, the actual latency can therefore be noticeably higher than the values in the table.
The glass-to-glass latency of your system also includes the processing time of your application and, if the images are displayed, the latency of the display pipeline.
A higher frame rate is also useful when the exposure is controlled manually: since the exposure time is expressed as a percentage of the frame period, a higher frame rate allows shorter exposure times and reduces motion blur.
Reduce the computation load with grab_compute_capping_fps
By default, running the camera at its highest frame rate also forces the ZED SDK to process every frame at that rate, which maximizes the CPU and GPU load. If your application does not need to process all the frames, or if the host cannot sustain this load, use the grab_compute_capping_fps initialization parameter.
grab_compute_capping_fps sets an upper limit to the processing rate of grab(), independently of the capture frame rate. It also limits the rate of read():
- The camera keeps capturing at
camera_fps, so the capture pipeline latency stays as low as the camera frame rate allows. grab()always returns the latest available image, so processing at a lower rate does not make the images older: each processed image is the most recent one captured. The frames captured in between are dropped.- The ZED SDK modules (image and depth retrieval, positional tracking, object detection, body tracking, and so on) run at most at the capping rate, which reduces the CPU and GPU load.
Unlike camera_fps, the capping value is not limited to the fixed frame rates of the camera: you can set any strictly positive value lower than camera_fps, for example 25.0. Set it to 0 to disable the capping, which is the default behavior.
For example, to capture at 120 fps with a ZED X in SVGA mode for the lowest latency, while processing at most 30 frames per second:
grab_compute_capping_fpsis an upper limit: it has no effect if the processing is already slower than the capping value.- It has no effect when reading an SVO file. Since ZED SDK 5.6, it also applies to stream inputs, where it previously had no effect.
- Before ZED SDK 5.6, it could delay the images by up to one capping period (about 200 ms at 5 FPS). Since ZED SDK 5.6,
grab()processes the newest image.
Find the best capping value
The best value depends on the processing power of the host and on the configuration of your application: resolution, depth mode, and enabled modules. To find it:
- Set
camera_fpsto the highest frame rate available for your resolution. - Set
grab_compute_capping_fpsto the processing rate required by your application. - Run your application with its full workload and monitor the processing rate with
getCurrentFPS(), and the CPU and GPU load of the host. - If the processing rate stays steadily at the capping value and the host has resources left, you can increase the capping value. If the processing rate cannot reach the capping value, the host cannot sustain this processing rate: decrease the capping value, or reduce the workload, for example with a lighter depth mode.
Tune the power mode of a ZED Box
On a ZED Box, a ZED Box Mini, a ZED Box 2, or a ZED Box 2 Max, the power mode of the NVIDIA® Jetson™ module sets the number of active CPU cores and the maximum CPU and GPU frequencies, and therefore the processing rate that the host can sustain. Once your capping value is defined, you can tune the power mode to balance processing frequency and power consumption:
- If the processing rate cannot reach the capping value, select a higher power mode to increase the processing power of the module, within the limits of your power supply.
- If the processing rate stays steadily at the capping value, try lower power modes and keep the lowest one that still sustains the required processing rate. This minimizes the power consumption and the heat of the host.
The available power modes and how to change them are described in the Power Modes guides of the ZED Box, of the ZED Box Mini, of the ZED Box 2, and of the ZED Box 2 Max.
With the ZED ROS 2 Wrapper, the same behavior is available through the general.grab_frame_rate and general.grab_compute_capping_fps parameters. See Stereo Node Frequency Tuning.

