Camera

Provides information about the camera that is used to capture images.

Summary

Typedefs

ArCamera typedef
struct ArCamera_
The virtual and physical camera (reference type, long-lived).

Functions

ArCamera_getDisplayOrientedPose(const ArSession *session, const ArCamera *camera, ArPose *out_pose)
void
Sets out_pose to the pose of the user's device in the world coordinate space at the time of capture of the current camera texture.
ArCamera_getImageIntrinsics(const ArSession *session, const ArCamera *camera, ArCameraIntrinsics *out_camera_intrinsics)
void
Retrieves the unrotated and uncropped intrinsics for the image (CPU) stream.
ArCamera_getPose(const ArSession *session, const ArCamera *camera, ArPose *out_pose)
void
Sets out_pose to the pose of the user's device in the world coordinate space at the time of capture of the current camera texture.
ArCamera_getProjectionMatrix(const ArSession *session, const ArCamera *camera, float near, float far, float *dest_col_major_4x4)
void
Computes a projection matrix for rendering virtual content on top of the camera image.
ArCamera_getTextureIntrinsics(const ArSession *session, const ArCamera *camera, ArCameraIntrinsics *out_camera_intrinsics)
void
Retrieves the unrotated and uncropped intrinsics for the texture (GPU) stream.
ArCamera_getTrackingState(const ArSession *session, const ArCamera *camera, ArTrackingState *out_tracking_state)
void
Gets the current state of the pose of this camera.
ArCamera_getViewMatrix(const ArSession *session, const ArCamera *camera, float *out_col_major_4x4)
void
Returns the view matrix for the camera for this frame.
ArCamera_release(ArCamera *camera)
void
Releases a reference to the camera.

Typedefs

ArCamera

struct ArCamera_ ArCamera

The virtual and physical camera (reference type, long-lived).

Acquire with ArFrame_acquireCamera()
Release with ArCamera_release()

Functions

ArCamera_getDisplayOrientedPose

void ArCamera_getDisplayOrientedPose(
  const ArSession *session,
  const ArCamera *camera,
  ArPose *out_pose
)

Sets out_pose to the pose of the user's device in the world coordinate space at the time of capture of the current camera texture.

The position of the pose is located at the device's camera, while the orientation approximately matches the orientation of the display (considering display rotation), using OpenGL camera conventions (+X right, +Y up, -Z in the direction the camera is looking).

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

See also: ArCamera_getViewMatrix()

Details
Parameters
session
The ARCore session
camera
The session's camera (retrieved from any frame).
out_pose
An already-allocated ArPose object into which the pose will be stored.

ArCamera_getImageIntrinsics

void ArCamera_getImageIntrinsics(
  const ArSession *session,
  const ArCamera *camera,
  ArCameraIntrinsics *out_camera_intrinsics
)

Retrieves the unrotated and uncropped intrinsics for the image (CPU) stream.

The intrinsics may change per frame, so this should be called on each frame to get the intrinsics for the current frame.

Details
Parameters
session
The ARCore session
camera
The session's camera.
out_camera_intrinsics
The camera_intrinsics data.

ArCamera_getPose

void ArCamera_getPose(
  const ArSession *session,
  const ArCamera *camera,
  ArPose *out_pose
)

Sets out_pose to the pose of the user's device in the world coordinate space at the time of capture of the current camera texture.

The position and orientation of the pose follow the device's physical camera (they are not affected by display orientation). However, due to a bug the resulting pose is rotated around the Z axis by a multiple of 90 degrees to (approximately) align the axes with those of the Android Sensor Coordinate System.

This bug will be fixed in an upcoming version of ARCore. Existing applications will continue to see the behavior of the ARCore SDK version that was compiled with the app.

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

Details
Parameters
session
The ARCore session
camera
The session's camera (retrieved from any frame).
out_pose
An already-allocated ArPose object into which the pose will be stored.

ArCamera_getProjectionMatrix

void ArCamera_getProjectionMatrix(
  const ArSession *session,
  const ArCamera *camera,
  float near,
  float far,
  float *dest_col_major_4x4
)

Computes 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.

Details
Parameters
session
The ARCore session
camera
The session's camera.
near
Specifies the near clip plane, in meters
far
Specifies the far clip plane, in meters
dest_col_major_4x4
Pointer to an array of 16 floats, to be filled with a column-major homogenous transformation matrix, as used by OpenGL.

ArCamera_getTextureIntrinsics

void ArCamera_getTextureIntrinsics(
  const ArSession *session,
  const ArCamera *camera,
  ArCameraIntrinsics *out_camera_intrinsics
)

Retrieves the unrotated and uncropped intrinsics for the texture (GPU) stream.

The intrinsics may change per frame, so this should be called on each frame to get the intrinsics for the current frame.

Details
Parameters
session
The ARCore session
camera
The session's camera.
out_camera_intrinsics
The camera_intrinsics data.

ArCamera_getTrackingState

void ArCamera_getTrackingState(
  const ArSession *session,
  const ArCamera *camera,
  ArTrackingState *out_tracking_state
)

Gets the current state of the pose of this camera.

If this state is anything other than AR_TRACKING_STATE_TRACKING the Camera's pose should not be considered useful.

ArCamera_getViewMatrix

void ArCamera_getViewMatrix(
  const ArSession *session,
  const ArCamera *camera,
  float *out_col_major_4x4
)

Returns the view matrix for the camera for this frame.

This matrix performs the inverse transform as the pose provided by ArCamera_getDisplayOrientedPose().

Details
Parameters
session
The ARCore session
camera
The session's camera.
out_col_major_4x4
Pointer to an array of 16 floats, to be filled with a column-major homogenous transformation matrix, as used by OpenGL.

ArCamera_release

void ArCamera_release(
  ArCamera *camera
)

Releases a reference to the camera.

This must match a call to ArFrame_acquireCamera().

This method may safely be called with nullptr - it will do nothing.

Send feedback about...