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 session configuration: an instance of the ARConfiguration class, or its subclass ARWorldTrackingConfiguration. These classes 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.

Topics

Configuring and Running a Session

func run(ARConfiguration, options: ARSession.RunOptions = [])

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

struct ARSession.RunOptions

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

var configuration: ARConfiguration?

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

func pause()

Pauses processing in the session.

Responding to AR Updates

var delegate: ARSessionDelegate?

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

var delegateQueue: DispatchQueue?

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

protocol ARSessionDelegate

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

protocol ARSessionObserver

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

Displaying and Interacting with AR Content

var currentFrame: ARFrame?

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

func add(anchor: ARAnchor)

Adds the specified anchor to be tracked by the session.

func remove(anchor: ARAnchor)

Removes the specified anchor from tracking by the session.

Relationships

Inherits From

Conforms To

See Also

First Steps

About Augmented Reality and ARKit

Discover supporting concepts, features, and best practices for building great AR experiences.

class ARConfiguration

The abstract base class for AR session configurations.