在 Raspberry Pi Android 事物上显示相机预览

Display camera preview on Raspberry Pi Android things

我正在开发一个应用程序,该应用程序在 Raspberry Pi 上运行 Android Things 并且应该在外部显示器上显示相机预览并且有一个按钮附加到演示上被按下时,从相机拍摄一张照片并对拍摄的图像进行一些计算。

我已成功完成第二部分,但在尝试在屏幕上获取相机预览时,应用程序崩溃了。 我昨天拿到了我的 RPi,我在 Github (https://github.com/googlesamples/android-Camera2Basic) 上尝试了 运行 Camera2 样本,但我 运行 遇到了和以前一样的问题。

I/CameraManagerGlobal: Connecting to camera service
2019-04-01 00:18:19.670 4625-4650/com.example.android.camera2basic W/CameraDevice-JV-0: Stream configuration failed due to: endConfigure:372: Camera 0: Unsupported set of inputs/outputs provided
2019-04-01 00:18:19.682 4625-4650/com.example.android.camera2basic E/CameraCaptureSession: Session 0: Failed to create capture session; configuration failed

我还尝试将 ImageReader 中预览的宽度和高度修改为我的 Android 事物控制台上显示的兼容尺寸之一(请参阅下面屏幕截图中的 JPEG 部分),但那没有帮不上忙

不过,我确实在 Github 上找到了一个 repo,它可以让我在 RPi 板上进行实时预览,但缺点是它的帧率很糟糕 (10-15 FPS)。 存储库 Link:https://github.com/harshithdwivedi/CameraDemoForAndroidThings

如果有任何想法或建议,我将不胜感激!

如底层 V4L2 实现的 another issue the RPI3 camera HAL only support one target surface at a time, this apparently come from a limitation 中所述。

以下解决方法应该可行:

您可以根据 android-Camera2Basic kotlin 示例找到一个初步示例:here