Tutorial - Global Localization
Tutorial - Global Localization
This tutorial shows how to use the Global Localization (GNSS Fusion) API to fuse GNSS coordinates with the camera’s visual-inertial odometry, in order to compute the camera’s global position (latitude, longitude, altitude) using the Fusion API. To keep this tutorial self-contained and easy to run without any external hardware, the GNSS data is randomly generated rather than read from a real GNSS receiver. We assume that you have followed the Positional Tracking tutorial before.
This module requires a stereo camera equipped with an inertial sensor (IMU), such as the ZED 2/2i, ZED Mini, ZED X, ZED X Mini, ZED X Nano. The original ZED (no built-in IMU) is not supported.
Getting Started
- First, download the latest version of the ZED SDK.
- Download the Global Localization sample code in C++ or Python.
Code Overview
Open the camera and enable positional tracking
As in the previous tutorials, we create, configure and open the ZED. Two positional tracking parameters are mandatory here: enable_imu_fusion (to get the gravity direction from the IMU) and set_gravity_as_origin (to align the camera and GNSS reference frames).
Publish the camera for Fusion
The Fusion module works on a Publish/Subscribe pattern: the camera publishes its data, and a Fusion object subscribes to it. Here, camera and Fusion run in the same process, communicating over shared memory.
Set up Fusion and subscribe the camera
We create the Fusion object, initialize it, enable its own positional tracking (with GNSS fusion), and subscribe our camera to it using its serial number as an identifier.
The python snippet above calls enable_positionnal_tracking (with the extra “n”) — this is the actual name exposed by the Fusion Python bindings.
Ingest GNSS data and retrieve the fused position
At each grab(), we get the camera-only pose, generate a fake GNSS position and ingest it into fusion, then call fusion.process() to retrieve both the fused camera pose and the geographic position (latitude, longitude, altitude) once the GNSS-to-camera alignment has converged.
Because this tutorial uses synthetic GNSS data, only the fusion mechanics are demonstrated. With a real GNSS receiver, you must provide the full GNSSData (coordinates, timestamp, position covariance, latitude/longitude/altitude standard deviation) for accurate results.
Close Fusion and the camera
For more information on the Fusion workflow, coordinate frames and calibration, read the Global Localization module documentation.

