如何锁定/冻结 CameraX 预览 TextureView?

Che*_*-Yi 5 android android-camerax

我正在关注 CameraX代码实验室,并在 Android Studio 中查看了他们的示例应用程序和源代码,但似乎没有办法冻结或锁定TextureView显示预览帧的内容。

在 Camera2 API 中,我们可以调用类似的东西cameraCaptureSession?.stopRepeating(),并且TextureView将停止从相机获取输入。

我冻结预览的用例是向用户显示当前正在保存的图像,因为我在TextureView.

小智 13

// You can unbind from any UseCase
CameraX.unbind(previewUseCase)
// In this way TextureView will hold the last frame


 // for version 1.0.0-alpha07
 cameraProvider.unbind(preview);
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,这有效。为了重新启用预览,我只需再次绑定`previewUseCase`。 (3认同)