Search Unity

Dynamic AR Kit ImageAnchor

Discussion in 'AR' started by moe9, Dec 3, 2018.

  1. moe9

    moe9

    Joined:
    Nov 2, 2018
    Posts:
    1
    Hello,

    I would like to develop an app that scans a barcode that serves as a reference image in the next ARKit scene.
    The barcode is decoded using ZXing. I get the barcode as a Texture2D.
    When the barcode is scanned, a button will appear to switch to an ARKit scene.
    in this scene, the Texture2D should serve as an ARKit reference image

    I tried the following:

    1.) In the Decode Script (without ARKit):

    Code (CSharp):
    1. public static string Decode(Texture2D tex)
    2. {
    3.    BarcodeReader codeReader = new BarcodeReader ();
    4. ...
    5.    GenerateImageAnchor gen = new GenerateImageAnchor();
    6.    gen.SetReferenceImage(tex);
    7. ...
    8. }

    In the GenerateImageAnchorScript from the ARKitExamples(ARKitImageAnchor):

    Code (CSharp):
    1. public void SetReferenceImage(Texture2D refImage)
    2. {
    3.    this.referenceImage.imageName = "barCode";
    4.    this.referenceImage.imageTexture = refImage;
    5. }
    barCode is the name of the ImageAnchor i created in Unity.

    That doesn't work. Is there a way to do that?

    Thanks!