Creating Image References

Include the following details (edit as applicable):

  • Issue category: Image Detection
  • Device type & OS version: Android / iOS
  • Host machine & OS version: Mac / Windows
  • Issue Environment : On Device / Dev Portal
  • **ARDK version1.0.1:
  • **Unity versionUnity2019.4.33 & 2021.2:

Description of the issue:

Ive been trying to understand how to work with image detection with Lightship but im really struggling using the documentation.
The examples show using a jpg.bytes but I have no idea how to actually get my image into a file like this. I tried just getting Texture2D reference to the jpg and than calling GetRawTextureData() but when I do this and try to pass it into the ARReferenceImageFactory I get a null reference exception.

The other methods of getting a reference image in the documentation refer to using RawImage or string path. Using string path no matter how many different string formats I try, when I build the device cannot find the path. For example Path = “Assets/img008.jpg” or “Assets/Resources/img008.jpg” or just “Resources/img008.jpg” all dont work. I’ve also tried all with appending Application.persistentDataPath to the beginning of the path but to no avail.

For the final method using RawImage, im not 100% how this works. I can only assume this is not referring to Unity.UI’s RawImage.

Im sure im missing something easy, but I am completely lost. This is the first AR SDK i’ve used that doesnt accept just image textures. Any help would be appreciated.

1 Like

I have since discovered that appending .bytes to the end of the jpg image does indeed work. When I did it before it didnt work because the unity meta file still thought it was a texture. When i made a different image a .bytes file it than worked on importing.

Hello Scott,

Thank you for your patience.

We were looking into your issue and found that the way you worked around it is the correct way to do it. I wouldn’t worry too much about opening a file using paths if you were able to get it to work this way. Please let me know if you need any further clarification, and if you have any other questions please open a new topic.

Thanks for the reply. I def dont need doing it from a path, being able to get byte arrays from download is a amazing feature.
My only confusion is how to work with PNGs using the raw data method. JPG’s are working great!

1 Like

I had the same problem and I found out that converting it with encodeToJPG() rather than with encodeToPNG() was the solution. But I wanna know the configurations needed to detect the images further than were it was taken. and considering light changes.

Hi Djony,

Thanks for providing your insight on this issue. For the second part of your comment, if you’re interested in learning more or going more in depth, you can always create a new topic where we can answer your questions.