How to flip camerax preview in PreviewView

1,241 views
Skip to first unread message

PAWAN THAKUR

unread,
Oct 1, 2020, 5:54:53 AM10/1/20
to Android CameraX Discussion Group
How to apply matrix transform to Preview View just like we apply it for TextureView.
Please help I tried to find in docs, but could not progress.

Xi Zhang (张熹)

unread,
Oct 1, 2020, 9:44:56 AM10/1/20
to PAWAN THAKUR, Android CameraX Discussion Group
Hi Pawan:

PreviewView does not support it at the moment. We might support it in the future, but I would like to better understand your scenario first. What is the reason you want to flip the Preview?

Thank you,

Xi

On Thu, Oct 1, 2020 at 2:54 AM PAWAN THAKUR <pwnkm...@gmail.com> wrote:
How to apply matrix transform to Preview View just like we apply it for TextureView.
Please help I tried to find in docs, but could not progress.

--
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/c4cc5889-3401-4fd9-81cf-596652aba3fdn%40android.com.

PAWAN THAKUR

unread,
Oct 1, 2020, 10:04:39 AM10/1/20
to Android CameraX Discussion Group, Xi Zhang, Android CameraX Discussion Group, PAWAN THAKUR
I need to show both mirrored and non-mirrored view with both front and back camera.

Xi Zhang (张熹)

unread,
Oct 1, 2020, 1:42:49 PM10/1/20
to PAWAN THAKUR, Android CameraX Discussion Group

PAWAN THAKUR

unread,
Oct 1, 2020, 10:55:55 PM10/1/20
to Android CameraX Discussion Group, Xi Zhang, Android CameraX Discussion Group, PAWAN THAKUR
Thankyou so much.

 For time being, could you guide me if we can use TextureView instead of PreviewView with CameraX or not?

Regards

Xi Zhang (张熹)

unread,
Oct 2, 2020, 11:53:36 AM10/2/20
to PAWAN THAKUR, Android CameraX Discussion Group
You can use TextureView instead of PreviewView, but it means that you have to manually handle the Surface which can be tricky. If you wish to do so, I would suggest you take a look at the source code of TextureViewImplementation.java and use it as an example.

LINGA venkatesh

unread,
Oct 12, 2020, 1:34:39 AM10/12/20
to Android CameraX Discussion Group, Xi Zhang, Android CameraX Discussion Group, pwnkm...@gmail.com
We too have a similar requirement to apply some matrix dynamically computed. 
Can we have this task(for supporting matrix transform on PreviewView) prioritized?
Incase if the work is already in progress, do we have any ETA?

Regards,
Venkatesh.

Xi Zhang (张熹)

unread,
Oct 12, 2020, 12:43:36 PM10/12/20
to LINGA venkatesh, Android CameraX Discussion Group, pwnkm...@gmail.com
Venkatesh, what is the matrix to be applied in your case?  Is it also flipping, or is it rotation?  For rotation, preview now supports arbitrary rotation via Preview#setTargetRotation. If the PreviewView is used, it will take care of the rotation as long as Preview#setTargetRotation is set.

LINGA venkatesh

unread,
Oct 12, 2020, 1:31:52 PM10/12/20
to Android CameraX Discussion Group, Xi Zhang, Android CameraX Discussion Group, pwnkm...@gmail.com, LINGA venkatesh
Hi Zhang,

I have a quad with four points(points doesn't change). I wanted to crop previewView with these four points and perspective to a rectangle.

Regards,
Venkatesh.

Xi Zhang (张熹)

unread,
Oct 12, 2020, 1:49:18 PM10/12/20
to LINGA venkatesh, Android CameraX Discussion Group, pwnkm...@gmail.com
I'm curious what the quad is for. Is it for syncing crop rects across use cases? If so, can you take a look at the ViewPort API and see if it fits your needs? 

What the ViewPort does is that, once applied, the crop rect of all the use cases will point to the same area in the sensor. By using PreviewView, it will transform the preview in a way that only the crop rect is visible to users. The transformation in PreviewView also takes care of edge cases so you don't have to.

Reply all
Reply to author
Forward
0 new messages