Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Error: AR reference image must have non zero positive width

Tags:

xcode

swift

arkit

Help I'm playing around with ARKit's Image detection and I have no idea why every image I place in the AR Reference folder has an error:

AR reference image 'name' must have non zero positive width

I'm not really sure what that means and I'm not having any luck when I google it.

How do i fix this?

like image 403
mn27 Avatar asked Apr 10 '18 15:04

mn27


People also ask

How do I create an AR reference image in Xcode?

Typically, you create reference images in your Xcode project's asset catalog: In your asset catalog, use the Add (+) button to create an AR Resource Group. Drag image files into the resource group to create AR Reference Image entries in the asset catalog.

What is arreferenceimage in ARKit?

To accurately detect the position and orientation of a 2D image in the real world, ARKit requires preprocessed image data and knowledge of the image's real-world dimensions. The ARReferenceImage class encapsulates this information.

How to enable image detection in an AR session?

The ARReferenceImage class encapsulates this information. To enable image detection in an AR session, pass a collection of reference images to your session configuration's detectionImages property.

How do I get ARKit to recognize a reference image?

For each reference image, use the Xcode inspector panel to provide the real-world size at which you want ARKit to recognize the image. (You can also provide a descriptive name, which appears as the name property at runtime and can be useful for debugging.)


1 Answers

When you add an AR reference image to your asset catalog, you need to add a physical size:

Xcode AR Reference image UI

This is necessary for ARKit to locate the image in the user's physical environment — otherwise it can't tell whether the image appears small in the camera image because it's physically small and nearby or because it's large and far away.

like image 158
rickster Avatar answered Oct 06 '22 18:10

rickster