ARCamera

Inherits: RefCounted < Object

Provides camera tracking state and pose information from an AR session.

Description

Wraps the AR camera data, including the device pose, tracking state, and on iOS, camera intrinsics and projection matrices.

Platform availability:

  • iOS: Full support including intrinsics, projection matrices, exposure, and image resolution.

  • visionOS/macOS: Only transform, euler_angles, tracking_state, tracking_state_reason, and timestamp are available. Camera intrinsics, projection matrices, exposure, and image resolution return empty/zero values because the system compositor owns the camera pipeline and Apple does not expose lens parameters to applications.

Properties

Vector3

euler_angles

Vector3(0, 0, 0)

float

exposure_duration

0.0

float

exposure_offset

0.0

Vector2

image_resolution

Vector2(0, 0)

PackedFloat32Array

intrinsics

PackedFloat32Array()

PackedFloat32Array

projection_matrix

PackedFloat32Array()

float

timestamp

0.0

int

tracking_state

0

int

tracking_state_reason

0

Transform3D

transform

Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

Methods

Vector2

project_point(point: Vector3, orientation: int, viewportSize: Vector2)

PackedFloat32Array

projection_matrix_for_orientation(orientation: int, viewportSize: Vector2, zNear: float, zFar: float)

Vector3

unproject_point(point: Vector2, ontoPlaneWithTransform: Transform3D, orientation: int, viewportSize: Vector2)

Transform3D

view_matrix_for_orientation(orientation: int)


Enumerations

enum TrackingState: 🔗

TrackingState NOT_AVAILABLE = 0

Camera tracking is not available.

TrackingState LIMITED = 1

Camera tracking is available but currently limited.

TrackingState NORMAL = 2

Camera tracking is operating normally.


enum TrackingStateReason: 🔗

TrackingStateReason NONE = 0

No specific reason is reported for limited tracking.

TrackingStateReason INITIALIZING = 1

Tracking is limited because the session is still initializing.

TrackingStateReason EXCESSIVE_MOTION = 2

Tracking is limited because the device is moving too quickly.

TrackingStateReason INSUFFICIENT_FEATURES = 3

Tracking is limited because the scene lacks enough visual features.

TrackingStateReason RELOCALIZING = 4

Tracking is limited because ARKit is attempting to relocalize in a known map.


Property Descriptions

Vector3 euler_angles = Vector3(0, 0, 0) 🔗

  • Vector3 get_euler_angles()

The camera orientation expressed as Euler angles in radians.


float exposure_duration = 0.0 🔗

  • float get_exposure_duration()

Exposure time in seconds. iOS 13+ only. Returns zero on visionOS/macOS.


float exposure_offset = 0.0 🔗

  • float get_exposure_offset()

Exposure EV offset. iOS 13+ only. Returns zero on visionOS/macOS.


Vector2 image_resolution = Vector2(0, 0) 🔗

  • Vector2 get_image_resolution()

The camera image resolution in pixels. iOS only. Returns zero on visionOS/macOS.


PackedFloat32Array intrinsics = PackedFloat32Array() 🔗

  • PackedFloat32Array get_intrinsics()

The camera intrinsic matrix (3x3). iOS only. Returns empty on visionOS/macOS.

Note: The returned array is copied and any changes to it will not update the original property value. See PackedFloat32Array for more details.


PackedFloat32Array projection_matrix = PackedFloat32Array() 🔗

  • PackedFloat32Array get_projection_matrix()

The camera projection matrix (4x4). iOS only. Returns empty on visionOS/macOS.

Note: The returned array is copied and any changes to it will not update the original property value. See PackedFloat32Array for more details.


float timestamp = 0.0 🔗

  • float get_timestamp()

The frame timestamp associated with this camera sample.


int tracking_state = 0 🔗

  • int get_tracking_state()

The current quality of camera tracking. See TrackingState.


int tracking_state_reason = 0 🔗

  • int get_tracking_state_reason()

If tracking is limited, explains why. See TrackingStateReason.


Transform3D transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) 🔗

  • Transform3D get_transform()

The camera transform in world space.


Method Descriptions

Vector2 project_point(point: Vector3, orientation: int, viewportSize: Vector2) 🔗

Projects a 3D point to 2D screen coordinates. iOS only. Returns zero on visionOS/macOS because camera intrinsics are not available.


PackedFloat32Array projection_matrix_for_orientation(orientation: int, viewportSize: Vector2, zNear: float, zFar: float) 🔗

Returns a projection matrix for the given orientation and viewport. iOS only. Returns empty on visionOS/macOS.


Vector3 unproject_point(point: Vector2, ontoPlaneWithTransform: Transform3D, orientation: int, viewportSize: Vector2) 🔗

Unprojects a 2D point onto a plane in 3D space. iOS only. Returns zero on visionOS/macOS.


Transform3D view_matrix_for_orientation(orientation: int) 🔗

Returns a view transform for the given interface orientation. iOS only. Returns the default transform on visionOS/macOS.