public final class ARReferenceImage

  1. Object
  2. ARReferenceImage

A 2D image the AR session should recognize in the real world - a poster, a game board, a product label. Register reference images through ARSessionOptions#referenceImages(ARReferenceImage[]); when the camera sees one, the session delivers an ARImageAnchor carrying this image’s name.

The physical width tells the platform how large the printed image is in the real world, which it needs to estimate the image’s distance and pose accurately.

Constructors

public ARReferenceImage(String name, byte[] encodedImage, float physicalWidthMeters)Creates a reference image from encoded (PNG or JPEG) bytes.
public ARReferenceImage(String name, Image image, float physicalWidthMeters)Creates a reference image from an Image, encoding it as PNG.

Methods

public String getName()The unique name identifying this image.
public byte[] getEncodedImage()The encoded (PNG or JPEG) bytes of the image as a newly allocated array.
public float getPhysicalWidthMeters()The width of the printed image in meters.

Inherited methods

Constructor details

ARReferenceImage

public ARReferenceImage(String name, byte[] encodedImage, float physicalWidthMeters)
Creates a reference image from encoded (PNG or JPEG) bytes.

Parameters

name String
a unique name identifying this image in ARImageAnchors
encodedImage byte[]
the PNG or JPEG bytes of the image to detect
physicalWidthMeters float
the width of the printed image in meters

ARReferenceImage

public ARReferenceImage(String name, Image image, float physicalWidthMeters)
Creates a reference image from an Image, encoding it as PNG.

Parameters

name String
a unique name identifying this image in ARImageAnchors
image Image
the image to detect
physicalWidthMeters float
the width of the printed image in meters

Method details

getName

public String getName()
The unique name identifying this image.

getEncodedImage

public byte[] getEncodedImage()
The encoded (PNG or JPEG) bytes of the image as a newly allocated array.

getPhysicalWidthMeters

public float getPhysicalWidthMeters()
The width of the printed image in meters.