Google is committed to advancing racial equity for Black communities. See how.

GoogleARCore.Session


Represents an ARCore session, which is an attachment point from the app to the ARCore service.

Summary

Holds information about the global state for ARCore, manages tracking of Anchors and Planes, and performs hit tests against objects ARCore is tracking in the world.

Properties

LostTrackingReason
Gets the reason for ARCore having lost tracking.
PlaybackStatus
Gets the current state of playback.
RecordingStatus
Gets the current state of the recorder.
Status
static SessionStatus
Gets current session status.

Public static functions

CheckApkAvailability()
AsyncTask< ApkAvailabilityStatus >
Checks the availability of the ARCore APK on the device.
CreateAnchor(Pose pose, Trackable trackable)
Creates a new Anchor at the given Pose that is attached to the Trackable.
GetCameraConfig()
Get the camera configuration the ARCore session is currently running with.
GetTrackables< T >(List< T > trackables, TrackableQueryFilter filter)
void
Gets Trackables ARCore has tracked.
IsDepthModeSupported(DepthMode depthMode)
bool
Check whether the depth mode is supported on this device.
RequestApkInstallation(bool userRequested)
AsyncTask< ApkInstallationStatus >
Requests an installation of the ARCore APK on the device.
SetPlaybackDataset(string datasetFilepath)
Sets an MP4 dataset file to play back instead of using the live camera feed and IMU sensor data.
SetPlaybackDatasetUri(Uri datasetUri)
Sets the uri for a dataset to be played back.
StartRecording(ARCoreRecordingConfig config)
Starts a new recording, using the provided ARCoreRecordingConfig to define the location to save the dataset and other options.
StopRecording()
Stops the current recording.

Properties

LostTrackingReason

static LostTrackingReason LostTrackingReason

Gets the reason for ARCore having lost tracking.

PlaybackStatus

static PlaybackStatus PlaybackStatus

Gets the current state of playback.

Details
Returns
The current PlaybackStatus.

RecordingStatus

static RecordingStatus RecordingStatus

Gets the current state of the recorder.

Details
Returns
The current RecordingStatus.

Status

static SessionStatus Status

Gets current session status.

Public static functions

CheckApkAvailability

AsyncTask< ApkAvailabilityStatus > CheckApkAvailability()

Checks the availability of the ARCore APK on the device.

Details
Returns
An AsyncTask that completes with an ApkAvailabilityStatus when the availability is known.

CreateAnchor

Anchor CreateAnchor(
  Pose pose,
  Trackable trackable
)

Creates a new Anchor at the given Pose that is attached to the Trackable.

If trackable is null, it creates a new anchor at a world pose. As ARCore updates its understading of the space, it will update the virtual pose of the of the anchor to attempt to keep the anchor in the same real world location.

Details
Parameters
pose
The Unity world pose where the anchor is to be creates.
trackable
The Trackable to attach the Anchor to.
Returns
The newly created anchor or null.

GetCameraConfig

CameraConfig GetCameraConfig()

Get the camera configuration the ARCore session is currently running with.

Details
Returns
The CameraConfig that the ARCore session is currently running with. The value is only correct when there is a valid running ARCore session.

GetTrackables< T >

void GetTrackables< T >(
  List< T > trackables,
  TrackableQueryFilter filter
)

Gets Trackables ARCore has tracked.

Details
Template Parameters
T
The Trackable type to get.
Parameters
trackables
A reference to a list of T that will be filled by the method call.
filter
A filter on the type of data to return.

IsDepthModeSupported

bool IsDepthModeSupported(
  DepthMode depthMode
)

Check whether the depth mode is supported on this device.

Not all devices support depth, see the ARCore supported devices page for details.

Details
Parameters
depthMode
The depth mode.
Returns
true if the depth mode is supported, false if it is not supported or the session has not yet been initialized.

RequestApkInstallation

AsyncTask< ApkInstallationStatus > RequestApkInstallation(
  bool userRequested
)

Requests an installation of the ARCore APK on the device.

Details
Parameters
userRequested
Whether the installation was requested explicitly by a user action.
Returns
An AsyncTask that completes with an ApkInstallationStatus when the installation status is resolved.

SetPlaybackDataset

PlaybackResult SetPlaybackDataset(
  string datasetFilepath
)

Sets an MP4 dataset file to play back instead of using the live camera feed and IMU sensor data.

Restrictions:

  • Can only be called while the session is paused. Playback of the MP4 dataset file will start once the session is resumed.
  • The MP4 dataset file must use the same camera facing direction as is configured in the session.
  • Due to the way session data is processed, ARCore APIs may sometimes produce different results during playback than during recording and produce different results during subsequent playback sessions. For exmaple, the number of detected planes and other trackables, the precise timing of their detection and their pose over time may be different in subsequent playback sessions.
  • Once playback has started pausing the session (by disabling the ARCoreSession) will suspend processing of all camera image frames and any other recorded sensor data in the dataset. Camera image frames and sensor frame data that is discarded in this way will not be reprocessed when the session is again resumed (by re-enabling the ARCoreSession). AR tracking for the session will generally suffer due to the gap in processed data.

Details
Parameters
datasetFilepath
The filepath of the MP4 dataset. Null if stopping the playback and resuming a live feed.
Returns
PlaybackResult.Success if playback filepath was set without issue. Otherwise, the PlaybackResult will indicate the error.

SetPlaybackDatasetUri

PlaybackResult SetPlaybackDatasetUri(
  Uri datasetUri
)

Sets the uri for a dataset to be played back.

The ARCore Session must be paused when using this method. Resume the Session for the change to take effect. The AbsoluteUri property of the Uri will be passed to ARCore to create an android.net.Uri.

The uri must point to a seekable resource.

See SetPlaybackDataset(string) for more restrictions.

Details
Parameters
datasetUri
The uri of the MP4 dataset. Null if stopping the playback and resuming a live feed.
Returns
PlaybackResult.Success if playback uri was set without issue. Otherwise, the PlaybackResult will indicate the error.

StartRecording

RecordingResult StartRecording(
  ARCoreRecordingConfig config
)

Starts a new recording, using the provided ARCoreRecordingConfig to define the location to save the dataset and other options.

If a recording is already in progress this call will fail, check the RecordingStatus before making this call. When an ARCore session is paused, recording may continue, during this time the camera feed will be recorded as a black screen, but sensor data will continue to be captured.

Details
Parameters
config
ARCoreRecordingConfig containing the path to save the dataset along with other recording options.
Returns
RecordingResult.OK if the recording is started (or will start on the next Session resume.) Or a RecordingResult if there was an error.

StopRecording

RecordingResult StopRecording()

Stops the current recording.

If there is no recording in progress, this method will return RecordingResult.OK.

Details
Returns
RecordingResult.OK if the recording was stopped successfully, or RecordingResult.ErrorRecordingFailed if there was an error.