google-ar / arcore-unity-sdk

ARCore SDK for Unity
https://developers.google.com/ar
Other
1.4k stars 402 forks source link

TextureReader in SDK #135

Closed iBicha closed 6 years ago

iBicha commented 6 years ago

~~I was wondering why the texture reader in the computer vision example, why the buffer format is either GL_RED or GL_RGBA, I think it should be GL_RED or GL_RGB, since alpha is not used at all. Another option is to pass the GL format from the C# script, keep it flexible (one could choose another format without having to recompile the texture reader utility)~~ Totally forgot about frame buffer formats, nevermind, but feel free to correct me if I'm wrong.

=> Also, could the texture be part of the SDK instead of the example? I think that makes a bit more sense. Thanks.

chaosemer commented 6 years ago

Thanks for the feature request.

Getting CPU access to the underlying texture is a very highly asked for feature. We're looking into it.

iBicha commented 6 years ago

Thanks!

iBicha commented 6 years ago

@chaosemer just a small pointer, if the future implementation will be based on reading PBOs from previous frames, we might need a timestamp with each frame, just to know how old it is (one might choose to not get these pixel buffers every frame) Cheers

chaosemer commented 6 years ago

This use case is supported!

TextureReaderApi.SubmitFrame returns an integer that uniquely identifies that frame. You can store any associated data (pose, lighting estimation, etc.) that you want to preserve with that integer as a key and look it up when you get the frame back from AcquireFrame.

iBicha commented 6 years ago

I thought it would return the buffer index where the frame would be stored (which would be 0 or 1 since the buffer count is 2) But I think I see what you mean, one could store a timestamp separately every time SubmitFrame is called, and return it when AcquireFrame is called.

chaosemer commented 6 years ago

Yeah, exactly what you said.

Also, you are correct that SubmitFrame will reuse IDs.

pablisho commented 6 years ago

Hi, ARCore Unity SDK v1.1.0 supports CPU image access in its API via Frame.AcquireCameraImageBytes.