Hi,
I have initialised the fullscreen camera using the below code, which is working fine in the other mobile phones except Moto G9.
...
private val targetResolution = Size(1080, 1920)
...
cameraExecutor = Executors.newSingleThreadExecutor()
...
private fun startCamera() {
val cameraProviderFuture = ProcessCameraProvider.getInstance(requireContext())
val cameraSelector =
CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build()
cameraProviderFuture.addListener({
val cameraProvider = cameraProviderFuture.get()
imagePreview = Preview.Builder().apply {
setTargetResolution(targetResolution)
setTargetRotation(binding.previewView.display.rotation)
}.build()
imageAnalysis = ImageAnalysis.Builder().apply {
setTargetResolution(targetResolution)
setTargetRotation(binding.previewView.display.rotation)
setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
}.build().also {
scannerAnalyzer = ScannerAnalyzer(args, this)
it.setAnalyzer(
cameraExecutor, scannerAnalyzer
)
}
cameraProvider.unbindAll()
camera = cameraProvider.bindToLifecycle(
this,
cameraSelector,
imagePreview,
imageAnalysis
)
cameraControl = camera.cameraControl
cameraInfo = camera.cameraInfo
imagePreview.setSurfaceProvider(binding.previewView.surfaceProvider)
setTorchStateObserver()
}, ContextCompat.getMainExecutor(requireContext()))
}
The device camera and preview resolutions are
Supported Hardware Level : 3
Image capturing YUV_420_888 available output size: 4000x2250
Image capturing YUV_420_888 available output size: 4000x1800
Image capturing YUV_420_888 available output size: 3264x2448
Image capturing YUV_420_888 available output size: 3264x1836
Image capturing YUV_420_888 available output size: 3264x1468
Image capturing YUV_420_888 available output size: 1920x1080
Image capturing YUV_420_888 available output size: 1920x864
Image capturing YUV_420_888 available output size: 1600x1200
Image capturing YUV_420_888 available output size: 1440x1080
Image capturing YUV_420_888 available output size: 1600x900
Image capturing YUV_420_888 available output size: 1600x720
Image capturing YUV_420_888 available output size: 1504x720
Image capturing YUV_420_888 available output size: 1280x720
Image capturing YUV_420_888 available output size: 1280x576
Image capturing YUV_420_888 available output size: 1200x540
Image capturing YUV_420_888 available output size: 1024x768
Image capturing YUV_420_888 available output size: 1120x504
Image capturing YUV_420_888 available output size: 960x720
Image capturing YUV_420_888 available output size: 960x540
Image capturing YUV_420_888 available output size: 720x1280
Image capturing YUV_420_888 available output size: 720x540
Image capturing YUV_420_888 available output size: 720x480
Image capturing YUV_420_888 available output size: 640x480
Image capturing YUV_420_888 available output size: 352x288
Image capturing YUV_420_888 available output size: 320x240
Image capturing YUV_420_888 available output size: 256x192
Image capturing YUV_420_888 available output size: 240x320
Image capturing YUV_420_888 available output size: 176x144
Preview available output size: 4000x2250
Preview available output size: 4000x1800
Preview available output size: 3264x2448
Preview available output size: 3264x1836
Preview available output size: 3264x1468
Preview available output size: 1920x1080
Preview available output size: 1920x864
Preview available output size: 1600x1200
Preview available output size: 1440x1080
Preview available output size: 1600x900
Preview available output size: 1600x720
Preview available output size: 1504x720
Preview available output size: 1280x720
Preview available output size: 1280x576
Preview available output size: 1200x540
Preview available output size: 1024x768
Preview available output size: 1120x504
Preview available output size: 960x720
Preview available output size: 960x540
Preview available output size: 720x1280
Preview available output size: 720x540
Preview available output size: 720x480
Preview available output size: 640x480
Preview available output size: 352x288
Preview available output size: 320x240
Preview available output size: 256x192
Preview available output size: 240x320
Preview available output size: 176x144
Chosen Preview resolution: 720x1280
Chosen Image Analyser resolution: 720x1280
Device: Motorola Moto G9
Display Resolution: 1600x720
Android Version: 10
Software Version: QPXS30.30-Q3-38-59-2
I am using the given below dependencies for CameraX.
- Gradle: androidx.camera:camera-camera2:1.0.0-rc03@aar
- Gradle: androidx.camera:camera-core:1.0.0-rc03@aar
- Gradle: androidx.camera:camera-lifecycle:1.0.0-rc03@aar
- Gradle: androidx.camera:camera-view:1.0.0-alpha22@aar
I am always getting similar frame in the ImageAnalysis's analyze method. Please let me know if I am missing something or is it a bug in cameraX for this device?
Thanks
Vikram Mittal