Detecting when Marker Is Detected and Lost in XZIMG Augmented Vision

Detection of Marker Detected and Lost events is important. We can use it to play sound when marker is found, play and pause video, trigger animations. It is the backbone of many AR interaction experience. This tutorial will show you how to do it. In the next tutorial, we will start playing with audio, video and other things. so this is really important

To follow this tutorial you would need a few things:

  1. You finished the previous tutorial
  2. Event Handling scripts. Use mine for now, we will learn how to build one in the advanced class. download it from here.

Download and Extract the Event Handling scripts folder

Download the scripts i provided above, and unzip it. You will get a folder like so:

Drag and drop the folder into Unity

Drag and Drop the EventHandling Script folder into Assets in Project window

Replacing the default Image Detector with our new one that has Event Sender

At the project window, go to Assets > EventHandling Script , you will see xmgAIplusEventSender and Event Receiver

Firstly, in the Hierarchy, select the imageDetector

With imageDetector selected, look at the Inspector window, right click Xmg Augmented Image script and click Remove Component

Drag and drop the xmgAIplusEventSender script into the Inspector window

Your inspector window will now look like this. Good job!

Configuring the new script

Under Object Pivot Links, change the Size to 1 and press Enter on your keyboard.

Once you press Enter, you will get something like this

Drag and drop Pivot 1 to Scene Pivot

Go to Assets > Resources, drag and drop the marker that we created in the previous tutorial to the Classifier slot

Finally, under Object Pivot Links, change the Object Real Width to 1.

That’s it, we are done with the sender part, now a few more steps for the receiver part.

Attaching the Event Receiver

In the Hierarchy, select Pivot1

With Pivot1 selected, drag and drop the Event Receiver into the Inspector

It should look like this now

Lets test it

Press Play, and show our marker to the camera. Our AR should work normally and the Marker Status will show marker is detected

Okay…we are all Done. So what can we do with this?

With this ready, we can use it to play sound when marker is found, play and pause video, trigger animations, do multiple marker interactions and many more. We will look at some of them in the next post

2 thoughts on “Detecting when Marker Is Detected and Lost in XZIMG Augmented Vision

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s