QrScanner
Inherits: Node
Description
Scans QR codes with the headset cameras.
Uses the OpenXR spatial marker tracking extension (XR_EXT_spatial_marker_tracking). On Meta Quest this needs Horizon OS v83 or newer and the "Spatial Data" permission. Detection only runs while a scan is active: start() creates a QR code only spatial context and stop() frees it again, so the cameras aren't searching for codes the rest of the time.
Properties
Methods
| Returns | Name |
|---|---|
| Variant | _emit_marker ( text: String, pose: Transform3D, scan_id: int ) |
| Variant | _finish ( text: String, scan_id: int ) |
| Variant | _free_context ( context: RID ) |
| Array[OpenXRMarkerTracker] | _get_marker_trackers ( context: RID ) |
| String | _marker_data_to_text ( data: Variant ) |
| Variant | _on_context_created ( context: RID, scan_id: int ) |
| Variant | _on_snapshot ( _snapshot: RID, processed: bool, context: RID ) |
| void | _process ( delta: float ) |
| void | _ready ( ) |
| bool | _request_permission ( ) |
| Variant | _start_discovery ( ) |
| bool | is_supported ( ) |
| QrScanner.ScanError | start ( timeout: float = 30.0, stop_on_first: bool = true ) |
| Variant | stop ( ) |
Signals
on_marker (text: String , pose: Transform3D )
Emitted for every QR code seen during a scan started with stop_on_first = false, with its pose in tracking space, as often as the codes are detected. The scan keeps running.
on_scanned (text: String )
Emitted with the content of the first QR code found during a scan. The scan stops right after.
on_scanning_changed (scanning: bool )
Emitted when a scan starts or stops.
on_timeout ( )
Emitted when a scan stops because no QR code was found in time.
Enums
enum ScanError
ScanError.OK = 0
No description provided yet.
ScanError.UNSUPPORTED = 1
The device or runtime can't detect QR codes.
ScanError.PERMISSION_DENIED = 2
The user didn't grant the permission needed for QR code detection.
ScanError.CANCELLED = 3
stop() was called before the scan started.
Constants
DEFAULT_TIMEOUT = 30.0
Seconds a scan runs before giving up.
DISCOVERY_INTERVAL = 0.3
Seconds between two discovery requests while scanning.
DISCOVERY_WATCHDOG = 3.0
Seconds after which a discovery that never reported back is given up on.
QUEST_SCENE_PERMISSION = "com.oculus.permission.USE_SCENE"
Meta Quest only reports QR codes to apps with the Spatial Data permission.
Property Descriptions
_component_data: Array[OpenXRSpatialComponentData]
No description provided yet.
_context: RID
No description provided yet.
_discovery_cooldown: float
No description provided yet.
_discovery_pending: bool
No description provided yet.
_discovery_started_at: float
No description provided yet.
_marker_tracking: Object
No description provided yet.
_scan_id: int
Increased on every start and stop, so callbacks of an old scan can tell they're stale.
_scan_time_left: float
No description provided yet.
_spatial_entities: Object
No description provided yet.
_stop_on_first: bool
No description provided yet.
scanning: bool
No description provided yet.
Method Descriptions
_emit_marker (text: String , pose: Transform3D , scan_id: int ) -> Variant
No description provided yet.
_finish (text: String , scan_id: int ) -> Variant
No description provided yet.
_free_context (context: RID ) -> Variant
No description provided yet.
_get_marker_trackers (context: RID ) -> Array[OpenXRMarkerTracker]
No description provided yet.
_marker_data_to_text (data: Variant ) -> String
No description provided yet.
_on_context_created (context: RID , scan_id: int ) -> Variant
No description provided yet.
_on_snapshot (_snapshot: RID , processed: bool , context: RID ) -> Variant
Called by the marker tracking capability once before (processed = false) and once after the snapshot has been turned into OpenXRMarkerTrackers.
_process (delta: float ) -> void
No description provided yet.
_ready ( ) -> void
No description provided yet.
_request_permission ( ) -> bool
No description provided yet.
_start_discovery ( ) -> Variant
No description provided yet.
is_supported ( ) -> bool
Returns true if QR codes can be scanned on this device. Only reliable once the XR session is running.
start (timeout: float = 30.0 , stop_on_first: bool = true ) -> QrScanner.ScanError
Starts scanning for QR codes. The first QR code found is emitted with on_scanned. With stop_on_first false, every detection is emitted with on_marker instead, until stop() is called or the scan times out. Returns once the scan is running or failed to start.
stop ( ) -> Variant
Stops the current scan, if any.

