如何取消绑定 cameraX 中的单个用例

How to unbind single use-case in cameraX

我有多个镜头、预览、对焦等用例

我知道怎么解绑了cameraProvider?.unbindAll()

但是,如何只解绑一个用例。如何只传递焦点解除绑定?

它是怎么知道的,如果我通过 cameraProvider?.unbind(imageCapture) 要取消绑定哪一个,因为没有顺序并且它们没有分配给任何变量。所以,我很困惑!

每次解绑都会重新加载所有画面。所以,我需要以某种方式避免这种情况。

尝试时,我也收到此错误

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

But, how to unbind only one use case

您只能使用 ProcessCameraProvider.unbind() 取消绑定一个用例(甚至两个用例),它接受类型为 UseCase.

的可变数量的参数(varargs)
// Binding Preview and ImageCapture use cases
cameraProvider.bind(lifecycleOwner, cameraSelector, preview, imageCapture)

...

// Unbinding the ImageCapture use case
cameraProvider.unbind(imageCapture)

And how It knows, Which one to unbind if I pass cameraProvider?.unbind(imageCapture) because there is no order and they are not assigned to any variable. So, I'm confused !

例如,CameraX 不需要明确知道您正在取消绑定图像捕获用例。它解除绑定具有特定配置的用例,例如表面、分辨率、图像格式等。如有必要,这将转化为更新相机捕获会话。

Each time I unbind all the screen will be reloaded. So, I need to somehow avoid that.

故障可能是由于取消绑定重复的捕获请求引起的,例如预览。