是否可以将 Preview、ImageAnalysis 和 VideoCapture 与 CameraX 结合使用? [英] Is it possible to combine Preview, ImageAnalysis, and VideoCapture with CameraX?

查看:32
本文介绍了是否可以将 Preview、ImageAnalysis 和 VideoCapture 与 CameraX 结合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以同时绑定PreviewImageAnalysisVideoCapture?成对组合,所有可能的组合(即 Preview+ImageAnalysisPreview+VideoCaptureImageAnalysis+VideoCapture) 工作得很好,但将所有三个绑定在一起会引发以下异常.

Is it possible to bind Preview, ImageAnalysis, and VideoCapture at the same time? Combined in pairs, all possible combinations (ie. Preview+ImageAnalysis, Preview+VideoCapture, and ImageAnalysis+VideoCapture) work perfectly fine but binding all three together throws the following exception.

java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 1.  May be attempting to bind too many use cases.
    at androidx.camera.camera2.internal.Camera2DeviceSurfaceManager.getSuggestedResolutions(Camera2DeviceSurfaceManager.java:193)
    at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java:943)
    at androidx.camera.core.CameraX.bindToLifecycle(CameraX.java:293)
    at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:229)

是否有任何解决方法可以让我在使用 ImageAnalysis 的同时录制视频?

Is there any workaround that allows me to use ImageAnalysis and at the same time record a video?

推荐答案

由于相机硬件管道的缩放单元限制,同时输出的数量存在限制.

There are limits to the number of simultaneous outputs that are due to the camera hardware pipeline's scaler unit limitations.

一般来说,除了高端设备之外,不支持 3 个并行 YUV 输出.

In general, 3 parallel YUV outputs aren't supported outside of high-end devices.

您可以在这里查看许多表格:https://developer.android.com/reference/android/hardware/camera2/CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)

You can look at the many tables here: https://developer.android.com/reference/android/hardware/camera2/CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)

看看可以在各种硬件级别上设置哪些类型的并行输出(PRIV 和 YUV 是这些用例操作的对象).

and see what kinds of parallel outputs can be set up, on the various hardware levels (PRIV and YUV are what these usecases operate on).

只要分析以 640x480 或更低的分辨率运行,FULL 设备就可以做到.但 LEGACY 和 LIMITED 不能.

A FULL device can do it, as long as the analysis runs at 640x480 or lower. But LEGACY and LIMITED cannot.

也就是说,您可以使用 ImageAnalysis 帧来驱动预览,但这肯定不太方便 - 可能需要使用 NDK 或其他麻烦.

That said, you can use ImageAnalysis frames to drive a preview, but it's certainly a bit less convenient - may require using the NDK or other annoyances.

这篇关于是否可以将 Preview、ImageAnalysis 和 VideoCapture 与 CameraX 结合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆