Reference images have an invalid size Xcode 10

I have noticed that all of my project using a specific image reference could not load on my application :



2018-06-13 13:51:39.699458+0200 RABTP[1111:192787] [Technique] Could not add planar object for detection: <ARReferenceImage: 0x2839bc000 name="Custom_Marker_2" physical-size=(0.000, 0.000)> Reason: 4
2018-06-13 13:51:39.704807+0200 RABTP[1111:192787] [Session] Session (0x12dd1cfd0): did fail with error: Error Domain=com.apple.arkit.error Code=300 "Invalid reference image." UserInfo={NSLocalizedFailureReason=One or more reference images have an invalid size: Target_NEW, Custom_Marker_2, NSLocalizedRecoverySuggestion=Make sure that all reference images are greater than 100 pixels and have a positive physical size in meters., ARErrorItems=(
    "Target_NEW",
    "Custom_Marker_2"
), NSLocalizedDescription=Invalid reference image.}

However, all of my image references have a positive physical size in meters. This issue appear onyly on Xcode 10.


Regards,

Replies

Still have the same issue with Xcode Version 10.0 beta 4 (10L213o)


2018-07-18 15:37:12.153485+0200 RABTP[400:25793] [Technique] Could not add planar object for detection: <ARReferenceImage: 0x283089400 name="Target" physicalSize=(0.145, 0.145)> Reason: 15
2018-07-18 15:37:12.153739+0200 RABTP[400:25793] [Session] Session (0x102a31ee0): did fail with error: Error Domain=com.apple.arkit.error Code=300 UserInfo={NSLocalizedFailureReason=<redacted>, NSLocalizedRecoverySuggestion=<redacted>, ARErrorItems=<redacted>, NSLocalizedDescription=<redacted>}
session(_:didFailWithError:): Invalid reference image.

We have observed the same issue. Did you resolve?

No unfortunately...

Hi Ysee-kzsln,


The first error was obviously due to an invalid physicalSize for the reference image: physicalSize=(0.0, 0.0) but the second error is more mysterious.


The physicalSize=(0.145, 0.145) value in this case seems legitimate but then the UserInfo feedback isn't very helpful at all:


{UserInfo={NSLocalizedFailureReason=<redacted>, NSLocalizedRecoverySuggestion=<redacted>, ARErrorItems=<redacted>, NSLocalizedDescription=<redacted>}


Are you loading the reference images from an external source at runtime or referencing images from the App bundle that you've added via the Asset Catelog?


If the later then there should be some feedback on the detection quality for the images and if the former then I'd try manually adding these images to the Asset Catelog to see what feedback you get.


Hope that helps and let us know what you find.

Hey, guys!
Had the same problem. Solved using JPEG format instead of PNG. 🙂
XCode version: 10.0 beta 5 (Jul 30, 2018).

Hello 4k4,



Thank you for you reply.

I manage my reference images via the Asset Catalog. So I drag & drop the images and set up the size in centimeter.

I also noticed some of the reference images with the bad histograms can not be loaded.

At the moment, I fixed this issue by using one of your valid reference image. (from sample code: Handling 3D Interaction and UI Controls in Augmented Reality)


Hope this will be fixed with the latest Xcode.

Hi Ysee-kzlsn,


According to our documentation on physicalSize the units should be meters and not centimeters.

<https://developer.apple.com/documentation/arkit/arreferenceimage/2941027-physicalsize>


Given that the values in your last error message physicalSize=(0.145, 0.145) look correct at 14.5cm I'm guessing this isn't an issue but mention it for completness.


Your point about "bad histograms" is interesting and I suspect that this actually correct feedback from Xcode i.e. these images are considered poor for detection and thereby cannot be loaded.


Otherwise, it sounds like this might be a bug because you're using the AssetCatalog and the runtime error messages are redacted.


Please file a bug report using our bug reporting tool at <https://developer.apple.com/bug-reporting/>

Hi moaner,


That's an interesting potential workaround. Likewise would you mind filing a bug report at <https://developer.apple.com/bug-reporting/>


It would be very helpful.

hello,
i am Unity3d Developer and facing this issue sometime... in my case i am creating marker at runtime. i've restricted user to create image below 100 pixels because of this error message. can you tell me what are the minimum physicalsize and image size to create marker.Thanks

I have tried that as well but no permanent success. In my example there also appears to be some problem with units conversion from meter to inch... I set the unit selector to meter and afterwards entered the size in meter (0,09 m - more than 1 inch for sure). The error message was telling me that the size should be one inch minimum. I changed the unit to inch and the program changed the value to something smaller than 1 inch. After changing those numbers and units backwards and forwards the photo was finally accepted.

This solution worked! Thanks!

I hope the topic isn't stale. I'm using Xcode 10.1 (10B61) and am seeing the same behavior.


Given that Xcode 10 is long out of beta, and that nobody seems to be asking about it any more, I'm hoping there's now a solution.


I'm adapting a tutorial, "Triassic Loupe" from raywenderlich.com (blessed be its name) to explore AR reference-image techniques. It worked (properly identified the target planes and overlaid them with a video) with my new images. I did further work, meaning only to replace the video overlay with a cgImage. Now when I execute the following code:


static let imageGroup = "OIplanar"



private func setupImageDetection() {
  imageConfiguration = ARImageTrackingConfiguration()
  guard let referenceImages = ARReferenceImage
       .referenceImages(
       inGroupNamed: ImageViewController.imageGroup,
       bundle: nil) else {
            fatalError(#function)
       }     
  imageConfiguration.trackingImages = referenceImages
}


referenceImages at line 9 shows all images correctly identified, but with physicalSize .zero:


(lldb) po referenceImages
▿ 6 elements
  - 0 : 
  - 1 : 
  - 2 : 
  - 3 : 
  - 4 : 
  - 5 :



(lldb) po referenceImages
▿ 6 elements
  - 0 : <ARReferenceImage: 0x283f78a50 name="Lion" physicalSize=(0.000, 0.000)>
  - 1 : <ARReferenceImage: 0x283f79270 name="QST" physicalSize=(0.000, 0.000)>
  - 2 : <ARReferenceImage: 0x283f4f570 name="Bull king" physicalSize=(0.000, 0.000)>
  - 3 : <ARReferenceImage: 0x283f79450 name="Middle Attendants" physicalSize=(0.000, 0.000)>
  - 4 : <ARReferenceImage: 0x283f796d0 name="Extreme priest" physicalSize=(0.000, 0.000)>
  - 5 : <ARReferenceImage: 0x283f40460 name="Cuneiform" physicalSize=(0.000, 0.000)>



(lldb) po referenceImages
▿ 6 elements
  - 0 : {ARReferenceImage: 0x283f78a50 name="Lion" physicalSize=(0.000, 0.000)}
  - 1 : {ARReferenceImage: 0x283f79270 name="QST" physicalSize=(0.000, 0.000)}
  - 2 : {ARReferenceImage: 0x283f4f570 name="Bull king" physicalSize=(0.000, 0.000)}
  - 3 : {ARReferenceImage: 0x283f79450 name="Middle Attendants" physicalSize=(0.000, 0.000)}
  - 4 : {ARReferenceImage: 0x283f796d0 name="Extreme priest" physicalSize=(0.000, 0.000)}
  - 5 : {ARReferenceImage: 0x283f40460 name="Cuneiform" physicalSize=(0.000, 0.000)}

(Sorry for the repeats, the literal-text style gets very confused by angle brackets and I can't fix or delete them in-place. For all I know you'll see all three.)


When execution proceeds to sceneView.session.run(imageConfiguration), the same error as elsewhere in this thread reaches session(_:didFailWithError:) -


... (same for the other images) ...
2018-12-05 18:48:17.183728-0600 Not OI[25465:9988437] [Technique] Could not add planar object for detection: <ARReferenceImage: 0x283f40460 name="Cuneiform" physicalSize=(0.000, 0.000)> Reason: 4
2018-12-05 18:48:17.184038-0600 Not OI[25465:9988437] [Session] Session (0x104b09bb0): did fail with error: Error Domain=com.apple.arkit.error Code=300 "Invalid reference image." UserInfo={NSLocalizedFailureReason=One or more reference images have an invalid size: Lion, QST, Bull king, Middle Attendants, Extreme priest, Cuneiform, NSLocalizedRecoverySuggestion=Make sure that all reference images are greater than 100 pixels and have a positive physical size in meters., ARErrorItems=(
    Lion,
    QST,
    "Bull king",
    "Middle Attendants",
    "Extreme priest",
    Cuneiform
), NSLocalizedDescription=Invalid reference image.}

Following other suggestions I converted to all JPEG (no), then all PNG (no), editing the respective Contents.json files to match. Here is what's in the Contents.json for one of them:


{ "images" : [
  { "idiom" : "universal", "filename" : "Cuneiform.jpg" }
  ],
  "info" : { "version" : 1, "author" : "xcode" }, "properties" : { "width" : 0.9144000000000001 }
}


The conversions were by way of a script using sips to convert and sed to edit the suffixes in the Contents.jsons. Remember I had this trouble before I did any of that. No change. Cutting the dimensions from ~2800 on a side to 1024 didn't help. (512 got me dimension-too-small runtime warnings, and I lacked the patience to correct those by hand.)


I know I should retrace my steps through the tutorial (no, I didn't add SCM until after I crossed the line to un-workland). I'll do that tomorrow after I go home and sleep.


In the mean time, I hope someone has figured out what exposes this issue and how I can avoid it.