Log in or register to post comments

Combining Ground Plane and Image Targets

February 2, 2018 - 6:59am #35

@rsultangareev I tried a similar approach and the positioning is way off.

Please see the image attached.

My aim is to allow several people within a room to experience an AR scene thats positioned and rotated in the exact same place for everyone.

First of all the user would be required to point the device at a marker which would then calibrate the world center.

In my initial prototype I've built upon the article here https://library.vuforia.com/articles/Solution/ground-plane-guide.html

When I tap on the screen I place the sphere using the DeployStageOnce from #15.

I've also added an image target with the aim of getting it's position and rotation relative to the arkit world center.

What I've noticed is that the coordinates are way off from the image target transformation. In the attached you'll notice the transform of the plane isn't realtive to arkit's world center.

I have ideas for workarounds but they wouldn't be perfect.

If anyone has any ideas or robust solutions i'd greatly appreciate it!

 

Amelie

AttachmentSize
Image icon IMG_0135.PNG1.42 MB

Combining Ground Plane and Image Targets

January 30, 2018 - 5:26am #34

Hi guys!

I hope here you will find the answer to your questions.

And sorry for my English!

The task is such, to connect the ImageTarget and GroundPlaneStage or MidAirStage.

Instruction:

1. Set on scene ImageTarget

2. Set on scene Vuforia --> MidAirStage or GoundPlaneStage (I use MidAirStage)

3. Set on MidAirStage game object or character as children

4. Write new script, I called "ImageTargetTrackable", script below

5. Put this script on the object ImageTarget

6. Turn off the "Default Trackable Event Handler (script)" component on ImageTarget

7. On our component "Image Target Trackable" we hang: "Anchor State" -- game object "Mid Air Stage"

8. We build on the smartphone and enjoy, the editor will not work correctly

Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class ImageTargetTrackable : MonoBehaviour, ITrackableEventHandler {

    protected TrackableBehaviour mTrackableBehaviour;
    public GameObject anchoreState; //it is object Mid Air Stage or Ground Plane Stage
    //public UnityEngine.UI.Image imageIndicator; //it is my indicator for detection image target

    protected virtual void Start()
    {
        anchoreState.SetActive(false);
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
    }

    public void OnTrackableStateChanged(
        TrackableBehaviour.Status previousStatus,
        TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED ||
            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
            OnTrackingFound();
        }
        else if (previousStatus == TrackableBehaviour.Status.TRACKED &&
                 newStatus == TrackableBehaviour.Status.NOT_FOUND)
        {
            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
            OnTrackingLost();
        }
        else
        {
            OnTrackingLost();
        }
    }


    protected virtual void OnTrackingFound()
    {
        anchoreState.transform.position = this.transform.position;
        anchoreState.transform.localPosition = Vector3.zero;
        anchoreState.transform.rotation = Quaternion.identity;
        anchoreState.SetActive(true);

        //imageIndicator.color = Color.green;
    }


    protected virtual void OnTrackingLost()
    {
        //imageIndicator.color = Color.red;
    }

    public void Reset()
    {
        anchoreState.SetActive(false);
    }
}

 

Combining Ground Plane and Image Targets

January 30, 2018 - 5:26am #33

Hi guys!

I hope here you will find the answer to your questions.

And sorry for my English!

The task is such, to connect the ImageTarget and GroundPlaneStage or MidAirStage.

Instruction:

1. Set on scene ImageTarget

2. Set on scene Vuforia --> MidAirStage or GoundPlaneStage (I use MidAirStage)

3. Set on MidAirStage game object or character as children

4. Write new script, I called "ImageTargetTrackable", script below

5. Put this script on the object ImageTarget

6. Turn off the "Default Trackable Event Handler (script)" component on ImageTarget

7. On our component "Image Target Trackable" we hang: "Anchor State" -- game object "Mid Air Stage"

8. We build on the smartphone and enjoy, the editor will not work correctly

Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class ImageTargetTrackable : MonoBehaviour, ITrackableEventHandler {

    protected TrackableBehaviour mTrackableBehaviour;
    public GameObject anchoreState; //it is object Mid Air Stage or Ground Plane Stage
    //public UnityEngine.UI.Image imageIndicator; //it is my indicator for detection image target

    protected virtual void Start()
    {
        anchoreState.SetActive(false);
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
    }

    public void OnTrackableStateChanged(
        TrackableBehaviour.Status previousStatus,
        TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED ||
            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
            OnTrackingFound();
        }
        else if (previousStatus == TrackableBehaviour.Status.TRACKED &&
                 newStatus == TrackableBehaviour.Status.NOT_FOUND)
        {
            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
            OnTrackingLost();
        }
        else
        {
            OnTrackingLost();
        }
    }


    protected virtual void OnTrackingFound()
    {
        anchoreState.transform.position = this.transform.position;
        anchoreState.transform.localPosition = Vector3.zero;
        anchoreState.transform.rotation = Quaternion.identity;
        anchoreState.SetActive(true);

        //imageIndicator.color = Color.green;
    }


    protected virtual void OnTrackingLost()
    {
        //imageIndicator.color = Color.red;
    }

    public void Reset()
    {
        anchoreState.SetActive(false);
    }
}

 

Combining Ground Plane and Image Targets

January 26, 2018 - 12:34pm #32

What i have noticed is that when you put a big object like a house and draw a tall cube in the center, where spawns, when you move to the center, which is the image target and the cube you should reach always the cube where is the target image but that is not what happens, the distances are not accurate between reality and the distance the camera moves, or maybe the house is moving in a wrong position as i move

Combining Ground Plane and Image Targets

January 26, 2018 - 8:07am #31

But Karolsenami that code is about the same as the one in the vuforia page, that doesnt solve anything

Combining Ground Plane and Image Targets

January 26, 2018 - 6:44am #30

markovichVF wrote:

steps included:

  1. Detect the imagetarget and extract the 3D pose relative to your camera 
  2. Convert this position from world coordinates to 2D screen coordinates 
  3. Emulate a touchevent at position X,Y of the device screen 

 

If this mechanism works you would also being allowed to keep checking the position of the detected image-target and compute the distance between the "perfect position" and the augmented object center. This difference could be checked against a treshold and used for re-adjusting the position of your virtual object.

I'm a bit late on this topic, but I managed to make ImageTargets and GroundPlane work together (code below) based on step 15 of the Ground Plane for Unity Guide.

You have to put your imageTarget on an horizontal surface (detected by GroundPlane so you can perfom a hit test).

I have a "World" object, which acts as the AnchorStage, that I place at result.position (the result position of the hit test as explained in markovichVF post), and set the same rotation as the imageTarget.

For the moment, I only created an Anchor for the "parent" (World) object. The tracking is alright, but the ImageTarget detection isn't perfect : the world is usually not at the exact same rotation as the imageTarget, and has a little x or z offset. 



Has anyone got any tips to improve the imageTarget position/rotation so the World is perfectly aligned ?

 

 

public void HandleInteractiveHitTest(HitTestResult result)
{
    if (result == null)
     return;
   // update world to plane below ImageTargets
    print("## Positioning world at: " + result.Position.ToString("F03") + " | while iT: "+imageTargetTransform.position.ToString("F03"));
    var anchor = positionalDeviceTracker.CreatePlaneAnchor("World", result);
    // set the anchor rotation to zero because we will give it the imageTarget rotation.
    anchor.transform.rotation = Quaternion.identity;
    World.transform.parent = anchor.transform;
    World.transform.localPosition = Vector3.zero;
    World.transform.localRotation = imageTargetTransform.rotation;     World.SetActive(true);
}

 

Combining Ground Plane and Image Targets

January 22, 2018 - 4:44pm #29

@strasza

Could we get clarification if this is a bug or a feature request?

Based on how Fusion was advertised I understood that the functionality should be available right now?

I would expect a quicker resolution if this was a bug. If Fusion does not actually fuse these technologies than it would be great to get an estimate on when you plan on adding it.

Thanks!

@strasza: also interested

January 22, 2018 - 2:30am #28

@strasza

I am also interested in both functionalities. 

Combining Ground Plane and Image Targets

January 19, 2018 - 9:50am #27

Also interested in this functionality. I would like to be able to detect my image or book and if it is sitting on a table be able to make my models explore the surrounding areas.

Combining Ground Plane and Image Targets

January 19, 2018 - 9:18am #26

@strasza, that's the two big ones I need.  Not sure how you'lI implement but I think we'll need midair anchor versions of both methods for things like posters and signs, ie it shouldn't work just on horizontal image targets.  

 

Combining Ground Plane and Image Targets

January 19, 2018 - 8:15am #25

Thanks for sharing your solution esnho!

@all Vuforia is watching this thread and this request is on our radar, but there seem to be different types of use cases for this. I've seen requests both for Ground Plane to be started from an Image Target and to place objects relative to the GP based on IT detection point. Are there any additional use cases, or are these the main two?

Thanks,

Vuforia Support

Combining Ground Plane and Image Targets

January 18, 2018 - 6:17am #24

I achieved something with this TrackableEventHandler and a setup as in the screenshot.



First of all you have to initialize the ground by tapping on the screen, then you can recognize the image target.

The ImageTarget childs will be immediatly removed from the image target hierarchy to obtain a stable tracking with the GroundPlane.



Note: this is a fast implementation, maybe can be done better.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
using System;

public class GroundPlaneTrackableEventHandler : DefaultTrackableEventHandler {
public GameObject AnchorStage;
private PositionalDeviceTracker _deviceTracker;
private GameObject _previousAnchor;

private List<GameObject> trackedObjects = new List<GameObject> ();
private GameObject trackingParent;

AnchorInputListenerBehaviour anchorInput;

protected override void Start ()
{
  base.Start ();

  if (AnchorStage == null)
  {
   Debug.Log("AnchorStage must be specified");
   return;
  }
  OnTrackingLost ();
}

public void Awake()
{
  VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
}

public void OnDestroy()
{
  VuforiaARController.Instance.UnregisterVuforiaStartedCallback(OnVuforiaStarted);
}

private void OnVuforiaStarted()
{
  _deviceTracker = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();
}
protected override void OnTrackingFound()
{
  base.OnTrackingFound ();

  if (trackingParent == null) {
   trackingParent = new GameObject ("trackingParent");
   trackingParent.transform.SetParent (transform, false);
  }

  if (transform.childCount > 0) {
   for (int i = 0; i < transform.childCount; i++) {
    trackedObjects.Add(transform.GetChild(i).gameObject);
   }

   foreach (GameObject trackedObj in trackedObjects) {
    trackedObj.transform.SetParent (trackingParent.transform, true);
   }

   trackingParent.transform.SetParent (transform.parent, true);
  }

  trackingParent.transform.position = transform.position;
  trackingParent.transform.rotation = transform.rotation;



}

protected override void OnTrackingLost() {
  if (_previousAnchor != null) {
   return;
  }
  base.OnTrackingLost ();
}

public void OnInteractiveHitTest(HitTestResult result)
{
  if (_previousAnchor != null) {
   return;
  }
  if (result == null || AnchorStage == null)
  {
   Debug.LogWarning("Hit test is invalid or AnchorStage not set");
   return;
  }

  var anchor = _deviceTracker.CreatePlaneAnchor(Guid.NewGuid().ToString(), result);

  if (anchor != null)
  {
   AnchorStage.transform.parent = anchor.transform;
   AnchorStage.transform.localPosition = Vector3.zero;
   AnchorStage.transform.localRotation = Quaternion.identity;
   AnchorStage.SetActive(true);
  }

  if (_previousAnchor != null)
  {
   Destroy(_previousAnchor);
  }

  _previousAnchor = anchor;
}
}

 

 

AttachmentSize
Image icon Schermata 2018-01-18 alle 15.06.28.png528.79 KB

Combining Ground Plane and Image Targets

January 18, 2018 - 3:04am #23

There is a problem for ARkit, it doesn't know its absolute position. So the first idea to fix it, is of course using marker(s) as absolute position reference. I tried to do something like that with Vuforia. i add a ground plane. i add a image target. the image target is supposed to be static on my monitor, but it moves around when i move my camera. And this makes the result not accurate. How does it happen?

Combining Ground Plane and Image Targets

January 17, 2018 - 8:18am #22

+1 for this.

This is not my understanding of "ARKit Integration into vuforia". I need a real world anchor, from where the device tracking always starts the same.

Combining Ground Plane and Image Targets

January 17, 2018 - 7:52am #21

+1 and waiting for some good solutions.

Combining Ground Plane and Image Targets

January 16, 2018 - 6:58am #20

Just wondering, is anyone from Vuforia reading this thread? Seems like a very popular thread and needed functionality, and just wanting to get an update? Thanks.

Combining Ground Plane and Image Targets

January 11, 2018 - 4:14pm #19

+1, According to how Vuforia Fusion was advertised, it should be possible to improve extended tracking using ground planes/SLAM.

Right now, this does not work. I am not sure if this is a bug or if this is a misunderstanding on what Fusion aims to provide.

Combining Ground Plane and Image Targets

January 11, 2018 - 7:55am #18

Basically all of you want to detect the position of an image-target and match this position to a point on a detected groundplane.

No matter if you are using the planefinder or midair functionality i would simply make use of the fact that Vuforia is waiting for touchevents (OnInteractiveHitTest) which are converted from screen-coordinates into the position on the detected groundplane. 

So it should be possible to use this approach backwards by detecting the 3D Position of an image-target and convert it into 2D-Space. At this position you could emulate an touchevent and make use of the integrated processes.

 

steps included:

  1. Detect the imagetarget and extract the 3D pose relative to your camera 
  2. Convert this position from world coordinates to 2D screen coordinates 
  3. Emulate a touchevent at position X,Y of the device screen 

 

If this mechanism works you would also being allowed to keep checking the position of the detected image-target and compute the distance between the "perfect position" and the augmented object center. This difference could be checked against a treshold and used for re-adjusting the position of your virtual object.

 

It will took some time to check this by myself. Maybe someone over here will give it a try and will share the result with us :-)

Combining Ground Plane and Image Targets

January 10, 2018 - 9:57pm #17

if someone has the solution for the problem stated below please share.

Combining Ground Plane and Image Targets

January 10, 2018 - 6:50am #16

+1 for an example file

Combining Ground Plane and Image Targets

January 8, 2018 - 1:12pm #15

I would also like to see an example or explanation of how to derive an ARkit world anchor from Vuforia Image Target pose information.

Combining Ground Plane and Image Targets

January 4, 2018 - 10:20pm #14

+100,  waiting for some sample or way-out on how to start with ImageTarget and ARKit, without much jumps.. thanks

Combining Ground Plane and Image Targets

January 4, 2018 - 1:21pm #13

@SoluisDev  @vdasilva

+1 for this. Would be great to see this capability in an example. Seems like most of us are needing this within our builds as extended tracking is a little legacy now to arkit 6dof. 

Combining Ground Plane and Image Targets

January 3, 2018 - 9:13pm #12

Plus one for having a sample that 1) Starts an experience using an image target (or multi-target, or 3d object target); 2) Uses ARKit to continue tracking when image target is lost; 3) Keeps the ARKit and Vuforia frame of reference in sync, so returning to the image target does not result in any apparent "jumping", or at least minimal jumping.

In essence, I think most people would be very happy to see ARKit serve as a much improved replacement for the legacy extended tracking.

Thanks @vdasilva for offering to put together a sample. Any idea how soon you might have one available?

Combining Ground Plane and Image Targets

January 3, 2018 - 12:57pm #11

vdasilva wrote:

dpizzle wrote:

vad710,



I think we really need an example or tutorial of triggering a ground plane experience from an image marker.  It's a very common use case that should be addressed in some way.

Thanks for the feedback! I will see what we can do to get some sort of sample for you. In general, ground plane + image targets are independent of each other, but can be used together. One doesn't really "trigger" the other - you should just be able to use Unity Code to get it working. We'll look into getting some docs and/or samples for this use case though.

 

I'm also wondering about how to accomplish this in Unity. In our case we need to be able to track an image target (a gallery painting) so the augmentation accurately overlaps the target but then allow the user to move the device away from the target without loosing tracking (in order to explore other augmented objects placed around the gallery space in front of the painting) and then to be able to come back to the original target. This is the same functionality that "extended tracking" is supposed to offer but it is very unreliable and augmented objects drift away very easily.

I guess the question is: does the new Vuforia Fusion concept mean that "extended tracking" for image targets also benefits from the fusion of other tracking techniques to make it more robust?

 

Thanks!

Combining Ground Plane and Image Targets

January 2, 2018 - 10:06am #10

DirkH wrote:

Hi,

my follow up question:

on  the "Ground Plane Supported Devices" page only  "Samsung Galaxy S8 (Snapdragon)" is mentioned.

Does that mean the european Galaxy S8 version will not be supported in the upcoming 2017.3 patch ?

 

 

We're always updating that list - Both the Exynos and the Snapdragon versions of the Galaxy S8 should be on the list by patch time.

Combining Ground Plane and Image Targets

January 2, 2018 - 9:48am #9

dpizzle wrote:

vad710,



I think we really need an example or tutorial of triggering a ground plane experience from an image marker.  It's a very common use case that should be addressed in some way.

Thanks for the feedback! I will see what we can do to get some sort of sample for you. In general, ground plane + image targets are independent of each other, but can be used together. One doesn't really "trigger" the other - you should just be able to use Unity Code to get it working. We'll look into getting some docs and/or samples for this use case though.

Combining Ground Plane and Image Targets

January 2, 2018 - 7:12am #8

Hi,

my follow up question:

on  the "Ground Plane Supported Devices" page only  "Samsung Galaxy S8 (Snapdragon)" is mentioned.

Does that mean the european Galaxy S8 version will not be supported in the upcoming 2017.3 patch ?

 

Combining Ground Plane and Image Targets

January 1, 2018 - 9:14am #7

vad710,



I think we really need an example or tutorial of triggering a ground plane experience from an image marker.  It's a very common use case that should be addressed in some way.









 

Combining Ground Plane and Image Targets

December 30, 2017 - 8:33pm #6
kethalak wrote:

I would love to see this question get some love. Also, any idea when the ground plane example project will become available?

The ground plane sample for unity is available on the asset store now.

If any of you have specific requests for samples and or docs, please keep the feedback flowing! We'll do our best to provide info for you guys!

Combining Ground Plane and Image Targets

December 30, 2017 - 8:29pm #5
niku123 wrote:

I thought that fusion would allow us to implement this using one build (or at least just one api) and the Vuforia sdk would know if arcore/kit is supported and then use that .

Yes, Vuforia will do that. Fusion isn't really a feature, just what we're calling the ability to leverage best platform enablers like arkit and arcore.

For Ground Plane, as of today, only arkit devices are supported (on Unity) . In an upcoming unity patch, other devices will be supported. ARcore support will be coming later, probably closer to arcore commercial release.

Combining Ground Plane and Image Targets

December 26, 2017 - 10:52am #4

I would love to see this question get some love. Also, any idea when the ground plane example project will become available?

Combining Ground Plane and Image Targets

December 21, 2017 - 5:26am #3

My question is similar. We are building an AR application allowing users to place 3d models on the floor. At this point, we have an application which uses arcore or kit to do plane detection and the user places them on there (for supported devices). For legacy phones we have a version using Vuforia image targets, it spawns an invisible plane on the image target and then the user places the objects on there the same way a user would on a more modern platform.

Right now this means we have 3 builds for the app, one arkit, one arcore, one Vuforia. I thought that fusion would allow us to implement this using one build (or at least just one api) and the Vuforia sdk would know if arcore/kit is supported and then use that instead (correct me if im wrong)

I can not find any kind of documentation on the new technologies apart from https://library.vuforia.com/articles/Training/ground-plane-guide.html, that can't possible be all? API Documentation? Literally the only reference to fusion I can find is the press release announcing it, and the line saying 'ground plane detection leverages fusion', whatever that means.

I hope to find a single api which uses the modern SDK's and falls back on an image target (just like the debugger thingy) for older devices.

Combining Ground Plane and Image Targets

December 20, 2017 - 7:10am #2

I came here to ask the same question.  I was expecting this to be a part of extended tracking of image targets but guessing we have to implement manually.  

If Vuforia could give us some best practices for this situation, it'd be much appreciated.

 

Pages

Log in or register to post comments