Camera

public class Camera

Provides information about the camera that is used to capture images. The Camera is a long-lived object and the properties of Camera are updated every time Session.update() is called.

Protected Constructors

Camera()
(FOR TESTING) Constructs a new instance for use as a mock.

Public Methods

boolean
equals(Object obj)
Indicates whether some other object is a Camera referencing the same logical camera as this one.
Pose
getDisplayOrientedPose()
Returns the virtual camera pose in world space for rendering AR content onto the latest frame.
CameraIntrinsics
getImageIntrinsics()
Returns the unrotated camera intrinsics for the CPU image.
Pose
getPose()
Returns the pose of the physical camera in world space for the latest frame.
void
getProjectionMatrix(float[] dest, int offset, float near, float far)
Returns a projection matrix for rendering virtual content on top of the camera image.
CameraIntrinsics
getTextureIntrinsics()
Returns the unrotated camera intrinsics for the GPU texture.
TrackingFailureReason
getTrackingFailureReason()
Returns the reason that getTrackingState() is PAUSED.
TrackingState
getTrackingState()
Returns the current motion tracking state of this camera.
void
getViewMatrix(float[] viewMatrix, int offset)
Returns the view matrix for the camera for this frame.
int
hashCode()
Returns a hash code value for the object.

Inherited Methods

Protected Constructors

protected Camera ()

(FOR TESTING) Constructs a new instance for use as a mock. Calling any base method implementation on this instance (including even equals(Object) and hashCode()) may return unexpected results, throw an exception, or even crash.

To obtain a Camera normally, use getCamera().

Public Methods

public boolean equals (Object obj)

Indicates whether some other object is a Camera referencing the same logical camera as this one.

Parameters
obj the reference object with which to compare.
Returns
  • true if this object is the same as the obj argument; false otherwise.

public Pose getDisplayOrientedPose ()

Returns the virtual camera pose in world space for rendering AR content onto the latest frame. This is an OpenGL camera pose with +X pointing right, +Y pointing up, and -Z pointing in the direction the camera is looking, with "right" and "up" being relative to current logical display orientation.

See Also:

Note: This pose is only useful when getTrackingState() returns TRACKING and otherwise should not be used.

public CameraIntrinsics getImageIntrinsics ()

Returns the unrotated camera intrinsics for the CPU image.

public Pose getPose ()

Returns the pose of the physical camera in world space for the latest frame. This is an OpenGL camera pose with +X pointing right, +Y pointing right up, and -Z pointing in the direction the camera is looking, with "right" and "up" being relative to the image readout in the usual left-to-right, top-to-bottom order. Specifically, this is the camera pose at the center of exposure of the center row of the image.

For applications using the SDK for ARCore 1.5 and earlier, the returned pose is rotated around the Z axis by a multiple of 90° so that the axes correspond approximately to those of the Android Sensor Coordinate System.

See Also:

Note: This pose is only useful when getTrackingState() returns TRACKING and otherwise should not be used.

public void getProjectionMatrix (float[] dest, int offset, float near, float far)

Returns a projection matrix for rendering virtual content on top of the camera image. Note that the projection matrix reflects the current display geometry and display rotation.

Note: When using FRONT_CAMERA, the returned projection matrix will incorporate a horizontal flip.

Parameters
dest storage for at least 16 floats representing a 4x4 matrix in column major order
offset the offset in dest at which to begin writing the matrix (often 0)
near specifies the near clip plane, in meters
far specifies the far clip plane, in meters

public CameraIntrinsics getTextureIntrinsics ()

Returns the unrotated camera intrinsics for the GPU texture.

public TrackingFailureReason getTrackingFailureReason ()

Returns the reason that getTrackingState() is PAUSED.

Returns NONE briefly after resume(), while the motion tracking is initializing. Always returns NONE when getTrackingState() is TRACKING.

If multiple potential causes for motion tracking failure are detected, this reports the most actionable failure reason.

Returns
  • the reason for motion tracking failure.

public TrackingState getTrackingState ()

Returns the current motion tracking state of this camera. If this state is anything other than TRACKING the pose should not be considered useful. Use getTrackingFailureReason() to determine the best recommendation to provide to the user to restore motion tracking.

public void getViewMatrix (float[] viewMatrix, int offset)

Returns the view matrix for the camera for this frame. Note that the view matrix incorporates the display orientation. This is equivalent to: camera.getDisplayOrientedPose().inverse().asMatrix()

Parameters
viewMatrix storage for at least 16 floats representing a 4x4 matrix in column major order
offset the offset in viewMatrix at which to begin writing the matrix

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

Returns
  • a hash code value for this object.
See Also

Send feedback about...