[英]How to listen to the cameraX lens facing changes
Does camerax provide api for lens facing changes callback? camerax 是否提供 api 用于镜头朝向更改回调? After switching the lens facing camera I want to be notified when it has finished changing and the camera is ready to use.
切换面向镜头的相机后,我希望在完成更换并且相机可以使用时收到通知。
Currently I'm using this dependencies of camerax目前我正在使用camerax的这个依赖项
implementation "androidx.camera:camera-lifecycle:1.0.0-beta01"
implementation "androidx.camera:camera-view:1.0.0-alpha08"
implementation "androidx.camera:camera-extensions:1.0.0-alpha08"
Sounds like you need a signal for when the camera starts emitting frames.听起来您需要一个信号来指示相机何时开始发射帧。 You can use
Camera2Interop
and set a CaptureCallback
on the preview use case for example.例如,您可以使用
Camera2Interop
并在预览用例上设置CaptureCallback
。 After binding the preview use case using a CameraSelector
for the lens facing you want, you can listen for when onCaptureCompleted()
is invoked, this should give you a signal that the camera has started.使用
CameraSelector
为您想要的镜头绑定预览用例后,您可以在调用onCaptureCompleted()
时进行监听,这应该会给您一个相机已启动的信号。
val builder = Preview.Builder()
Camera2Interop.Extender(builder).setSessionCaptureCallback(object: CameraCaptureSession.CaptureCallback() {
override fun onCaptureCompleted(session: CameraCaptureSession, request: CaptureRequest, result: TotalCaptureResult) {
// Camera will start emitting frames
}
})
val preview = builder.build()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.