Jump to content
  • Advertisement
Sign in to follow this  

Unity Image Target Recognizer?

This topic is 1001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to make a quiz game which sounds like this : I need a button which will pick a random game object and than I need to check if the selected game object is same as the ImageTarget being shown to the camera, and if it is same it should respond "Correct", if not "Not Correct"  ! .
I already did the button which will pick the random game object but now I don't know how to check if that object is equal to the object being shown to the camera. I am sending you the button script which picks a random game object. 
I would be grateful if you help me do this :) 

This is the Random.cs which generates a random game object:


using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Vuforia;
public class Quiz : MonoBehaviour 
public GameObject[] models;
public GameObject currentPoint;
int index;
public AudioSource correctAudio;
public AudioSource notcorrectAudio;
void Start()
StateManager sm = TrackerManager.Instance.GetStateManager();
IEnumerable<TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours();
models = GameObject.FindGameObjectsWithTag("numbers");
index = Random.Range (0, models.Length);
currentPoint = models[index];
print ("Trackable " +currentPoint.name);
//the attached AudioSource of the selected object is played here
currentPoint.GetComponent<AudioSource> ().Play ();

Share this post

Link to post
Share on other sites

When you say "the ImageTarget being shown to the camera" do you mean that there will be only one object in your scene or will there be multiple?


If there is going to be multiple and you want to base selection solely on what your camera sees, you will need to implement some sort of ray casting aligned with the center of the viewport to select an object.


If there will be only one object, and say you can traverse through different scenes with each having a different object, you could just associate the selected object with the current scene.


Hope I helped!

Share this post

Link to post
Share on other sites

This is an example: I press the button "Numbers" which generates a random ImageTarget from 0-9 with theri relative child game objects (0,1,2,3...9) and plays its AudioClip which is attached to every ImageTarget. Then I need to check if that target which was randomly generated, for ex. Number 3, is equal to the printed card with the relevant number from 0-9. If i show the printed card 3 it should say "Correct", if i show printed card 5 it should say "Not Correct" ! 

Share this post

Link to post
Share on other sites
So when you say camera, you mean the physical camera on the computer?

I would start with using OpenCV

I would then put QR codes, or some other simple identifiable marker, on the cards for identification

QR codes aren't as cool as actual character recognition but it will be more accurate. I know generic symbol recognition is achievable with opencv but it will take more work to get to work right. Edited by HappyCoder

Share this post

Link to post
Share on other sites

Yes i mean the physical camera on the computer. Is there any alternative way for  this because i noticed that the OpenCV is 95$ 

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!