USB webcam support in Nougat Camera API
Asked Answered
F

2

8

I am building a Nougat AOSP image for Raspberry Pi 3 following these instructions: https://github.com/tab-pi/platform_manifest. And I have a UVC-compatible USB webcam (Logitech C525) that I would like to access through Android Camera API.

So far the webcam is visible in UsbManager.getDeviceList() but Camera.getNumberOfCameras() returns 0.

I have customized the kernel so that there's a /dev/video0 appearing with the appropriate permissions when plugging the webcam:

$ adb shell ls -l /dev/video0
crw-rw---- 1 system camera 81,   0 2018-09-20 10:16 /dev/video0

I've tried to build the following HALs against my AOSP tree but they all fail:

To put it in a nutshell, how can I access a USB camera through the Android Camera API on the Raspberry Pi ?

Flatboat answered 13/9, 2018 at 10:19 Comment(12)
This seems to depend on the Android version you're using. For versions with Tremble there is a guide in the official documentation: source.android.com/devices/camera/external-usb-cameras. For versions before Tremble you can find a V4L2 based HAL implementiation here: github.com/aosp-mirror/platform_hardware_libhardware/tree/…Bradwell
@Bradwell Since the Android version is Nougat I assume that Treble is not available, right?Flatboat
Right. Oreo was the first that came with Tremble. Have you tried the second link? This one should work on Nougat.Bradwell
Did you enable V4L2? Do you see a /dev/video0 and are the permissions adequate?Bradwell
github.com/openxc/android-webcam#usb-webcam-supportBradwell
@Bradwell I updated my question with the results of my latest experimentsFlatboat
@fiddler you need to create an USB filter for devices of class 14... developer.android.com/reference/android/hardware/usb/… in order to access it from within an app (don't think that an addition HAL is required). the camera class is deprecated; later API level tend to use camera2 instead.Grano
@MartinZeitler AFAIK this is only required to be notified of (dis)connection eventsFlatboat
@fiddler that's true, nevertheless these events are relevant for such applications... eg. that one can select the application (as default), whenever plugging in an USB webcam.Grano
@fiddler what kind of errors do you get when building the HAL?Bradwell
@Bradwell see my editFlatboat
hello, I can turn on my usb camera using this, however I would like to access it using navigator.mediadevices, it still doesn't show up there. Is there any way to do that?Soilasoilage
E
0

You can try checking the init.rc file at location /device/fsl/. And set back_camera_name uvc . While booting up it looks for the specified default camera and it fails to initialize the camera driver when the mentioned camera is missing. I was facing the same issue in technexion imx6 boards. Also you find a board specific file which in case of technexion is init.i.MX6DL.rc which specifies the back_camera parameter.

Elfriedeelfstan answered 4/10, 2018 at 4:10 Comment(0)
E
0

The team at my company was able to backport USB camera support from Android 9 to Android 8, but it wasn't easy and involved changes to at least five git repositories and many thousands of lines of code moved and tweaked when needed. Back porting USB camera support to Android 7 sounds like an even more difficult task.

Why not just install Android 9 on your Raspberry Pi?

Perhaps try:

https://github.com/brobwind/pie-device-brobwind-rpi3

https://konstakang.com/devices/rpi3/LineageOS16.0/

Ethos answered 13/3, 2020 at 23:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.