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 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 ARImageAnchors

      • 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 ARImageAnchors

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