ARCore, AddImage to AugmentedImageDatabase in runtime
Hello
I try to add image in runtime to my AugmentedImageDatabase.
I use the code below but nothing happen . In my code "camera" is my ARCoreSession.
Texture2D tex = new Texture2D(2, 2);
tex.LoadImage(asset.augmentedImage);
camera.SessionConfig.AugmentedImageDatabase.AddImage("test", tex, 0);
Do you know if it's possible ?
Answer by Phanou · Nov 21, 2018 at 08:32 AM
This is my complete class test :
public class test : MonoBehaviour {
public Sprite monimage;
public ARCoreSession masession;
public List<AugmentedImage> m_TempAugmentedImages = new List<AugmentedImage>();
void Start ()
{
masession.SessionConfig.AugmentedImageDatabase.AddImage("test", monimage.texture, 0);
Session.GetTrackables<AugmentedImage>(m_TempAugmentedImages, TrackableQueryFilter.Updated);
Debug.Log(m_TempAugmentedImages.Count + " image in the AugmentedImageDatabase"); // ==0
}
}
Debug.Log print "0"
the problem come from "AddImage" in AugmentedImageDatabase.cs
Lifecycle$$anonymous$$anager.Instance.NativeSession is always null.
I don't understand what is NativeSession.
Answer by KLoOonal · Mar 08, 2019 at 05:01 AM
I recommend you to test on android device not just instant preview but real android device.
I have faced this problem when I test in unity editor but it work perfectly on my android device. That because LifecycleManager.instance.NativeSession is always null in editor and that make AddImage() return -1 which is error.
It's don't work also on real android device. Any other Idea ?