Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Frame.CameraImage.Texture size #76

Closed
iBicha opened this issue Jan 11, 2018 · 10 comments
Closed

Frame.CameraImage.Texture size #76

iBicha opened this issue Jan 11, 2018 · 10 comments

Comments

@iBicha
Copy link

iBicha commented Jan 11, 2018

I know that ARCore camera texture Frame.CameraImage.Texture is an external texture, so it can be rendered correctly without the need to set the size, but the SDK should set the width and the height of the texture, as this information can be useful in some cases, and also it is misleading to set it to zero.
It shouldn't be complicated to pass these values from the native lib to Unity.

FrameManager.cs:#136

if (m_BackgroundTexture == null)
{
   // The Unity-cached size and format of the texture (0x0, ARGB) is not the
   // actual format of the texture. This is okay because the texture is not
   // accessed by pixels, it is accessed with UV coordinates.
   m_BackgroundTexture = Texture2D.CreateExternalTexture(0, 0, TextureFormat.ARGB32, false,
       false, new IntPtr(cameraTextureId));
}
else
{
       m_BackgroundTexture.UpdateExternalTexture(new IntPtr(cameraTextureId));
}

In addition, the TextureFormat could be set right as well? I would guess it's probably a GL_RGB, so the SDK can set the texture format to TextureFormat.RGB24 for the sake of clarity, in case a developer was trying to read that field.

@chaosemer
Copy link
Contributor

Since the texture is an external texture, this isn't quite the same as for normal GL textures.

  • Regarding format, there is not a corresponding format -- external textures are usually made up two GL textures actually, one GL_RED_8 (for the Y channel) and a GL_RG_16 (for the UV channels).
  • The texture is 16x9 in DP2, it is safe to assume it is 1920x1080.

I'm going to leave this open for other folks who are interested.

@iBicha
Copy link
Author

iBicha commented Jan 11, 2018

Oh yeah never mind me, it's not a normal GL format. I guess the format could be set to TextureFormat.YUY2 which is the closest? And I think it's fine for now, but once ARCore is released supporting more devices, it shouldn't be safe to assume it's 1920x1080 for every device, I think.

@chaosemer
Copy link
Contributor

YUY2 is close, but not really accurate. External textures on Android are in format YUV 4:2:0, but YUY2 is defined to be the format YUV 4:2:2.

You're right about future device work no longer allowing the assumption of 1920x1080. This is known work on our side, we will be updating the API.

@alexbu92
Copy link

So for now can we safely assume that the size is 1920x1080? Is there no way to check at runtime?

@chaosemer
Copy link
Contributor

There is no way to check at runtime at the moment. We're working on a new API surface for this.

@alexbu92
Copy link

Just came back to report that on my Nexus 6P the texture size is actually 640x480 as reported by GAPID and testing.

@chaosemer
Copy link
Contributor

@alexbu92, I'm very confused. The Nexus 6P is not a supported device. How are you developing an ARCore app on it?

@iBicha
Copy link
Author

iBicha commented Feb 21, 2018

@chaosemer https://github.com/tomthecarrot/arcore-for-all is getting almost twice as popular as this repo...

@chaosemer
Copy link
Contributor

Please don't file bugs here on an unofficial modification to ARCore. We can't make any guarantees in what the behavior is on devices other than the ones we certify.

@iBicha
Copy link
Author

iBicha commented Apr 18, 2018

Closing this since CameraImageBytes CPU access could be used. (even though it is still different from the issue at hand, texture size)
Feel free to reopen this if it is relevant/to be fixed in a future release.

@iBicha iBicha closed this as completed Apr 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants