问题
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.
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
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.
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
I'd appreciate any ideas or pointers on this!
回答1:
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
You can find a tentative example based on the android-Camera2Basic
kotlin sample: here
来源:https://stackoverflow.com/questions/55636748/display-camera-preview-on-raspberry-pi-android-things