Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Tracking issue #157

Open
TheNillesen opened this issue Jun 13, 2019 · 27 comments

Comments

Projects
None yet
5 participants
@TheNillesen
Copy link

commented Jun 13, 2019

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 which results in several objects on top of eachother when i change the image. 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().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

@ikv007s

This comment has been minimized.

Copy link

commented Jun 17, 2019

same problem any luck?

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 17, 2019

sadly no. I really hope that someone will post a solution <3

@dorkbot

This comment has been minimized.

Copy link

commented Jun 17, 2019

You have to subscribe to the trackedImagesChanged event. Then iterate over the 'updated', 'added' and 'remove' lists that come in the ARTrackedImagesChangedEventArgs argument. Disable the game objects in the remove list.
You can see that here -> https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scenes/ImageTracking/TrackedImageInfoManager.cs#L97

Also you can use the tracking state

ARTrackedImage trackedImage = eventArgs.updated[i];
if (trackedImage.trackingState == TrackingState.Tracking)

Here some info ->
https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@2.1/api/UnityEngine.XR.ARFoundation.ARTrackedImageManager.html

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 17, 2019

Thank you so much, i will check that out first thing in the morning and see if i can figure it out, i´m just gonna wait a bit with closing this issue until i know i don´t have anymore questions.

Again, thank you.

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 19, 2019

I'm facing the same issue: when the camera is off the target (or even when the target is physically removed) the ARTrackedImage is not present in the ARTrackedImagesChangedEventArgs's removed list and the trackingState does not go to None as expected.

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 19, 2019

i cant make it work either, when i debug i can see that the image is added to the added List.

and i can follow it through the updated list. but i cant do anything with the removed list.

Please someone add a specific example on how to achieve this.

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 19, 2019

AndroidLogcat

as the image shows - when i have a bad angle on the target i can get the Limited trackingstate. but when i just remove my phone completely from the image i get all these errors instead of the None
myTrackedImageInfoManager.txt
This is my script if oyu want to review what i have done

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 20, 2019

@TheNillesen that's weird, I have not seen those errors... but they might be something else, if you notice the tag is native and not Unity...
I get the None state only when I totally cover the smartphone sensors and let it lose the tracking of the environment

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 20, 2019

hm you might be right, the error just only occured when i didnt scan. oh well.

Had two great programmers looking through my code and the ar foundation code yesterday and they came to the conclusion that the arfoundation is not working as intended and we might have to wait on a fix.
so i am going to use it as it is now (broken) and then hope for a update in the near future so i can update my application.

Will keep this issue open until we get a proper solution.

@dorkbot

This comment has been minimized.

Copy link

commented Jun 20, 2019

I'm able to show and hide AR objects using ARFoundation on Android and iOS. Maybe this will help -> https://forum.unity.com/threads/arfoundation-2-image-tracking-with-many-ref-images-and-many-objects.680518/#post-4668326

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 20, 2019

Could you elaborate @dorkbot? The code that you linked is not able to hide AR objects, they will stay there even if you stop focusing the image or if you physically remove the image... that's the issue

@dorkbot

This comment has been minimized.

Copy link

commented Jun 20, 2019

Incorrect, the code I shared does hide the AR object when image tracking is lost. The code I link to is my code (I'm SpiderJones). I have an app that uses playing cards for images. It's live in the Apple App store and I'm using ARFoundation image tracking. https://apps.apple.com/app/id1468426395?fbclid=IwAR2EBeeOOQBa4PLiQt90OBb48hdwZNTae51M7HE2Sg-gKyKlYYbzpxwZzss

I doubt you had enough time to give the approach a try so I don't understand why you would say it doesn't hide objects.

@dorkbot

This comment has been minimized.

Copy link

commented Jun 20, 2019

I should point out that my app has an image tracking AR experience and a planar AR experience. Using ARFoundation for both.

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 21, 2019

I downloaded your app @dorkbot and it actually works, I am quite confused how is it possible with the code you shared on the forum... because that's the same exact code I am using and that the AR Foundation sample uses. The trackingState never goes to None in my tests.
Have you set up something on the manager? Or on the library?
(I am using Unity 2019.2.0b1 with AR Foundation preview.3 2.1.0)

@dorkbot

This comment has been minimized.

Copy link

commented Jun 21, 2019

I'm using Unity 2019.1.7f and ARFoundation 2.1.0 preview.3. Are you also using the remove List?

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 24, 2019

Yes but the images are in the remove list only when the AR Session is stopped

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 24, 2019

could it be that the ARKit is just working better than the ARCore ?? I played around with it and my image is in fact being disabled, but only when i totally black my camera. or like Oneiros90 said, facing the phone to the table.
my guess is that ARCore simple is worse at detecting the trackingstate than arkit..

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 24, 2019

I agree that ARCore's tracking is far worse than ARKit's one... but the issue I described is present in both systems

@TheNillesen

This comment has been minimized.

Copy link
Author

commented Jun 24, 2019

okay then. i am far from happy with how this works and even though dorkbot helped a lot i still feel i am missing a crucial part. :(

@Roaninho

This comment has been minimized.

Copy link

commented Jun 24, 2019

I'm currently experiencing the same issue: Tracked images never get into the trackingState.limited (or trackingState.None for that matter) and remain in the trackingState.tracked. Only covering the camera results in a change to trackingState.limited. I don't think that's supposed to work like that?

I'm working with Unity 2019.1.5f1, ARFoundation 2.2 and Android 9.0. Haven't tried iOS yet due to the necessity of iOS 13 and XCode 11.

I really hope for a fix or an explanation for the behavior...

@dorkbot

This comment has been minimized.

Copy link

commented Jun 24, 2019

ARCore image tracking and ARKit image tracking are not the same, for one, ARCore doesn't track moving images.

To avoid having to use iOS 13 and XCode 11, use ARFoundation 2.1 and ARKit 2.1. The only new feature in ARFoundation 2.2 and ARKit 2.2 is support for the new iOS and Xcode, both of which aren't released yet, as I know you are most likely aware of.

@Roaninho

This comment has been minimized.

Copy link

commented Jun 25, 2019

ARCore image tracking and ARKit image tracking are not the same, for one, ARCore doesn't track moving images.

They added that functionality in ARCore 1.9.0

I'm aware of the requierements of using ARFoundation 2.2 instead of 2.1 with iOS, but that shouldn't influence the experience on an Android device...

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 25, 2019

Ok guys, here's a test project using Unity 2019.1.7f and ARFoundation 2.1.0 preview.3 that shows the issue. Please @dorkbot have a look at the code if you have any spare time, your help would be very precious :) you're the only one that got it working hahaha

Steps to reproduce the problem:

  1. Download this: ARFoundationTest.zip
  2. Open it with Unity Hub/Unity 2019.1.7f (make sure to have Android support)
  3. Build it and focus the camera on one of the samples images (e.g. rafflesia.jpg)
  4. Move the camera off the target (or physically remove the image) and see the logs on screen
@dorkbot

This comment has been minimized.

Copy link

commented Jun 26, 2019

I apologize for not being clear, ARFoundation image tracking on iOS (ARKit) works as expected. ARFoundation on Android (ARCore) doesn't work as expected. I thought that was partly due to ARCore, but as Roaninho has pointed out, image tracking was introduced to ARCore. So now I'm on your team, I believe there is something wrong with ARFoundation image tracking running on Android.

@dorkbot

This comment has been minimized.

Copy link

commented Jun 26, 2019

@Roaninho My point was that you can try ARFoundation image tracking on iOS without using iOS 13 and Xcode 11

@Oneiros90

This comment has been minimized.

Copy link

commented Jun 26, 2019

@dorkbot does your application (CRISPR-3D) work as expected on Android?
I am facing the same issues on both ARKit and ARCore...

@dorkbot

This comment has been minimized.

Copy link

commented Jun 26, 2019

No, it doesn't work as expected on Android, but does work perfectly on iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.