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 ?

sdabet
  • 18,360
  • 11
  • 89
  • 158
  • This seems to depend on the Android version you're using. For versions with Tremble there is a guide in the official documentation: https://source.android.com/devices/camera/external-usb-cameras. For versions before Tremble you can find a V4L2 based HAL implementiation here: https://github.com/aosp-mirror/platform_hardware_libhardware/tree/master/modules/camera/3_4 – manuel Sep 13 '18 at 12:01
  • @manuel Since the Android version is Nougat I assume that Treble is not available, right? – sdabet Sep 13 '18 at 13:55
  • Right. Oreo was the first that came with Tremble. Have you tried the second link? This one should work on Nougat. – manuel Sep 14 '18 at 07:31
  • Did you enable V4L2? Do you see a /dev/video0 and are the permissions adequate? – manuel Sep 14 '18 at 08:23
  • https://github.com/openxc/android-webcam#usb-webcam-support – manuel Sep 14 '18 at 09:03
  • @manuel I updated my question with the results of my latest experiments – sdabet Sep 20 '18 at 12:49
  • @fiddler you need to create an USB filter for devices of class 14... https://developer.android.com/reference/android/hardware/usb/UsbConstants.html#USB_CLASS_VIDEO 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. – Martin Zeitler Sep 20 '18 at 13:10
  • @MartinZeitler AFAIK this is only required to be notified of (dis)connection events – sdabet Sep 20 '18 at 13:15
  • @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. – Martin Zeitler Sep 20 '18 at 13:16
  • @fiddler what kind of errors do you get when building the HAL? – manuel Sep 26 '18 at 08:42
  • @manuel see my edit – sdabet Sep 26 '18 at 10:45
  • 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? – ilteris Dec 21 '18 at 03:56

2 Answers2

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.

KetkiK
  • 40
  • 5
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/

satur9nine
  • 13,927
  • 5
  • 80
  • 123