How to use cameraX with SurfaceView/TextureView?

1,389 views
Skip to first unread message

Deepu George Jacob

unread,
Aug 20, 2021, 2:45:14 AM8/20/21
to Android CameraX Discussion Group
Hi,

I am planning to migrate camera api to camerax. Currently I am using SurfaceView to show the camera preview. I noticed that camerax is using PreviewView to show the camera preview. As this library is still in alpha stage, so what is the alternate for that?

I know that previewView internally using SurfaceView/TextureView.

How can I explicitly configure and use SurfaceView/TextureView?


Thanks and Regards

Deepu George Jacob

Eino-Ville Talvala

unread,
Aug 20, 2021, 1:11:00 PM8/20/21
to Deepu George Jacob, Android CameraX Discussion Group
You need to implement a wrapper for your actual View element by creating a Preview.SurfaceProvider.

There's a small example in the docs on how to use it for a custom EGL renderer, which would be pretty similar to what you'd need for TextureView.

But basically, CameraX will call your instance of Preview.SurfaceProvider to get a Surface to draw to, giving you a SurfaceRequest object.
The SurfaceRequest object has information like requested resolution, and methods to call to actually give the Surface to CameraX once you have the Surface ready.

- Eddy

--
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 on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/70db2174-f929-4fd2-9cd8-170bf22cd6c2n%40android.com.

Deepu George Jacob

unread,
Aug 30, 2021, 5:55:01 AM8/30/21
to Android CameraX Discussion Group, Eino-Ville Talvala, Android CameraX Discussion Group, Deepu George Jacob
Thanks Eddy :)
Reply all
Reply to author
Forward
0 new messages