Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
2
Question by w8w · Feb 04, 2017 at 05:08 AM · cameraimagevuforiaaugmented-realitytracking

Combine Two or More Image Targets Simultaneously to Display a New 3D Object, Not Individually (Unity + Vuforia)

Hi all Unity, Vuforia, VR, and AR experts,

I have asked the same question on the Vuforia developer forum and would love some advice: https://developer.vuforia.com/forum/object-recognition/combine-two-or-more-image-targets-create-third-3d-object

Currently with Vuforia you can easily detect multiple image target simultaneously to display objects, but it's a one to one association. Meaning 1 image target will display 1 object upon detection, and the system can simultaneously detect multiple image targets, say 2 images, and display 2 separate objects.

What I would like to accomplish is when 2 images are display at the same time, display a different object than that of object 1 (from image 1) or object 2 (from image 2) like in the following:

if Image 1 is detected, then show 3D Object 1

if Image 2 is detected, then show Object 2

if Image 1 + 2 are both detected (at the same time), then show Object 3

It seems currently the way it works is if an object is found, display its child, which is the actual object. I thought I can make a list to capture when objects are found, and then look through the list for if all the image target names exist in the list then display the model (Object 3 in this case); however as I am doing it it doesn't make as much sense.

Wondering if anyone know of a more elegant solution or any suggestions. Is this even the right idea? I am not much a developer, so any help is much appreciated!

 private void OnTrackingFound()
         {
             Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true); 
             Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
 
             // My addition: Declaring a list of strings
             List<string> foundComponents = new List<string>();
 
             // Enable rendering:
             foreach (Renderer component in rendererComponents)
             {
                 //My addition: Captured the names of the image targets that are found
                 foundComponents.Add(mTrackableBehaviour.TrackableName);
                
                             component.enabled = true;
             }
 
             // Enable colliders:
             foreach (Collider component in colliderComponents)
             {
                 component.enabled = true;
             }
 
             Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
 
             foreach( string component in foundComponents )
             {
                 Debug.Log( component );
             }
         }









Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ashfaqueck · Oct 09, 2018 at 12:40 PM

First of all that DefaultTrackableEventHandler which is a component for each image target you create (in which you can see those both tracking found and lost functions) is just a default script provided by vuforia.

  1. Remove it

  2. Create your own new script name it something which smell like its a tracking behaviour.

  3. In that script add namespace Vuforia as "Using Vuforia;"

  4. now implement the interface of vuforia tracker which is : "ITrackableEventHandler"

Here , We have our own tracker behaviour script now. Means, think you get two events as image has been tracked and lost. Let's not have extended tracking for now. and you can do whatever you wanna do in those two events. you can use that image target object as a dummy object which handle that specific image tracking mechanism. there is no need that you have to keep the augmenting object as the child of your image target object. you can use the image target behaviour tracker results from your script as you need. here is a sample how you can do what you asked for.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using Vuforia;
 
 public class MTrackableBehaviour : MonoBehaviour, ITrackableEventHandler
 {
 
     protected TrackableBehaviour mTrackableBehaviour;
     public bool isTracked=false;
     public GameObject aug_Model, model_3;
 
 
     protected virtual void Awake()
     {
         mTrackableBehaviour = GetComponent<TrackableBehaviour>();
         if (mTrackableBehaviour)
             mTrackableBehaviour.RegisterTrackableEventHandler(this);
 
         aug_Model.SetActive(false);
     }
 
 
 
     public void OnTrackableStateChanged(
        TrackableBehaviour.Status previousStatus,
        TrackableBehaviour.Status newStatus)
     {
 
         if (newStatus == TrackableBehaviour.Status.DETECTED ||
             newStatus == TrackableBehaviour.Status.TRACKED ||
             newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
         {
             trackedBehaviour();
 
         }
         else if (previousStatus == TrackableBehaviour.Status.TRACKED &&
                  newStatus == TrackableBehaviour.Status.NOT_FOUND)
         {
             trackLostBehaviour();
         }
         else
         {
             trackLostBehaviour();
         }
     }
 
 
     private void trackedBehaviour()
     {
         isTracked = true;
 
         if (!isBothTargetsTracked())
             aug_Model.SetActive(true);
         else
             model_3.SetActive(true);
     }
 
     private void trackLostBehaviour()
     {
         isTracked = false;
         aug_Model.SetActive(false);
         model_3.SetActive(false);
     }
 
     private bool isBothTargetsTracked()
     {
         bool value = true;
 
         foreach (MTrackableBehaviour m in FindObjectsOfType<MTrackableBehaviour>())
         {
             if (!m.isTracked)
                 value = false;
         }
         return value;
     }
 
 }
 

add this script to each ImageTarget object. the aug_model and model_3 can be anywhere in the scene hierarchy.

ENJOY...! @weikian ,@iamklarey ,@BioFan ,@w8w

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SallarQ · Nov 02, 2018 at 04:24 AM 0
Share

thanks brother its working for me but only when two image targets are in the hierarchy if the image targets are more than two its not showing. i want to do is to add more image so when pair of image targets combined, each pair combined to generate a model for example i have 10 image targets in scene when two image targets detected by the camera it generate the model other wise not. i tried to do it with by comparing Names but its not working https://answers.unity.com/questions/1567822/combine-two-image-targets-to-generate-a-model.html here is my question i already asked u can see the script i used. any help will be appreciable thanks..

avatar image
0

Answer by BioFan · Jan 30, 2018 at 03:21 AM

no answers to this?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by iamklarey · Feb 26, 2018 at 12:19 PM

I'm also looking for the answer.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by weikian · Mar 11, 2018 at 03:54 AM

I am seeking the solution for the same case as well..,I am looking for the answer too

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by VRTitus · Oct 16, 2018 at 12:40 AM

@ashfaqueck I have gone through many of answer and your answer should be the best one. But I have encountered with some new issues, would you mind to figure them out? Thanks in advance!


  1. Put target image A on camera for detection, show 3D object A

  2. Remove target image A from camera and put target image B on camera for detection, show 3D object B

  3. Keep target image B on camera and put back target image A, show 3D object C


But what I have seen on screen:


  1. Put target image A on camera for detection, show 3D object A [OKAY]

  2. Remove target image A from camera and put target image B on camera for detection, show 3D object B [show 3D object A and C simultaneously, 3D object B never show]

  3. Keep target image B on camera and put back target image A, show 3D object C [same as step 2]

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

126 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity (Vuforia) doesn't recognize my PS Eye. 0 Answers

Vuforia: model disappears when getting closer to ImageTarget 2 Answers

Building an AR App, everything is Blurry: Using Unity and Vuforia 0 Answers

why my Scene camera is not redering the predefined setup when creating two scenes? (using Vuforia ARCamera and another simple camera on a second screen) 1 Answer

[Unity Vuforia] Make an object move towards the camera 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges