Re: [camerax-developers] Is it possible to get imageCapture Target Resolution to equal or less than previewView size?

35 views
Skip to first unread message

Charcoal Chen

unread,
Mar 14, 2023, 6:19:12 AM3/14/23
to Khun Chansopheak, Android CameraX Discussion Group
Hi,

By using existing public API, apps can't specify a setting to select equal to or lower resolution against a specific size. But we're working on a new ResolutionSelector API to provide such a kind of ability. The new ResolutionSelector API is targeted to be public in the 1.3.0-alpha stage.

A short-term solution, you might be able to retrieve the supported JPEG output sizes via Camera2Interop. The code might be similar to:

val cameraInfo = ... // retrieves the CameraInfo of the target camera
val camera2CameraInfo = Camera2CameraInfo.from(cameraInfo)
val streamConfigurationMap = camera2CameraInfo.getCameraCharacteristics(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
val jpegOutputSizes = streamConfigurationMap.getOutputSizes(ImageFormat.JPEG)
// Try to find your preferred size from jpegOutputSizes and then specify it as the ImageCapture's target resolution (Please remember to flip the size according to your target rotation setting)
// Then, bind the ImageCapture use case to lifecycle

BTW, you should be able to unbind the bound ImageCapture use case by ProcessCameraProvider#unbind(UseCase[]). Could you describe more details about the problem you encountered when rebinding the ImageCapture use case?
 




On Mon, Mar 13, 2023 at 6:26 PM Khun Chansopheak <khun.cha...@gmail.com> wrote:
I can list down camera supported resolution after I bind imageCapture to Lifecycle. CameraX will set resolution the higher or max if it doesn't match supported size on the list.

I want to get the right size resolution that have width less than previewView for the output image. To do that I have to loop to find the size (resolution) and setTargetResolution to imageCapture. But after bind imageCapture to Lifecycle, I can't rebind it again because camera in on preview.

I don't want to do rotation and want camera in vertical view only.

--
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/c5f5f95e-6b99-46eb-9b29-4be458f1da6cn%40android.com.
Reply all
Reply to author
Forward
0 new messages