QR Code Tracking Sample
This sample demonstrates how to detect and track QR codes in the real world. In order to use this feature it must be enabled in the OpenXR plugin settings located under Project Settings > XR Plug-in Management > OpenXR (> Android Tab) > OpenXR Feature Groups > Snapdragon Spaces > QR Code Tracking.
How the sample works
First and foremost, make sure to have the QR Code Tracking
feature enabled in the OpenXR project settings.
There are just two components needed to detect, track and decode QR codes when running the experience.
Adding the SpacesQrCodeManager
to the XR Origin
gameObject will enable the QR Code Subsystem included in the Snapdragon Spaces package.
A GameObject with the SpacesARMarker
component will be instantiated for each detected QR code.
The main UI shows the size of the markers to be detected in meters, and the minimum and maximum QR code versions available.
When a QR code is detected it will instantly instantiate a prefab reference that is supplied to the SpacesQrCodeManager
. The prefab tracks the position and orientation of the real world QR code. The prefab will query the SpacesARMarker
for the QR code Data and display it as soon as it is decoded by the internal feature. The prefab's UI will also display the unique trackableId
(see Unity documentation) of the detected QR code. The sample allows for multiple QR codes to be detected simultaneously.
If a prefab reference is supplied to the SpacesQrCodeManager
, the SpacesARMarker
component will be automatically added if not already attached to the prefab. When no prefab reference is supplied, it is recommended to use SpacesQrCodeManager.markersChanged
callback to manage all QR codes.