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

ArImage

Provides access to CPU camera images.

Summary

Enumerations

ArImageFormat{
  AR_IMAGE_FORMAT_INVALID = 0,
  AR_IMAGE_FORMAT_YUV_420_888 = 0x23,
  AR_IMAGE_FORMAT_DEPTH16 = 0x44363159,
  AR_IMAGE_FORMAT_RGBA_FP16 = 0x16
}
enum
Image formats produced by ARCore.

Typedefs

AImage typedef
struct AImage
Forward declaring the Android NDK AImage struct, which is used in ArImage_getNdkImage.
ArImage typedef
struct ArImage_
Accessing CPU image from the camera (reference type, large data).
ArImageCubemap[6] typedef
Convenient definition for cubemap image storage where it is a fixed size array of 6 ArImage.

Functions

ArImage_getFormat(const ArSession *session, const ArImage *image, ArImageFormat *out_format)
void
Gets the image format of the provided ArImage.
ArImage_getHeight(const ArSession *session, const ArImage *image, int32_t *out_height)
void
Gets the height of the input ArImage.
ArImage_getNdkImage(const ArImage *image, const AImage **out_ndk_image)
void
Deprecated. Deprecated in release 1.10.0. Use the other ArImage functions to obtain image data. ARCore can produce a wide variety of images, not all of which can be represented using Android NDK AImage provided by this function. In those cases, this function will return NULL in out_ndk_image.
Converts an ArImage object to an Android NDK AImage object.
ArImage_getNumberOfPlanes(const ArSession *session, const ArImage *image, int32_t *out_num_planes)
void
Gets the number of planes in the provided ArImage.
ArImage_getPlaneData(const ArSession *session, const ArImage *image, int32_t plane_index, const uint8_t **out_data, int32_t *out_data_length)
void
Gets the data pointer of the provided image for direct application access.
ArImage_getPlanePixelStride(const ArSession *session, const ArImage *image, int32_t plane_index, int32_t *out_pixel_stride)
void
Gets the byte distance between the start of two consecutive pixels in the image.
ArImage_getPlaneRowStride(const ArSession *session, const ArImage *image, int32_t plane_index, int32_t *out_row_stride)
void
Gets the number of bytes between the start of two consecutive rows of pixels in the image.
ArImage_getTimestamp(const ArSession *session, const ArImage *image, int64_t *out_timestamp_ns)
void
Gets the source-specific timestamp of the provided ArImage in nanoseconds.
ArImage_getWidth(const ArSession *session, const ArImage *image, int32_t *out_width)
void
Gets the width of the input ArImage.
ArImage_release(ArImage *image)
void
Releases an instance of ArImage returned by ArFrame_acquireCameraImage.

Enumerations

Typedefs

AImage

struct AImage AImage

Forward declaring the Android NDK AImage struct, which is used in ArImage_getNdkImage.

ArImage

struct ArImage_ ArImage

Accessing CPU image from the camera (reference type, large data).

ArImageCubemap

ArImage * ArImageCubemap[6]

Convenient definition for cubemap image storage where it is a fixed size array of 6 ArImage.

Functions

ArImage_getFormat

void ArImage_getFormat(
  const ArSession *session,
  const ArImage *image,
  ArImageFormat *out_format
)

Gets the image format of the provided ArImage.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
out_format
The image format, one of ArImageFormat values.

ArImage_getHeight

void ArImage_getHeight(
  const ArSession *session,
  const ArImage *image,
  int32_t *out_height
)

Gets the height of the input ArImage.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
out_height
The height of the image in pixels.

ArImage_getNdkImage

void ArImage_getNdkImage(
  const ArImage *image,
  const AImage **out_ndk_image
)

Converts an ArImage object to an Android NDK AImage object.

The converted image object format is AIMAGE_FORMAT_YUV_420_888.

Deprecated. Deprecated in release 1.10.0. Use the other ArImage functions to obtain image data. ARCore can produce a wide variety of images, not all of which can be represented using Android NDK AImage provided by this function. In those cases, this function will return NULL in out_ndk_image.

ArImage_getNumberOfPlanes

void ArImage_getNumberOfPlanes(
  const ArSession *session,
  const ArImage *image,
  int32_t *out_num_planes
)

Gets the number of planes in the provided ArImage.

The number of planes and format of data in each plane is format dependent. Use ArImage_getFormat to determine the format.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
out_num_planes
The number of planes in the image.

ArImage_getPlaneData

void ArImage_getPlaneData(
  const ArSession *session,
  const ArImage *image,
  int32_t plane_index,
  const uint8_t **out_data,
  int32_t *out_data_length
)

Gets the data pointer of the provided image for direct application access.

Note that once the ArImage data is released with ArImage_release, the data pointer from the corresponding ArImage_getPlaneData call becomes invalid. Do NOT use it after the ArImage is released.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
plane_index
The index of the plane, between 0 and n-1, where n is number of planes for this image.
out_data
The data pointer to the image.
out_data_length
The length of data in bytes.

ArImage_getPlanePixelStride

void ArImage_getPlanePixelStride(
  const ArSession *session,
  const ArImage *image,
  int32_t plane_index,
  int32_t *out_pixel_stride
)

Gets the byte distance between the start of two consecutive pixels in the image.

The pixel stride is always greater than 0.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
plane_index
The index of the plane, between 0 and n-1, where n is number of planes for this image.
out_pixel_stride
The plane stride of the image in bytes.

ArImage_getPlaneRowStride

void ArImage_getPlaneRowStride(
  const ArSession *session,
  const ArImage *image,
  int32_t plane_index,
  int32_t *out_row_stride
)

Gets the number of bytes between the start of two consecutive rows of pixels in the image.

The row stride is always greater than 0.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
plane_index
The index of the plane, between 0 and n-1, where n is number of planes for this image.
out_row_stride
The row stride of the image in bytes.

ArImage_getTimestamp

void ArImage_getTimestamp(
  const ArSession *session,
  const ArImage *image,
  int64_t *out_timestamp_ns
)

Gets the source-specific timestamp of the provided ArImage in nanoseconds.

The timestamp is normally monotonically increasing. The timestamps for the images from different sources may have different timebases and should not be compared with each other. The specific meaning and timebase of the returned timestamp depends on the source providing images.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
out_timestamp_ns
The timestamp of the image in nanoseconds.

ArImage_getWidth

void ArImage_getWidth(
  const ArSession *session,
  const ArImage *image,
  int32_t *out_width
)

Gets the width of the input ArImage.

Details
Parameters
session
The ARCore session.
image
The ArImage of interest.
out_width
The width of the image in pixels.

ArImage_release

void ArImage_release(
  ArImage *image
)

Releases an instance of ArImage returned by ArFrame_acquireCameraImage.