Most visited

Recently visited

ARImageTarget

public class ARImageTarget
extends Object

java.lang.Object
   ↳ com.viro.core.ARImageTarget


ARImageTarget contains all the information required to find and track an image and extract its pose information. To use image targets:

  1. Create an ARImageTarget representing the image you would like to find in the real-world.
  2. Add the ARImageTarget to your app by using addARImageTarget(ARImageTarget).
  3. Once an image target is added to the scene, you will receive a callback when an instance of that image is detected in the world. The callback will come through onAnchorFound(ARAnchor, ARNode), with an anchor of type ARImageAnchor.
  4. Use getAnchorId() and compare against getId() to identify which of your targets was found in the world.

Note that for each ARImageTarget added to the scene, there will be only one instance of that target found.

Summary

Nested classes

enum ARImageTarget.Orientation

The orientation of the image to detect in the real world, with respect to the base orientation of your input image. 

Public constructors

ARImageTarget(Bitmap image, ARImageTarget.Orientation orientation, float physicalWidth)

Creates a ARImageTarget object to be given to ViroViewARCore to start looking for and tracking the specified image.

Public methods

void dispose()

Release native resources associated with this ARImageTarget.

String getId()

Get the ID of this ARImageTarget, which corresponds to the ID returned by getAnchorId() when this target is found.

ARImageTarget.Orientation getOrientation()

Get the ARImageTarget.Orientation of this ARImageTarget.

float getPhysicalWidth()

Get the physical width (in meters) of this ARImageTarget.

Public constructors

ARImageTarget

ARImageTarget (Bitmap image, 
                ARImageTarget.Orientation orientation, 
                float physicalWidth)

Creates a ARImageTarget object to be given to ViroViewARCore to start looking for and tracking the specified image.

Parameters
image Bitmap: The Bitmap containing the image to track.

orientation ARImageTarget.Orientation: The ARImageTarget.Orientation of the given Bitmap, which indicates where the top of the image is. For example, if the input image is an upside-down dollar bill, you would set the orientation to Down to identify right-side-up dollar bills in the world. Set to Up to indicate you want to identify the image as-is without any rotation.

physicalWidth float: The real-world width of the image in meters. Note this is the width post-orientation.

Public methods

dispose

void dispose ()

Release native resources associated with this ARImageTarget.

getId

String getId ()

Get the ID of this ARImageTarget, which corresponds to the ID returned by getAnchorId() when this target is found.

Returns
String The ID of this target.

getOrientation

ARImageTarget.Orientation getOrientation ()

Get the ARImageTarget.Orientation of this ARImageTarget.

Returns
ARImageTarget.Orientation The orientation of this target.

getPhysicalWidth

float getPhysicalWidth ()

Get the physical width (in meters) of this ARImageTarget. This width is post-orientation.

Returns
float The physical width in meters.

Hooray!