How can i get the image as in the preview size of TextureView in camera 2

833 Views Asked by At

I am learning camera 2 API using google sample code android-Camera2Basic in that i have changed the width and height of AutoFitTextureView to 200 dp and when i capture the picture then i seeing that picture has more focused area than the preview size.

So How can i get the image as in the preview?

1

There are 1 best solutions below

0
On

Assuming you want the image to be cropped the same way as your preview, which is what I think you are asking, you can use the the SCALER_CROP_REGION which is a field of the Camera2 API CaptureRequest class.

More information is available here: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION