AR Data Format & API

AR Coordinate System

Coordinate Frame:

  • X-axis: Right

  • Y-axis: Up

  • Z-axis: Forward

Pose : [tx,ty,tz,qx,qy,qz,qw][t_x, t_y, t_z, q_x, q_y, q_z, q_w]

  • Translation (first 3 values): Position in meters

    • tx,ty,tzt_x, t_y, t_z: X, Y, Z coordinates

  • Rotation (last 4 values): Orientation as quaternion

    • qx,qy,qzq_x, q_y, q_z: Imaginary part

    • qwq_w: Real part

Difference between local_pose and global_pose:

  • local_pose: Position relative to device starting point

  • global_pose: Position in shared world coordinate (when multiple devices collaborate)

circle-info

Note: When using a single device, local_pose and global_pose are identical

Velocity

Format: [vx,vy,vz][v_x, v_y, v_z]

  • Calculated as: v=ΔpΔt\vec{v} = \frac{\Delta \vec{p}}{\Delta t}

  • Unit: meters per second (m/s)

  • In the same coordinate frame as pose

Camera Intrinsics

Format: [fx,0,0,0,fy,0,cx,cy,1][f_x, 0, 0, 0, f_y, 0, c_x, c_y, 1]

Represents 3×3 matrix:

K=[fx0cx0fycy001]K = \begin{bmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{bmatrix}

Where:

  • fx,fyf_x, f_y: Focal length in pixels

  • cx,cyc_x, c_y: Principal point (optical center) in pixels

triangle-exclamation

Attention

Depth Image

  • Format: 16-bit unsigned integer (uint16)

  • Unit: 10410^{-4} m (0.1 mm, scaled by 10000 from meters)

  • Conversion to meters: dmeters=draw10000d_{meters} = \frac{d_{raw}}{10000}

  • Range: 0draw655350 \leq d_{raw} \leq 6553500 to 6.55356.5535 m

  • Access: Use data.depth or data.depth_array to get numpy array

Image Data Format

Color Image: Two formats available

  • color_bytes: JPEG compressed bytes

  • color_array: RGB numpy array (640×480×3)

  • color: Shortcut for color_array

Depth Image: Numpy array only

  • depth_array: uint16 numpy array (256×192)

  • depth: Shortcut for depth_array

API Reference

ARDataSubscriber

Constructor:

Parameters:

  • ip (str): iPhone's IP address

  • port (int): Port number (default: 8000)

  • hwm (int): High water mark (default: 1, keeps only latest message)

  • conflate (bool): Message conflation (default: True)

  • verbose (bool): Print connection info (default: False)

Usage:

Main Methods:

Method

Returns

Description

get()

ARFrame or None

Get latest data frame

get_timestamp()

float or None

Get timestamp only

get_velocity()

np.ndarray or None

Get velocity only

get_local_pose()

np.ndarray or None

Get local pose only

get_global_pose()

np.ndarray or None

Get global pose only

get_camera_intrinsics()

np.ndarray or None

Get camera intrinsics only

get_color_image()

bytes or None

Get color image bytes only

get_depth_image()

np.ndarray or None

Get depth array only

close()

None

Close connection

circle-info

Note:

  • The subscriber is iterable, so you can use for data in sub: to receive frames continuously.

  • All get_*() methods accept an optional timeout parameter (default: 1000ms).

ARFrame

Data object returned by get() or when iterating. For data format details, see AR Data Format Referencearrow-up-right above.

Properties:

Property

Type

Description

timestamp

float

Unix timestamp in seconds

velocity

np.ndarray

Velocity $[v_x, v_y, v_z]$ in m/s

local_pose

np.ndarray

Local pose $[t_x, t_y, t_z, q_x, q_y, q_z, q_w]$

global_pose

np.ndarray

Global pose $[t_x, t_y, t_z, q_x, q_y, q_z, q_w]$

camera_intrinsics

np.ndarray

Camera intrinsics (3×3 flattened)

Color Image

color_bytes

bytes

JPEG image bytes (for saving/forwarding)

color_array

np.ndarray

Decoded RGB image array (640×480×3)

color

np.ndarray

Shortcut for color_array

Depth Image

depth_array

np.ndarray

Depth image array (uint16, 256×192)

depth

np.ndarray

Shortcut for depth_array

depth_width

int

Depth image width (256)

depth_height

int

Depth image height (192)

Helpers

has_color_image

bool

Check if color image exists

has_depth_image

bool

Check if depth image exists

Methods:

Method

Returns

Description

show_color(window_name)

bool

Display color image with OpenCV

show_depth(window_name, colormap)

bool

Display depth image with colormap

show_images(show_color, show_depth)

tuple

Display both images side by side

Last updated

Was this helpful?