=> PREVIEW refers to the best size match to the device's screen resolution, or to 1080p (1920x1080), whichever is smaller.
--
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/9382de94-3f55-4055-a292-6a6b75a03d6an%40android.com.
Hi,
As I mentioned in my first replyment, camera devices have their capabilities limitation. CameraX refers to the guaranteed supported configurations tables listed in the CameraDevice's regular-capture section to find the best suitable resolutions for the bound UseCase combination. Actually, the guaranteed supported configurations tables do not include a configuration for four streams for Preview + VideoCapture + ImageAnalysis + ImageCapture combination. For this use case, CameraX uses a stream sharing mechanism to share images from one stream to Preview and VideoCapture UseCases. But this also has some restrictions to avoid some double-cropping image or resolution selection performance problems. There might be too many details there. Please let me know if you are interested in any part. But, the results you provided for 1.4.0 match our expectations. Here are the explanations for your app’s cases.
Case 1: your app wants the Preview to have 1080p resolution and VideoCapture to have 480p resolution
Because four UseCases are bound, CameraX needs to find a resolution to share to these VideoCapture and Preview. To avoid the double-cropping issue, CameraX selects a 4:3 resolution to create the stream to share the images. According to the guaranteed tables, only 4:3 resolutions under 1080p or display size can be selected. Finally, maybe 1440x1080 or 1280x960 is selected according to the device's supported output sizes, and the images are cropped and scaled to produce the 1280x720 images to Preview and 720x480 images to VideoCapture.
Case 2: your app wants the Preview to have 1080p resolution and VideoCapture to have 720p resolution
To avoid the double-cropping issue and have better resolution selection performance, CameraX would select 4:3 resolutions in priority. To make 1080p can be selected for Preview in this case, apps can use ResolutionSelector and implement a ResolutionFilter to force CameraX to select 1080p resolution for Preview. The code looks like:
val preview = Preview.Builder()
.setResolutionSelector(ResolutionSelector.Builder()
.setResolutionFilter { supportedSizes, _ ->
val resultList = mutableListOf<Size>()
if (supportedSizes.contains(Size(1920, 1080))) {
resultList.add(Size(1920, 1080))
}
resultList
}
.build())
.build()
Please note that not all devices can support the configuration. Therefore, if an IllegalArgumentException is thrown when calling bindToLifecycle method, your app would need to try-catch it and loosen the resolution conditions to make the UseCases bound successfully.