12

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?

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
mn27
  • 121
  • 1
  • 8

3 Answers3

23

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.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • 2
    Took me a second to find that input - once you click the image in Xcode to highlight it look at the right pane and make sure you've clicked the attributes inspector, then you should see the input above where you can put in a width and the warning goes away. – LOP_Luke Jun 01 '18 at 13:31
0

It could be because there are some limitations with the software:

  • ARKit performs best when the host app is searching for 25 or fewer distinct images in a given environment

  • Developers should provide reference images, including information on physical size, to optimize detection

  • ARKit does not track changes to the position so precise placement of virtual assets could pose a problem

A separate section covers potential interruptions to the AR experience

Also, please refer see this answer that might reference you into right direction

tatigo
  • 2,174
  • 1
  • 26
  • 32
0

In my case, after a lot of trial and error i realised the problem happened because i had exactly the same image with the same file name as the reference image, in a normal asset catalog (ie a duplicate). Changing the name of the reference image fixed it.

Apneist
  • 396
  • 7
  • 17