Forgot password?
EasyAR Portal Tutorial View Content

EasyAR Multi-Target recognition

AlbertLee 2017-8-1 16:01

Multi-Target recognition


code :

Step 1:Import SDK into the new project.

Create a project named “ARMultiTarget”.

Next, Import EasyAR 2.0 package and set up the environment. We can create a new file, name it “StreamingAssets”, and drag target images into this file.

Delete the original “Main Camera”, drag “EasyAR ImageTracker 1 MultiTarget” into the panel.

Then, fill in the key we applied ealier in the official website into the inspector

Step 2:Process camera

We need to write some scripts to process EasyAR Multi-target functions, create a script named “HelloARTarget” on "EasyAR_ImageTracker-1-MultiTarget"

The script is like following:

using UnityEngine;
using EasyAR;

namespace EasyARSample
    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\n"
            + "  2. create app with\n"
            + "      Name: HelloARMultiTarget-SameImage (Unity)\n"
            + "      Bundle ID:\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))
                UnityEditor.EditorUtility.DisplayDialog(title, keyMessage, "OK");
                Debug.LogError(title + " " + keyMessage);

Step 3: Process ImageTarget

two target photos

 We already prepared EasyAR’s camera, and we need to drag “ImageTarget” into the panel.

We can process ImageTarget like previously, making it display a model. (If you don’t understand, check our previous tutorial). Create a cube under the ImageTarget, as shown in the picture below.

Create another ImageTarget, change the target image and cube’s texture, as shown in the picture below 

Finally, we can press “Build” to preview the effect