Limited-level (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
LIMITED
) devices support at least the following stream combinations in addition to those for LEGACY
devices:
Target 1 | Target 2 | Target 3 | Sample use case(s) | |||
---|---|---|---|---|---|---|
Type | Max size | Type | Max size | Type | Max size | |
PRIV | PREVIEW | PRIV | RECORD | High-resolution video recording with preview. | ||
PRIV | PREVIEW | YUV | RECORD | High-resolution in-app video processing with preview. | ||
YUV | PREVIEW | YUV | RECORD | Two-input in-app video processing. | ||
PRIV | PREVIEW | PRIV | RECORD | JPEG | RECORD | High-resolution recording with video snapshot. |
PRIV | PREVIEW | YUV | RECORD | JPEG | RECORD | High-resolution in-app processing with video snapshot. |
YUV | PREVIEW | YUV | PREVIEW | JPEG | MAXIMUM | Two-input in-app processing with still capture. |
--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/bbd30b6b-902b-432b-8bb6-3869060ad5een%40android.com.
When using a TextureView
to display camera preview images and you've set an OnFrameAvailableListener
, you can access the frames for analysis by following these steps:
Obtain the SurfaceTexture:
SurfaceTexture
associated with the TextureView
using getTextureView().getSurfaceTexture()
.Update the SurfaceTexture:
onFrameAvailable()
callback of your OnFrameAvailableListener
, call surfaceTexture.updateTexImage()
to update the SurfaceTexture
with the latest frame from the camera.Acquire a Frame Buffer:
GLES20.glGenFramebuffers(1, fbo, 0)
.Bind the Frame Buffer and SurfaceTexture:
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo[0])
.SurfaceTexture
to the frame buffer using GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textureId, 0)
.Read Pixels:
GLES20.glReadPixels()
to read the pixel data from the frame buffer into a buffer.Image Format:
The format of the image data obtained will depend on the camera's output format, which you can configure using Camera.Parameters
. Common formats include:
Example Code Snippet:
// In your OnFrameAvailableListener
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
surfaceTexture.updateTexImage();
// ... (Bind frame buffer and read pixels as described above)
// Assuming the camera output format is NV21
ByteBuffer buffer = ByteBuffer.allocateDirect(width * height * 3 / 2);
GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buffer);
// ... (Process the image data in 'buffer')
}
Important Considerations:
GLES20.glGetError()
.