Manages AR system state and handles the session lifecycle. This class is the main entry point to ARCore API. This class allows the user to create a session, configure it, start/stop it, and most importantly receive frames that allow access to camera image and device pose.
(FOR TESTING) Constructs a new instance for use as a mock.
Returns all known anchors, including those not currently tracked.
|<T extends Trackable> Collection<T>|
Pause the current session.
Starts or resumes the ARCore Session.
Sets the OpenGL texture name (id) that will allow GPU access to the camera image.
setDisplayGeometry(int displayRotation, int widthPx, int heightPx)
Sets the aspect ratio, coordinate scaling, and display rotation.
Updates the state of the ARCore system.
nativeAcquireAllTrackables(long sessionHandle, int filterType)
public Session (Context context)
Creates a new ARCore session. This must be the first ARCore action that your application takes.
|FatalException||if an internal error occurred while
creating the session.
|UnavailableArcoreNotInstalledException||if the ARCore APK is not present|
|UnavailableSdkTooOldException||if the ARCore SDK that this application was built with is too old and no longer supported by the installed ARCore APK.|
|UnavailableApkTooOldException||if the installed ARCore APK is too old for the ARCore SDK with which this application was built.|
|SecurityException||if client app fails to grant CameraPermission.|
|FatalException||if initialization failed for any other reason.|
protected Session ()
(FOR TESTING) Constructs a new instance for use as a mock. Calling any base method implementation on this instance may return unexpected results, throw an exception, or even crash.
To create a
Session normally, use
public void configure (Config config)
Configures the session.
A session initially has a default configuration. This should be called if a configuration
different than default is needed. Before calling this method, the configuration should be
|config||The new configuration setting for the session.|
public Collection<Anchor> getAllAnchors ()
public Collection<T> getAllTrackables (Class<T> filterType)
public boolean isSupported (Config config)
Checks if the provided configuration is usable on the this device. If this method returns
false, calls to
configure(Config) with this configuration will throw an exception.
|config||the configuration to test|
public void pause ()
public void resume ()
public void setCameraTextureName (int textureId)
Sets the OpenGL texture name (id) that will allow GPU access to the camera image. The provided
ID should have been created with
glGenTextures(int, int, int). The resulting
texture must be bound to the
GL_TEXTURE_EXTERNAL_OES target for use. Shaders
accessing this texture must use a
samplerExternalOES sampler. See sample code for an
|textureId||a valid OpenGL texture name (id)|
public void setDisplayGeometry (int displayRotation, int widthPx, int heightPx)
Sets the aspect ratio, coordinate scaling, and display rotation. This data is used by UV conversion, projection matrix generation, and hit test logic.
public Frame update ()
Updates the state of the ARCore system. This includes: receiving a new camera frame, updating the location of the device, updating the location of tracking anchors, updating detected planes, etc.
This call may cause off-screen OpenGL activity. Because of this, to avoid unnecessary frame buffer flushes and reloads, this call should not be made in the middle of rendering an frame or offscreen buffer.
This call may update the pose of all created Anchors and detected Planes. The set of updated
objects is accessible through
This call may block until a new camera frame is available. See
- The most recent Frame received
protected long nativeAcquireAllTrackables (long sessionHandle, int filterType)