Search code examples
unity-game-engineaugmented-realityvuforiakudan

Is there an AR SDK for creation of Image Targets during runtime?


For a Demo application I need an reliable AR SDK that does allow the creation of Image Targets during Runtime.

The SDK has to run on a mobile device and the Targets should not be created by some cloud server or during development. In this scenario Users would photograph their own markers (e.g. magazine covers) and they get cropped and warped to be used as markers (3D Objects have to be assigned to these markers at random). Neither vuforia nor ARToolkit allow this scenario. Some other SDKs that might

support it: Kudan, EasyAR or MAXST.

If this is not possible at all, is there a AR SDK that allows to use the exact same Image Target (or Marker of any kind) multiple times for rendering the same 3D Object? Again vuforia and ARToolkit do not support this.


Solution

  • Kudan seams to be not supporting this feature in unity i think it's supported in the native SDKs.

    Unlike the native SDKs, the Unity Plugin can't just get a raw image file from the assets and load it into the tracker. This is a feature we will be adding to the plugin in the future.

    source :- https://kudan.readme.io/docs/markers-1

    EasyAR on the other hand support creating imageTarget out of .png or .jpg one image at a time or by .json to add multiple images in one batch and it's provided in the example projects in EasyAR_SDK_2.2.0_Basic_Samples_Unity here

    Note:- to run the example project you need to

    1 - sign up on their site https://www.easyar.com/

    2 - creat SDK license key from here.

    3 - follow this Guide to place the key and run on unity.

    4 - Your goal is achieved in the "HelloARTarget" project

    and here is the example project script loading an AR experience from .pjg images

    using UnityEngine;
    using System.Linq;
    using EasyAR;
    
    namespace Sample
    {
        public class HelloARTarget : MonoBehaviour
        {
            private const string title = "Please enter KEY first!";
            private const string boxtitle = "===PLEASE ENTER YOUR KEY HERE===";
            private const string keyMessage = ""
                  + "Steps to create the key for this sample:\n"
                  + "  1. login www.easyar.com\n"
                  + "  2. create app with\n"
                  + "      Name: HelloARTarget (Unity)\n"
                  + "      Bundle ID: cn.easyar.samples.unity.helloartarget\n"
                  + "  3. find the created item in the list and show key\n"
                  + "  4. replace all text in TextArea with your key";
    
            private void Awake()
            {
                if (FindObjectOfType<EasyARBehaviour>().Key.Contains(boxtitle))
                {
            #if UNITY_EDITOR
                     UnityEditor.EditorUtility.DisplayDialog(title, keyMessage, "OK");
            #endif
                     Debug.LogError(title + " " + keyMessage);
                }
            }
    
        void CreateTarget(string targetName, out SampleImageTargetBehaviour targetBehaviour)
        {
            GameObject Target = new GameObject(targetName);
            Target.transform.localPosition = Vector3.zero;
            targetBehaviour = Target.AddComponent<SampleImageTargetBehaviour>();
        }
            void Start()
        {
            SampleImageTargetBehaviour targetBehaviour;
            ImageTrackerBehaviour tracker = FindObjectOfType<ImageTrackerBehaviour>();
    
            // dynamically load from image (*.jpg, *.png)
            CreateTarget("argame01", out targetBehaviour);
            targetBehaviour.Bind(tracker);
            targetBehaviour.SetupWithImage("sightplus/argame01.jpg", StorageType.Assets, "argame01", new Vector2());
            GameObject duck02_1 = Instantiate(Resources.Load("duck02")) as GameObject;
            duck02_1.transform.parent = targetBehaviour.gameObject.transform;
    
            // dynamically load from json file
            CreateTarget("argame00", out targetBehaviour);
            targetBehaviour.Bind(tracker);
            targetBehaviour.SetupWithJsonFile("targets.json", StorageType.Assets, "argame");
            GameObject duck02_2 = Instantiate(Resources.Load("duck02")) as GameObject;
            duck02_2.transform.parent = targetBehaviour.gameObject.transform;
    
            // dynamically load from json string
            string jsonString = @"
                {
                ""images"" :
                [
                    {
                    ""image"" : ""sightplus/argame02.jpg"",
                    ""name"" : ""argame02""
                    }
                ]
                }
                ";
            CreateTarget("argame02", out targetBehaviour);
            targetBehaviour.Bind(tracker);
            targetBehaviour.SetupWithJsonString(jsonString, StorageType.Assets, "argame02");
            GameObject duck02_3 = Instantiate(Resources.Load("duck02")) as GameObject;
            duck02_3.transform.parent = targetBehaviour.gameObject.transform;
    
            // dynamically load all targets from json file
            var targetList = ImageTargetBaseBehaviour.LoadListFromJsonFile("targets2.json", StorageType.Assets);
            foreach (var target in targetList.Where(t => t.IsValid).OfType<ImageTarget>())
            {
                CreateTarget("argame03", out targetBehaviour);
                targetBehaviour.Bind(tracker);
                targetBehaviour.SetupWithTarget(target);
                GameObject duck03 = Instantiate(Resources.Load("duck03")) as GameObject;
                duck03.transform.parent = targetBehaviour.gameObject.transform;
            }
    
            targetBehaviour = null;
        }
    
    
    
    
        }
    }
    

    edit

    although it's easy to make an ImageTarget from .png but i wonder how to check that the image contains the sufficient features for being detected in EasyAR ?

    Google AR Core supports this feature but they have limited number of supported devices

    https://developers.google.com/ar/develop/java/augmented-images/guide

    edit 2

    Looks like Vuforia is supporting the creation of the image target at runtime. also drag and drop the image as texture in the editor without having to generate a dataset from the portal. although you still need the api key from the portal.