How ARKit 2 Recognizes Real-World Images
Apple introduced advanced image detection and tracking in iOS 12 with ARKit 2, allowing developers to anchor digital content to physical, flat surfaces like posters, artwork, and product packaging. This article explains the underlying mechanisms of ARKit 2's image recognition pipeline, covering how pre-configured reference assets, feature extraction algorithms, and real-time computer vision combine to detect and track printed media in physical space.
Pre-Configured Reference Images
Image recognition in ARKit 2 begins before the app runs. Developers
supply reference images (ARReferenceImage) within an asset
catalog in Xcode. For recognition to work accurately, developers must
specify the physical size (width in meters) of the real-world print.
This real-world measurement provides the scale baseline that the system
requires to determine depth and orientation from a single 2D camera
feed.
Visual Feature Extraction
During the compilation phase, Xcode analyzes the reference images to determine if they contain sufficient visual detail. ARKit relies on high-contrast points, distinct corners, and asymmetric patterns to create unique feature descriptors. Low-contrast images, repetitive patterns, or solid blocks of color are flagged as unsuitable because the system cannot reliably differentiate key points.
Real-Time Optical Matching
When an AR session launches using either
ARWorldTrackingConfiguration (for combined environment and
image tracking) or ARImageTrackingConfiguration (focused
solely on moving 2D images), the device's camera stream analyzes
incoming video frames:
- Feature Detection: The computer vision engine scans each frame for localized features and generates keypoint descriptors similar to those created for the reference image.
- Matching: The runtime matches the live camera keypoints against the database of stored reference descriptors using fast geometric verification algorithms.
- Homography Estimation: Once enough keypoints correlate, ARKit solves for the homography—the geometric transformation between the flat 2D reference plane and the perspective captured by the camera sensor.
Pose Estimation and Anchoring
After identifying a match, ARKit calculates the exact
six-degrees-of-freedom (6DoF) position and orientation of the physical
image relative to the camera. It converts this transformation matrix
into an ARImageAnchor. Developers can then attach 3D
models, videos, or interface elements directly to this anchor, which
aligns the virtual object seamlessly to the real-world print.
Continuous Tracking in iOS 12
While ARKit 1.5 only offered static image detection, ARKit 2 introduced dynamic image tracking. Using visual-inertial odometry (VIO) paired with real-time optical flow, the framework can track an image even if it moves through the environment, such as a poster held in someone's hands or a label on a moving box. If the target leaves the camera frame or becomes heavily occluded, ARKit retains the anchor's estimated position based on the physical environment until the target is visible again.