在Raspberry Pi Android上显示相机预览 [英] Display camera preview on Raspberry Pi Android things

查看:175
本文介绍了在Raspberry Pi Android上显示相机预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在开发一个在具有Android Things的Raspberry Pi上运行的应用程序,该应用程序应该在外部显示器上显示Camera预览,并且演示中附带有一个按钮,按下该按钮可以从相机中捕获图片并对捕获的图像进行一些计算.

I was working on an app that runs on a Raspberry Pi with Android Things and is supposed to show a Camera preview onto an external display and there's a push button attached to the demo which on being pressed, captures a picture from the camera and does some computation on that captured image.

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

I've successfully completed the second part, but while trying to get a camera preview on the screen, the app crashes for me. I got my RPi yesterday and I tried running the Camera2 sample on Github (https://github.com/googlesamples/android-Camera2Basic) but I ran into the same issue as before.

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内的Preview的宽度和高度修改为兼容的大小之一,如我的Android Things控制台上所示(请参见下面的屏幕快照中的JPEG部分),但这没有帮助.

I have also tried modifying the width and height of the Preview inside ImageReader to one of the compatible sizes as shown on my Android things console (see the JPEG section in the screenshot below) but that didn't help.

但是,我确实在Github上找到了一个回购协议,可以在RPi板上实时预览,但是缺点是帧速率很差(10-15 FPS). 存储库链接: https://github.com/harshithdwivedi/CameraDemoForAndroidThings

However, I did find a repo on Github that gives me realtime preview on a RPi board, but the downside is that it has a terrible Framerate (10-15 FPS). Repository Link : https://github.com/harshithdwivedi/CameraDemoForAndroidThings

对此我将不胜感激!

推荐答案

另一个问题 RPI3相机HAL一次仅支持一个目标表面,这显然来自

As commented in another issue the RPI3 camera HAL only support one target surface at a time, this apparently come from a limitation of the underlying V4L2 implementation.

以下变通办法应该是可能的:

The following workaround should be possible:

  • for preview: use a SurfaceView as the target surface
  • when taking picture: in the CaptureCallback use PixelCopy to grab the raw frame from the surface

您可以找到基于android-Camera2Basic kotlin示例的暂定示例:此处

You can find a tentative example based on the android-Camera2Basic kotlin sample: here

这篇关于在Raspberry Pi Android上显示相机预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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