Frame

Per-frame state.

Summary

Typedefs

ArFrame typedef
struct ArFrame_
The world state resulting from an update (value type).

Functions

ArFrame_acquireCamera(const ArSession *session, const ArFrame *frame, ArCamera **out_camera)
void
Returns the camera object for the session.
ArFrame_acquireCameraImage(ArSession *session, ArFrame *frame, ArImage **out_image)
Returns the CPU image for the current frame.
ArFrame_acquireImageMetadata(const ArSession *session, const ArFrame *frame, ArImageMetadata **out_metadata)
Gets the camera metadata for the current camera image.
ArFrame_acquirePointCloud(const ArSession *session, const ArFrame *frame, ArPointCloud **out_point_cloud)
Acquires the current set of estimated 3d points attached to real-world geometry.
ArFrame_create(const ArSession *session, ArFrame **out_frame)
void
Allocates a new ArFrame object, storing the pointer into *out_frame.
ArFrame_destroy(ArFrame *frame)
void
Releases an ArFrame and any references it holds.
ArFrame_getAndroidSensorPose(const ArSession *session, const ArFrame *frame, ArPose *out_pose)
void
Sets out_pose to the pose of the Android Sensor Coordinate System in the world coordinate space at the time of capture of the current camera texture.
ArFrame_getDisplayGeometryChanged(const ArSession *session, const ArFrame *frame, int32_t *out_geometry_changed)
void
Checks if the display rotation or viewport geometry changed since the previous call to ArSession_update().
ArFrame_getLightEstimate(const ArSession *session, const ArFrame *frame, ArLightEstimate *out_light_estimate)
void
Gets the current ambient light estimate, if light estimation was enabled.
ArFrame_getTimestamp(const ArSession *session, const ArFrame *frame, int64_t *out_timestamp_ns)
void
Returns the timestamp in nanoseconds when this image was captured.
ArFrame_getUpdatedAnchors(const ArSession *session, const ArFrame *frame, ArAnchorList *out_anchor_list)
void
Gets the set of anchors that were changed by the ArSession_update() that produced this Frame.
ArFrame_getUpdatedTrackables(const ArSession *session, const ArFrame *frame, ArTrackableType filter_type, ArTrackableList *out_trackable_list)
void
Gets the set of trackables of a particular type that were changed by the ArSession_update() call that produced this Frame.
ArFrame_hitTest(const ArSession *session, const ArFrame *frame, float pixel_x, float pixel_y, ArHitResultList *hit_result_list)
void
Performs a ray cast from the user's device in the direction of the given location in the camera view.
ArFrame_hitTestRay(const ArSession *session, const ArFrame *frame, const float *ray_origin_3, const float *ray_direction_3, ArHitResultList *hit_result_list)
void
Similar to ArFrame_hitTest, but takes an arbitrary ray in world space coordinates instead of a screen space point.
ArFrame_transformDisplayUvCoords(const ArSession *session, const ArFrame *frame, int32_t num_elements, const float *uvs_in, float *uvs_out)
void
Transform the given texture coordinates to correctly show the background image.

Typedefs

ArFrame

struct ArFrame_ ArFrame

The world state resulting from an update (value type).

Allocate with ArFrame_create()
Populate with ArSession_update()
Release with ArFrame_destroy()

Functions

ArFrame_acquireCamera

void ArFrame_acquireCamera(
  const ArSession *session,
  const ArFrame *frame,
  ArCamera **out_camera
)

Returns the camera object for the session.

Note that this Camera instance is long-lived so the same instance is returned regardless of the frame object this method was called on.

ArFrame_acquireCameraImage

ArStatus ArFrame_acquireCameraImage(
  ArSession *session,
  ArFrame *frame,
  ArImage **out_image
)

Returns the CPU image for the current frame.

Caller is responsible for later releasing the image with ArImage_release. Return values:

Details
Returns
AR_SUCCESS or any of:

ArFrame_acquireImageMetadata

ArStatus ArFrame_acquireImageMetadata(
  const ArSession *session,
  const ArFrame *frame,
  ArImageMetadata **out_metadata
)

Gets the camera metadata for the current camera image.

Details
Returns
AR_SUCCESS or any of:

ArFrame_acquirePointCloud

ArStatus ArFrame_acquirePointCloud(
  const ArSession *session,
  const ArFrame *frame,
  ArPointCloud **out_point_cloud
)

Acquires the current set of estimated 3d points attached to real-world geometry.

A matching call to PointCloud_release() must be made when the application is done accessing the point cloud.

Note: This information is for visualization and debugging purposes only. Its characteristics and format are subject to change in subsequent versions of the API.

Details
Parameters
session
The ARCore session.
frame
The current frame.
out_point_cloud
Pointer to an ArPointCloud* receive the address of the point cloud.
Returns
AR_SUCCESS or any of:

ArFrame_create

void ArFrame_create(
  const ArSession *session,
  ArFrame **out_frame
)

Allocates a new ArFrame object, storing the pointer into *out_frame.

Note: the same ArFrame can be used repeatedly when calling ArSession_update.

ArFrame_destroy

void ArFrame_destroy(
  ArFrame *frame
)

Releases an ArFrame and any references it holds.

ArFrame_getAndroidSensorPose

void ArFrame_getAndroidSensorPose(
  const ArSession *session,
  const ArFrame *frame,
  ArPose *out_pose
)

Sets out_pose to the pose of the Android Sensor Coordinate System in the world coordinate space at the time of capture of the current camera texture.

The orientation follows the device's "native" orientation (it is not affected by display orientation).

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
frame
The current frame.
out_pose
An already-allocated ArPose object into which the pose will be stored.

ArFrame_getDisplayGeometryChanged

void ArFrame_getDisplayGeometryChanged(
  const ArSession *session,
  const ArFrame *frame,
  int32_t *out_geometry_changed
)

Checks if the display rotation or viewport geometry changed since the previous call to ArSession_update().

The application should re-query ArCamera_getProjectionMatrix() and ArFrame_transformDisplayUvCoords() whenever this emits non-zero.

ArFrame_getLightEstimate

void ArFrame_getLightEstimate(
  const ArSession *session,
  const ArFrame *frame,
  ArLightEstimate *out_light_estimate
)

Gets the current ambient light estimate, if light estimation was enabled.

Details
Parameters
session
The ARCore session.
frame
The current frame.
out_light_estimate
The light estimate to fill. This object must have been previously created with ArLightEstimate_create().

ArFrame_getTimestamp

void ArFrame_getTimestamp(
  const ArSession *session,
  const ArFrame *frame,
  int64_t *out_timestamp_ns
)

Returns the timestamp in nanoseconds when this image was captured.

This can be used to detect dropped frames or measure the camera frame rate. The time base of this value is specifically not defined, but it is likely similar to clock_gettime(CLOCK_BOOTTIME).

ArFrame_getUpdatedAnchors

void ArFrame_getUpdatedAnchors(
  const ArSession *session,
  const ArFrame *frame,
  ArAnchorList *out_anchor_list
)

Gets the set of anchors that were changed by the ArSession_update() that produced this Frame.

Details
Parameters
session
The ARCore session
frame
The current frame.
out_anchor_list
The list to fill. This list must have already been allocated with ArAnchorList_create(). If previously used, the list will first be cleared.

ArFrame_getUpdatedTrackables

void ArFrame_getUpdatedTrackables(
  const ArSession *session,
  const ArFrame *frame,
  ArTrackableType filter_type,
  ArTrackableList *out_trackable_list
)

Gets the set of trackables of a particular type that were changed by the ArSession_update() call that produced this Frame.

Details
Parameters
session
The ARCore session
frame
The current frame.
filter_type
The type(s) of trackables to return. See ArTrackableType for legal values.
out_trackable_list
The list to fill. This list must have already been allocated with ArTrackableList_create(). If previously used, the list will first be cleared.

ArFrame_hitTest

void ArFrame_hitTest(
  const ArSession *session,
  const ArFrame *frame,
  float pixel_x,
  float pixel_y,
  ArHitResultList *hit_result_list
)

Performs a ray cast from the user's device in the direction of the given location in the camera view.

Intersections with detected scene geometry are returned, sorted by distance from the device; the nearest intersection is returned first.

Note: Significant geometric leeway is given when returning hit results. For example, a plane hit may be generated if the ray came close, but did not actually hit within the plane extents or plane bounds (ArPlane_isPoseInExtents() and ArPlane_isPoseInPolygon() can be used to determine these cases). A point (point cloud) hit is generated when a point is roughly within one finger-width of the provided screen coordinates.

The resulting list is ordered by distance, with the nearest hit first

Note: If not tracking, the hit_result_list will be empty.
Note: If called on an old frame (not the latest produced by ArSession_update() the hit_result_list will be empty).

Details
Parameters
session
The ARCore session.
frame
The current frame.
pixel_x
Logical X position within the view, as from an Android UI event.
pixel_y
Logical X position within the view.
hit_result_list
The list to fill. This list must have been previously allocated using ArHitResultList_create(). If the list has been previously used, it will first be cleared.

ArFrame_hitTestRay

void ArFrame_hitTestRay(
  const ArSession *session,
  const ArFrame *frame,
  const float *ray_origin_3,
  const float *ray_direction_3,
  ArHitResultList *hit_result_list
)

Similar to ArFrame_hitTest, but takes an arbitrary ray in world space coordinates instead of a screen space point.

Details
Parameters
session
The ARCore session.
frame
The current frame.
ray_origin_3
A pointer to float[3] array containing ray origin in world space coordinates.
ray_direction_3
A pointer to float[3] array containing ray direction in world space coordinates. Does not have to be normalized.
hit_result_list
The list to fill. This list must have been previously allocated using ArHitResultList_create(). If the list has been previously used, it will first be cleared.

ArFrame_transformDisplayUvCoords

void ArFrame_transformDisplayUvCoords(
  const ArSession *session,
  const ArFrame *frame,
  int32_t num_elements,
  const float *uvs_in,
  float *uvs_out
)

Transform the given texture coordinates to correctly show the background image.

This will account for the display rotation, and any additional required adjustment. For performance, this function should be called only if ArFrame_hasDisplayGeometryChanged() emits true.

Details
Parameters
session
The ARCore session
frame
The current frame.
num_elements
The number of floats to transform. Must be a multiple of 2. uvs_in and uvs_out must point to arrays of at least this many floats.
uvs_in
Input UV coordinates in normalized screen space.
uvs_out
Output UV coordinates in texture coordinates.

Send feedback about...