Augmented Images developer guide for Unity

Learn how to use Augmented Images in your own apps.

Build and run the sample app

Create a new project in Unity based on the quickstart.

When building the app, make sure to include the augmented image scene located in Assets/GoogleARCore/Examples/AugmentedImage/Scenes/.

Make sure your device is connected to your machine and then click Build and Run. Unity builds your project into an Android APK, installs it on the device, and launches it.

As you move your device, the app automatically detects and tracks images from the set of reference images located in Assets/GoogleARCore/Examples/AugmentedImage/Images/.

Create database file

In Project window, select your desired set of reference images (PNG or JPG), then right-click and select Create > Google ARCore > AugmentedImageDatabase.

A new image database is created in the same folder as the reference images.

The Inspector window displays the images in the database and the image quality score. The system may struggle to detect images with quality scores below 75.

You can optionally specify a physical width (in meters) for each image. If you do so, ARCore can estimate the pose of the physical image at runtime as soon as ARCore detects the physical image, without requiring the user to move the device to view the physical image from different viewpoints.

Use the database file

  1. In the Project window, go to Assets/GoogleARCore/Examples/AugmentedImage/Configurations and open AugmentedImagesSessionConfig.

  2. In the Inspector, click the box next to Augmented Image Database and select the database file you created.

Get the AugmentedImage

See AugmentedImageExampleController.cs, located in Assets/GoogleARCore/Examples/AugmentedImage/Scripts, for an example on how to get the trackable:

Session.GetTrackables<AugmentedImage>(myList, TrackableQueryFilter.Updated);

Supporting different use cases

When ARCore detects an Augmented Image, it creates a Trackable for that Augmented Image and sets TrackingState to Tracking and AugmentedImageTrackingMethod to FullTracking. When the tracked image moves out of camera view, ARCore changes the AugmentedImageTrackingMethod to LastKnownPose while continuing to provide the orientation and position of the image.

Your app should use these enumerators differently depending on the intended use case.

  • Fixed images. Most use cases involving images that are fixed in place (that is, not expected to move) can simply use TrackingState to determine whether the image has been detected and whether its location is known. AugmentedImageTrackingMethod can be ignored.

  • Moving images. If your app needs to track a moving image, use both TrackingState and AugmentedImageTrackingMethod to determine whether the image has been detected and whether its position is known.

Use case Fixed image Moving image
Example A poster hung on a wall An advertisement on the side of a bus
The pose can be
considered valid when
TrackingState == Tracking TrackingState == Tracking
and
AugmentedImageTrackingMethod == FullTracking

フィードバックを送信...