fast way to get contents of SurfaceTexture?

Started by raft, December 19, 2013, 09:10:55 AM

Previous topic - Next topic

raft

does anybody now a fast way to get contents of a SurfaceTexture?

SurfaceTexture is a very convenient way to direct Android's Camera or MediaPlayer output to a texture in GLSurfaceView, kind of render to texture. But I also need the pixel data of the surface for further processing and the only way I found is via GLES20.glReadPixels which is infeasably slow. only getting pixels without any processing drops FPS to 4 on a Samsung S3.

Some information here: it says a SurfaceTexture is backed by an external texture and that's why its content can not be retrieved in regular ways.

EgonOlsen

glReadPixels is slow but so is every read operation that has to access data in the gpu's domain. I don't see how this can be done faster. Isn't there another way to get the camera's output? Does it has to be via this SurfaceTexture?

raft

yes there is another way, that is:

* register a preview callback to camera.
* convert byte array provided to callback from YUV to some format that jPCT can handle
* make or update a texture out of that
* blit that texture to frame buffer before any other 3d content

despite the overhead of yuv -> jpeg -> texture -> upload cycle, this runs 40 fps (which is vSynch limit I Suppose) on Samsung S3. I'm just trying to figure an easier way.