# Class ARReferenceImage

java.lang.Object
com.codename1.ar.ARReferenceImage

public final class ARReferenceImage extends Object

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.

- ## Constructor Summary

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

- ## Method Summary

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

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ARReferenceImage

    public ARReferenceImage(String name, byte[] encodedImage, float physicalWidthMeters)

    Creates a reference image from encoded (PNG or JPEG) bytes.

    ###### Parameters

    - `name`: a unique name identifying this image in `ARImageAnchor`s

    - `encodedImage`: the PNG or JPEG bytes of the image to detect

    - `physicalWidthMeters`: 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`: a unique name identifying this image in `ARImageAnchor`s

    - `image`: the image to detect

    - `physicalWidthMeters`: 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.