Open rajeshkumarMSEN opened 5 years ago
I also faced the problem in unity. I used to get "-1" every time I tried to add an image in the AugmnetedImageDatabase.
There are two possible reasons for this :-
Problem_#1) Format of the Image you are adding is not correct. AugmnetedImageDatabase only supports jpg and png files and that too in RGBA32 format only.
Possible Solution: Convert your png/ jpg image into dezired texture format by creating a new Texture2D. Texture2D yourImage = "Set your image here via path" //Creating a new image of the dezired texture using the "yourImage". Texture2D newRGBTexture = new Texture2D(yourImage .width, yourImage .height, TextureFormat.RGBA32, false); newRGBTexture .SetPixels(yourImage.GetPixels()); newRGBTexture .Apply();
Problem_#2) Trying to access the AugmentedImageDatabase before the ARCore Session has been initialised. I was stuck here. As I was calling my addAugmentedImage() in start(), so the my AugmnetedImageDatabase was accessed before my ARCore session was initialised.
Possible Solution: I used the Invoke function and called the addAugmentedImage() after 1 second. ( Invoke(functionToBeCalled(),TimeInSeconds) ). Read about invoke function.
PS: The ARCore guys should add separate Debug.Log() for both the different cases, so that it is easier for the developer to find out where things are going wrong.
This was my first answer ever, so I am sorry if I did anything incorrectly. I hope it was helpful.
Cheers -Jking
newRGBTexture .SetPixels(texture.GetPixels());
I don't understand about this texture.GetPixels(). which "texture" ?
@rajeshkumarMSEN Actually it is supposed to be "yourImage.GetPixels()". I have edited it in the answer.... So use this "newRGBTexture .SetPixels(yourImage.GetPixels());"
Try it out and feel free to ask if the problem still persists.
PS: I would suggest you to add @Jatin-Pawar handle so that I get notified whenever you ask any question.This time you got lucky as I just randomly checked this post out.
Note: Anybody reading this out....don't worry I have already edited the answer above...so follow that.
Cheers -Jking
SPECIFIC ISSUE ENCOUNTERED
AddImage method not working in Unity android. created new database,used exiting database,copyfrom existing database,used 24 bit rgb with R/W enabled still its not working. even created separate background thread with time delay before addimage call still nots working.
VERSIONS USED
STEPS TO REPRODUCE THE ISSUE
1.Tried to addImage in the AugmentedImageDataBase - Unity-Android
WORKAROUNDS (IF ANY)
ADDITIONAL COMMENTS