} else {setResolutionStrategy(ResolutionStrategy(Size(binding.cameraViewer.width,binding.cameraViewer.width), ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER))}
When creating a ResolutionSelector instance, theRATIO_4_3_FALLBACK_AUTO_STRATEGY
will be the defaultAspectRatioStrategy
if it is not set.
Please refer to the ViewPort's documentation.ForImageAnalysis
and in-memoryImageCapture
, the output crop rect isgetCropRect
; for on-diskImageCapture
, the image is cropped before saving; forPreview
, the crop rect isgetCropRect
.Could you describe more details about what does "viewport not work without videoCapture" mean? For example, what is your setting and what are the incorrect output sizes or the resolutions selected for the Preview/ImageCapture?
CameraX's selection logic is to select the best resolution from the supported output sizes retrieved from StreamConfigurationMap#getOutputSizes(). For 16:9 or 4:3 aspect ratio settings, most devices should support output sizes of the aspect ratios. But for 1:1, you will need to implement a ResolutionFilter to put the 1:1 output sizes to the higher priority position. Because most devices might not support 1:1 output sizes and sometimes the supported 1:1 size might not match your requirement (maybe too small). Please also describe more details about what is the final AspectRatioStrategy setting and what are the incorrect output sizes or the resolutions selected for the Preview/ImageCapture for this question?
Which UseCase's output size or selected resolution is not 16:9? What is the incorrect output size or selected resolution?
--
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/41e697cb-6e20-4d4d-bd4a-58c47f0f8ac3n%40android.com.
Hi,
I’m wondering whether there are some misunderstandings about what ResolutionSelector (ResolutionStrategy, AspectRatioStrategy) is used for? For an app to show the preview on the display, it needs to obtain the images from the camera device, and then resize/scale/rotate the images to correctly show on an Android View on the display.
The ResolutionSelector (ResolutionStrategy, AspectRatioStrategy) is used to select the best suitable resolution for your app from the device supported output sizes, but not for cropping the output images. After launching the your camera app, you can use the command “adb shell dumpsys media.camera | grep Dims” to know what resolutions are selected to create the camera capture session to output images for Preview/ImageCapture. It looks like below. 1920x1080 is the output size for Preview and 4032x2268 is for ImageCapture.
The PreviewView is used to show the images on the display. It helps you to resize/scale/rotate to show the images in the correct direction/aspect ratio (FILL_CENTER by default).
If you want to make the preview be 1:1, 4:3, 16:9, you will need to manually adjust the PreviewView's layout setting in your app to the desired aspect ratio. Then, no matter which aspect ratio of output size is selected to create the capture session for the Preview UseCase, the images shown in the PreviewView should be correct.
setAspectRatioStrategy can’t help the app to directly crop to output images. ViewPort can help to crop the images in the image or video saved by CameraX. But for preview, in-memory still capture or ImageAnalysis images, only a crop rect info is provided for the app to know the area mapping to the ViewPort.
Please let me know whether this can explain the issue you encountered or not. Thanks.