Implementing an UVC driver using the Android NDK and a raw usb connection for cameras that are not supported by the kernel

Nils picture Nils · May 6, 2012 · Viewed 22.9k times · Source

I'm looking for a way to get UVC compartible usb cameras working on other android devices that don't have a kernel driver for those UVC cameras by default.

I don't want to root those devices nor change their image/kernel, because usual customers should be able to use the camera later on with every tablet and without special requirements (except an app).

Do you think it might be possible to establish a raw connection to an unknown device using Android's USB class in Android 3.1 and higher (http://developer.android.com/guide/topics/usb/host.html) or can I only use it with devices that are supported and recognized by the kernel already?

If it would be possible, I would be interested in integrating the UVC driver using Java/NDK to get the video stream out of it. At least that's my rough idea.

Do you think that's possible?

Answer

mk.. picture mk.. · May 7, 2012

It is definitely possible if you are compromising on that rooted part.. I did the same project and was finally successful. Inside uvc code, you shall be opening /dev/video1 or video0 node for which by default on most of the devices there are no user permissions.

To state it simply,

It depends on 2 things :

1) When you connect the USB Camera, if the camera node is getting created or not. It should be inside /dev directory with major number 81(signifies V4l2 device)

2) For that device node you are having user permissions or not.

These are the two hurdles you will be facing.

Solution to first is not there in our hands coz it depends from vendor to vendor. Ex, Acer tab it gets created but in Samsung Galaxy it doesnt.. The reason is missing support of V4L2 or UVC modules inside the kernel.

Solution to the second one is if you are a root user you can change the permissions of the node.

It is quite a big project and should take some time if you are starting from scratch.. All the best