Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

ARFoundation and 2D image target tracking

Discussion in 'Handheld AR' started by jarileon, Jun 27, 2018.

  1. LorenzoValente

    LorenzoValente

    Joined:
    May 2, 2019
    Posts:
    13
    Thank you Unity team, I started an AR project just yesterday and Image Tracking in AR Foundation is just what I needed.
    Is there any documentation about this feature? I can't find any class or component that I could use. In the changelist you talk about a "Tracked Image Manager" but I couldn't find it
     
    MrLeggo likes this.
  2. LorenzoValente

    LorenzoValente

    Joined:
    May 2, 2019
    Posts:
    13
    Ok I got it: open your "Packages/manifest.json" and make sure it looks like this:

    {
    "dependencies": {
    ...
    "com.unity.xr.arfoundation": "2.1.0-preview.2",
    ...
    },
    "registry": "https://staging-packages.unity.com"
    }
     
    Last edited: May 14, 2019
    MrLeggo likes this.
  3. Trifun

    Trifun

    Joined:
    Feb 23, 2018
    Posts:
    1
    Hello i guys,
    I'd like to know if the image tracking feature works on Arcore disabled devices. In other words, can i build a small app that doesn't require Arcore nor ARKit using AR Foundation ?
     
  4. mende

    mende

    Joined:
    Jun 11, 2013
    Posts:
    27
    Hello everybody,
    So I managed to run the sample for image tracking available in tzhe project from here: https://github.com/Unity-Technologies/arfoundation-samples/tree/master .
    Its working:) but I want to do some changes. I want to reference a different prefab for every image.
    At this time there will only be instantiated the same prefab for every tracked image.
    I have set up a list with different prefabs in the "ARTrackedImageManager.cs" , now I want to have a reference to the images of the "XRReferenceImageLibrary".I could not manage to get these tracked Images by an id or name:(
    How to do this in a simple way ? Any idea?
     
  5. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    669
    In TrackedImageInfoManager.cs file, check out the UpdateInfo method - gives you name and guid of detected pic.
     
    mende likes this.
  6. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    669
    Image tracking seems to work great so far, congratulations to the ARF team! Any pointers on how best to dynamically create or update an XRReferenceImageLibrary at runtime?
     
    LorenzoValente, Basic50 and mende like this.
  7. Basic50

    Basic50

    Joined:
    Dec 30, 2013
    Posts:
    5
    First, thanks for your work on this new release. We were waiting for this new feature (Image tracking) for a while and are excited to play with. However we notice that it's not possible to update the image references at runtime, all the APIs are in UnityEditor namespace. Did we miss something or it's not available yet? And in that case, do you plan to work on it?
     
    Last edited: May 20, 2019
    LorenzoValente, polytropoi and Blarp like this.
  8. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    156
    This technique will be real handy for choosing a point cloud map to localize against. Map IDs are set to Image Targets that are generated through screenshot (read pixels). So when the image target is recognized, we can programatically set which map to localize against.

    The problem that solves, is you cant iterate between point cloud maps until they match and localize, you need to specify the exact map you want to localize against to start the session.

    Image targetting bridges that cap between what you are looking at to what map to load.
     
  9. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    3
    Check the function ARTrackableManager::CreateGameObject(). There the Prefab is loaded. You need to adjust the functions in order to pass the name to the ARTracedImageManger::GetPrefab()).
    Then you can choose the Prefab by the Name/ID.

    Update: You will need to embed the ARFoundation package into your project. Otherwise changes to the ARTrackedManager classes cannot be stored permanently:
    https://forum.unity.com/threads/is-it-possible-to-edit-tmp-unity-package-source-code.571420/

    For example:
    upload_2019-5-18_21-52-28.png

    And you need another overload of GetPrefab:
    upload_2019-5-18_21-53-53.png

    And then you can choose the right prefab by its name here:
    upload_2019-5-18_21-55-4.png
     
    Last edited: May 19, 2019
    mende and MrLeggo like this.
  10. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    3
    Can anybody explain what exactly happens once I scan an image and a game object is instantiated at that position?
    I have some trouble with the alignment of the gameobjects.
    I mean, how is the gameobject internally translated to the anchor position? How is it rotated? Does it make use of ARSession::MakeContentAppearAt function?
    Can anybody give some more background about how this happens?
     
  11. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    669
    Skeketor23 likes this.
  12. LorenzoValente

    LorenzoValente

    Joined:
    May 2, 2019
    Posts:
    13
    I'm also struggling with the dynamic update of the XRReferenceImageLibrary. I've no solution yet, I posted my experience in this thread.
     
    polytropoi likes this.
  13. loganfive

    loganfive

    Joined:
    Nov 10, 2016
    Posts:
    1
    nothing new about 2d image tracking?
     
  14. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    101
  15. MrLeggo

    MrLeggo

    Joined:
    Feb 16, 2018
    Posts:
    15
    So I have the basics working but have some weird scaling issues. For instance if I place a standard cube under the base prefab, it seems to scale the y up, so the cube is now very long!

    I can't figure where or why this is happening. It seems to related to the tracked image size.

     
    Last edited: Jun 7, 2019
  16. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    101
    I suggest you look here for help -> https://github.com/Unity-Technologies/arfoundation-samples/issues
     
    MrLeggo likes this.
  17. MrLeggo

    MrLeggo

    Joined:
    Feb 16, 2018
    Posts:
    15
  18. dg3

    dg3

    Joined:
    Sep 20, 2016
    Posts:
    3
    Did the same test and having the same problem. Did you get anywhere to resolving? I saw someone else having the same problem here https://github.com/Unity-Technologies/arfoundation-samples/issues/142, but their solution didn't work for me. Thanks.
     
    MrLeggo likes this.
  19. MrLeggo

    MrLeggo

    Joined:
    Feb 16, 2018
    Posts:
    15
    I did the same in that link and added a public vector 3, so I could adjust the values as I needed. It stopped the plane from being the same size as the image, but the objects did become the correct scale. For a while...

    Now it has sopped working again. Not sure what I changed! I need to dive in and figure it out. I have some more pressing projects, so not sure when I will be able to look again.

    I'm sure more people must be having this same issue?
     
  20. NicklasAugsos

    NicklasAugsos

    Joined:
    Sep 26, 2018
    Posts:
    1
    Hi all.
    I am looking through the code of TrackedImageInfoManager and ARTrackedImageManager in ARFoundations Image Tracking.

    My problem is that i am trying to recieve the same functionality as in vuforia image tracking. (when camera is on the target = show content, when camera is off the target = dont show content) when using the demo scene from arfoundation the content stays on the screen instead of being disabled, I am stil fairly new to coding so i have a big problem understanding what is happening, i played around with this standard code from the TrackedImageInfoManager script:
    //Disable the visual plane if it is not being tracked
    if (trackedImage.trackingState != TrackingState.None)
    {
    planeGo.SetActive(true);

    // The image extents is only valid when the image is being tracked
    trackedImage.transform.localScale = new Vector3(trackedImage.size.x, 1f, trackedImage.size.y);

    //// Set the texture
    var material = planeGo.GetComponentInChildren<MeshRenderer>().material;
    material.mainTexture = (trackedImage.referenceImage.texture == null) ? defaultTexture : trackedImage.referenceImage.texture;
    }
    else
    {
    planeGo.SetActive(false);
    }

    My problem is that even when the trackingstate is None - the content is still showing..what can i do to make the stuff disapear, and only show when i scan my images?

    please help, have been stuck for too long :D
     
  21. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    16
    +1 Bump this question!
    Even with half a day of research, there is no clear answer to be found in the Unity pages.
    Anybody can confirm or deny if ARCore is necessary for Image Target detection?