Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

an error occurred by CameraX.bindToLifecycle()

java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0. May be attempting to bind too many use cases.

why the bindToLifecycle() only choose imageCapture or videoCapture?

 CameraX.bindToLifecycle(lifecycleOwner, mPreview, imageCapture,videoCapture)
like image 895
user6407556 Avatar asked Jul 20 '19 16:07

user6407556


3 Answers

A workaround is to bind Preview with VideoCapture, and Preview with ImageCapture separately. Binding Preview, ImageCapture and VideoCapture appears to be an issue on a few devices currently. When switching between the two be careful to unbindAll first.

This may be because the VideoCapture UseCase is not officially supported yet, as of 1.0.0-Beta10.

fun startVideoCapture() {
        ...
                cameraProvider.unbindAll()
                cameraProvider.bindToLifecycle(
                                lifecycleOwner,
                                cameraSelected,
                                previewUseCase,
                                videoCaptureUseCase
                            )
                }
fun startImageCapture() {
        ...
                cameraProvider.unbindAll()
                cameraProvider.bindToLifecycle(
                                lifecycleOwner,
                                cameraSelected,
                                previewUseCase,
                                imageCaptureUseCase
                            )
                }
like image 171
Alt-Cat Avatar answered Nov 18 '22 17:11

Alt-Cat


You are binding more UseCases than your device's camera supports. Not all devices can support two ImageAnalyzers.

Try reducing your analyzers,

CameraX.bindToLifecycle(lifecycleOwner, mPreview, imageCapture or videoCapture)

I have tested with many devices, so far, among the devices that I tested, only Google Pixel 1 works with three analyzers.

To suggest a hack, remove imageCapture analyzer, try to get images from preview for imageCapture and use videoCapture.

Hope it helps.

like image 6
Ye Min Htut Avatar answered Nov 18 '22 15:11

Ye Min Htut


There is no videoCapture usecase right now.

As mentioned in the official documentation, the available usecases are preview, analysis & image capture (and their combinations).

like image 3
Chrisvin Jem Avatar answered Nov 18 '22 17:11

Chrisvin Jem