LoginSignup
9
5

More than 5 years have passed since last update.

ARReferenceImageの制限について

Last updated at Posted at 2018-06-21

はじめに

WWDC 2018でARKit2が発表されました。
そこで今までに追加されている機能をおさらいしていたら、ARReferenceImageで様々な警告を受けたのでまとめておこうと思います。
ARReferenceImage.init(_ image: CGImage, orientation: CGImagePropertyOrientation, physicalWidth: CGFloat)で生成した時に発生する警告では判断がつかないことが多いので、目を通しておくといいと思います。

ちなみにこんな感じの雑なエラーが発生し、ARSessionが停止します。

2018-06-21 08:59:03.738531+0900 ARKit-Sample[359:15389] [Session] Session (0x12dd09560): 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: <Unnamed>, NSLocalizedRecoverySuggestion=Make sure that all reference images are greater than 100 pixels and have a positive physical size in meters., ARErrorItems=(
    "<Unnamed>"
), NSLocalizedDescription=Invalid reference image.}

ARReferenceImageとは

そもそもARReferenceImageって何かと言うと、ざっくり説明すると「AR空間で画像を使用するためのもの」です。
例えばAR空間で画像の認識をしたいとなった時に使用します。
確かARKit1.5から加わった機能だったと思います。

引っかかった制限(随時追記)

The aspect ratio of the image is high. The aspect ratio should be lower than 3:1.

和訳: 画像の縦横比が高い。 縦横比は3:1より小さくする必要があります。

アスペクト比の差が大きすぎると発生します。
使用していた画像のアスペクト比が8:1だったので、3:1にしてみたところ解消されました。

The histogram of the image is narrow or not well distributed. Recognition works better on images with wider, flatter histograms.

和訳: 画像のヒストグラムは狭いか、またはうまく分布していません。 認識はより広く、より平らなヒストグラムを有する画像上でより良好に機能する。

画像の輝度の差があまりないものは認識に向かないようです。
画像の色のバランスとかコントラストの調整をすると上手くいきました。
参考: http://www.asahi-net.or.jp/~ax2s-kmtn/ref/histogram.html

The image has uniform cokor regions, low texture, or low local contrast regions. Recognition works better whem there are higher local contrast regions distributed across the image.

和訳: 画像は、均一なココア領域、低いテクスチャ、または低い局所コントラスト領域を有する。 認識は、より高い局所コントラスト領域が画像全体に分散している場合にはより効果的である。

これも画像の色のバランスとかコントラストの調整をすると上手くいきました。
具体的な解決法を知っている人は教えていただけると幸いです。

The resolution of the image is low. Noth width and height should be at least 480 pixels.

和訳: 画像の解像度は低いです。 幅と高さは、少なくとも480ピクセルにする必要があります。

画像の解像度は縦横どちらも480ピクセル以上にしなければいけないようです。
縦が300ピクセルしかなかったのを480ピクセルにしたら解消しました。

まとめ

他にも様々な制約があると思います。
こんなの出たよーとか、こうしたら解決したよーというのがあれば、編集リクエストいただけたら幸いです。

9
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5