an error occurred by CameraX.bindToLifecycle()

前端 未结 5 2060
执念已碎
执念已碎 2021-01-02 06:54

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

相关标签:
5条回答
  • 2021-01-02 07:18

    I got the same error when I tried to create imageCapture, videoCapture, mPreview or the analyzer with different settings between each other.

    Try to set in the builder setting the same parameters, e.g. if you want:

    setLensFacing(CameraX.LensFacing.BACK)
    

    Set in all the setting builders the same. This can fix your error but still, I don't know if the library support this feature jet.

    0 讨论(0)
  • 2021-01-02 07:28

    There is no videoCapture usecase right now.

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

    0 讨论(0)
  • 2021-01-02 07:29

    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.

    0 讨论(0)
  • 2021-01-02 07:30

    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
                                )
                    }
    
    0 讨论(0)
  • I got the same error while popping fragment with camera view from backstack, I fixed it by unbinding all analysers when view exits.

    CameraX.unbindAll()
    

    As suggested here.

    0 讨论(0)
提交回复
热议问题