Class

ARSession

A shared object that manages the device camera and motion processing needed for augmented reality experiences.

Overview

An ARSession object coordinates the major processes that ARKit performs on your behalf to create an augmented reality experience. These processes include reading data from the device's motion sensing hardware, controlling the device's built-in camera, and performing image analysis on captured camera images. The session synthesizes all of these results to establish a correspondence between the real-world space the device inhabits and a virtual space where you model AR content.

Every AR experience built with ARKit requires a single ARSession object. If you use an ARSCNView or ARSKView object to easily build the visual part of your AR experience, the view object includes an ARSession instance. If you build your own renderer for AR content, you'll need to instantiate and maintain an ARSession object yourself.

Running a session requires a configuration. Subclasses of the abstract ARConfiguration class determine how ARKit tracks a device's position and motion relative to the real world, and thus affect the kinds of AR experiences you can create. For example, use ARWorldTrackingConfiguration for experiences that augment the user's view of the world around them though the device's back camera.

Topics

Configuring and Running a Session

runWithConfiguration:options:

Starts AR processing for the session with the specified configuration and options.

runWithConfiguration:

Starts AR processing for the session with the specified configuration.

ARSessionRunOptions

Options affecting how to transition an AR session's current state when you change its configuration.

configuration

An object that defines motion and scene tracking behaviors for the session.

pause

Pauses processing in the session.

Responding to AR Updates

delegate

An object you provide to receive captured video images and tracking information, or to respond to changes in session status.

delegateQueue

The dispatch queue through which the session calls your delegate methods.

ARSessionDelegate

Methods you can implement to receive captured video frame images and tracking state from an AR session.

ARSessionObserver

Methods you can implement to respond to changes in the state of an AR session.

Displaying and Interacting with AR Content

currentFrame

The video frame image, with associated AR scene information, most recently captured by the session.

addAnchor:

Adds the specified anchor to be tracked by the session.

removeAnchor:

Removes the specified anchor from tracking by the session.

Saving or Sharing Session State

getCurrentWorldMapWithCompletionHandler:

Returns an object encapsulating the world-tracking session's space-mapping state and set of anchors.

Scanning 3D Objects for Detection

createReferenceObjectWithTransform:center:extent:completionHandler:

Creates a reference object (for 3D object detection) from the specified region of the session’s world space.

Updating the World Origin

setWorldOrigin:

Changes the basis for the AR world coordinate space using the specified transform.

Relationships

Inherits From

See Also

First Steps

Verifying Device Support and User Permission

Make sure your app can use ARKit and respects user privacy.

ARConfiguration

The abstract base class for AR session configurations.