Android CameraX capture a portion of picture

1,099 views
Skip to first unread message

mushfiq salehine

unread,
Sep 21, 2022, 2:33:58 AM9/21/22
to Android CameraX Discussion Group
I want to capture white box area in cameraX. I don't how to do that. Please help me.
Screenshot (17).png

Charcoal Chen

unread,
Sep 22, 2022, 10:24:30 PM9/22/22
to Android CameraX Discussion Group, mushfiq...@gmail.com
Thanks for the question.

CameraX can't support to only capture portion of the preview image. There might be some approaches to achieve your goal.

1. If you only need the a lower resolution result as the preview's resolution and PreviewView is used, you may be able to get the Bitmap of the preview image by the PreviewView#getBitmap() API and then crop what you want.

2. If you want to get a higher resolution result that is cropped from ImageCapture's captured JPEG image  and PreviewView is used, you may be able to use the (TransformExperimental) CoordinateTransform API to transform the rectangle position cross different types of use cases. Please see the sample code here.

3. If PreviewView is not used, you might need to map the rectangle position from the preview to the ImageCapture's captured image and then crop the portion you want.
Reply all
Reply to author
Forward
0 new messages