Tutorial - Using 3D Object Detection
Tutorial - Using 3D Object Detection
This tutorial shows how to use your ZED 3D camera to detect, classify and locate persons in space (compatible with ZED 2 only). Detection and localization works with both a static or moving camera.
Getting Started
- First, download the latest version of the ZED SDK.
- Download the Object Detection sample code in C++, Python or C#.
Code Overview
Open the camera
In this tutorial, we will use the Object Detection AI module of the ZED SDK. As in previous tutorials, we create, configure and open the camera.
Enable 3D Object detection
Before enabling object detection, we specify the ObjectDetectionParameters of the module. In this tutorial, we use the following settings:
image_syncdetermines if object detection runs for each frame or asynchronously in a separate thread.enable_trackingallows objects to be tracked across frames and keep the same ID as long as possible. Positional tracking must be active in order to track objects’ movements independently from camera motion.enable_mask_outputoutputs 2D masks over detected objects. Since it requires additional processing, disable this option if not used.
Now let’s enable object detection which will load an AI model. This operation can take a few seconds. The first time the module is used, the model will be optimized for your hardware and this can take up to a few minutes. The model optimization operation is done only once.
Retrieve object data
To retrieve detected objects in an image, use the retrieveObjects() function with an Objects parameter that will store objects’ data.
Since image_sync is enabled, for each grab call, the image will be fed into the AI module that will output the detected objects for each frame. We also set the object confidence threshold at 40 to keep only very confident detections.
Disable modules and exit
Before exiting the application, modules need to be disabled and the camera closed.
zed.close() can also disable properly all active modules. The close() function is also called automatically by the destructor if necessary.
And this is it!

