Tutorial - Using Camera Tracking
Tutorial - Using Camera Tracking
This tutorials shows how to get the position and orientation of the camera in real time. The program will loop until 1000 positions are grabbed. We assume that you have followed the previous tutorials.
Getting Started
- First, download the latest version of the ZED SDK.
- Download the Positional Tracking sample code in C++, Python or C#.
Code Overview
Open the camera
As in previous tutorials, we create, configure and open the ZED.
Enable positional tracking
Once the camera is opened, we must enable the positional tracking module with enablePositionalTracking() in order to get the position and orientation of the ZED.
In the above example, we use the default tracking parameters set in the ZED SDK. For the list of available parameters, check the Tracking API docs.
Capture pose data
Now that motion tracking is enabled, we create a loop to grab and retrieve the camera position. The camera position is given by the class Pose. This class contains the translation and orientation of the camera, as well as image timestamp and tracking confidence.
A pose is always linked to a reference frame. The SDK provides two reference frames: REFERENCE_FRAME::WORLD and REFERENCE_FRAME::CAMERA. For more information, see the Coordinate Frames section.
In this tutorial, we retrieve the camera position in the World Frame.
Inertial Data
If an IMU is available (ex: ZED 2, ZED Mini), the Positional Tracking module will fuse internal visual and inertial data to provide improved position tracking.
You can also access IMU data using the code below:
For more information on Camera-IMU and other onboard sensors, check the Sensors section.
Close the Camera
After tracking the ZED camera position for 1000 frames, we disable the tracking module and close the camera.
Advanced Example
To learn how to retrieve and display the live position and orientation of the camera in a 3D window, transform pose data and change coordinate systems and units, check the advanced Motion Tracking sample code.

