Augmented Images
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/
.
Augmented Images
The Augmented Images APIs in ARCore lets you build AR apps that can detect and augment 2D images in the user's environment, such as posters or product packaging.
You provide a set of reference images. ARCore uses a computer vision algorithm to extract features from each image, and stores a representation of these features in one or more Augmented Image databases.
At runtime, ARCore searches for these features on flat surfaces in the user's environment. This lets ARCore detect these images in the world and estimate their position, orientation, and size if one is not provided.
ARCore can track up to 20 images simultaneously. ARCore will not simultaneously detect or track multiple instances of the same image.
Each Augmented Image database can store information up to 1,000 reference images. There's no limit to the number of databases, but only one database can be active at any given time.
Images can be added to an Augmented Image database at runtime, up to the 1,000-image per-database limit.
ARCore can respond to and track images that are:
- Images that are fixed in place, such as a print hanging on a wall or a magazine on a table
Moving images, such as an advertisement on a passing bus or an image on a flat object held by the user as they move their hands around.
Images must:
- Fill at least 25% of the camera frame to be initially detected.
- Be flat (for example, not wrinkled or wrapped around a bottle).
- Be in clear view of the camera. They should not be partially obscured, viewed at a highly oblique angle, or viewed when the camera is moving too fast due to motion blur.
- The image's resolution should be at least 300 x 300 pixels. Using images with high resolution does not improve performance.
- Reference images can be provided in PNG or JPEG file format.
- Color information is not used. Both color and equivalent grayscale images can be used as reference images or by users at runtime.
- Avoid images with heavy compression as this interferes with feature extraction.
- Avoid images with that contain a large number of geometric features, or very few features (e.g. barcodes, QR codes, logos and other line art) as this will result in poor detection and tracking performance.
- Avoid images with repeating patterns as this also can causes issues with detection and tracking.
Use the
arcoreimg
tool included in the ARCore SDK to get a quality score between0
and100
for each image. We recommend a quality score of at least 75. Here are two examples:
Tips for creating the image database:
- The database stores a compressed representation of the features extracted from the grayscale data in the reference images. Each image entry occupies about 6 KB.
- It takes about 30 ms to add an image to the database at runtime.
- Add images on a worker thread to avoid blocking the UI thread.
- Or, if possible, add images at compile time using the
arcoreimg
tool included in the ARCore SDK.
- If you know the expected physical size of an image, specify it. This information improves detection and tracking performance, especially for large physical images (over 75 cm).
- Avoid keeping many unused images in the database because there's a slight impact on system performance due to increased CPU utilization.
Understanding the 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
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
Assets/GoogleARCore/Examples/AugmentedImage/Configurations
and open AugmentedImagesSessionConfig
.In the Inspector, click the box next to Augmented Image Database and select the database file you created.