Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android as an UVC Camera

I'm stuck at home with a rather bad webcam. I was considering upgrading, but then it struck me: phones these days have really good cameras embedded in them. So why not use it as a webcam?

However, as I was researching this further I was really disappointed with the available apps for this. As far as I was able to find, we have Android apps that work roughly as follows:

  • Present phone camera as a network attached camera. Then you can use local software to use that feed as a webcam. See e.g., IP Webcam. This may be sufficient, but it's a complicated setup, and network latency makes this far from ideal.

  • The Android app sends the camera feed to an custom host application that in turn creates a virtual web camera. See e.g., DroidCam. This mostly solves the latency problem, but it is still rather complicated, and requiring us to install a specific third party application is troublesome in regard to user privacy. Especially since the applications are closed source.

So, I took the engineering approach and tried to see if it was even possible to improve the situation. As far as I was able to find, Android supports being used as a custom USB accessory. And looking over the USB video class documentation, it strikes me that it should be possible to create an Android app that presents the phone as a generic UVC webcam, such that we do not have to resort to tricks such as the ones above.

Ideally, I would have liked Android to add another USB device option ("Use USB connection as webcam") in addition to debug mode, file-transfer, etc. This seems quite unlikely to happen in the short term however.

So, my question is this: Does an application that does the above already exist? My searching thus far haven't yielded any results, but I might be missing something as googling for this turned out a bit harder than I expected.

Alternatively, am I wrong in my assumption above, such that there is some fundamental issue why an Android application cannot be made to work in that way?

like image 531
Xaldew Avatar asked May 11 '20 13:05

Xaldew


People also ask

What is the UVC function on an Android phone?

The USB video device class (also USB video class or UVC) is a USB device class that describes devices capable of streaming video like webcams, digital camcorders, analog video converters, and still-image cameras.

What is UVC on a camera?

UVC cameras (USB video class) are USB-powered devices that incorporate a standard video streaming functionality – connecting seamlessly with the host machines. There are standard and class-specific descriptors – data structures used to describe a USB device's capability.

Are all webcams UVC?

This means that every UVC Camera is a USB camera, but not all USB cameras are UVC Cameras, because they might adopt the USB interface without meeting the Video class requirements. Take our current USB3 Camera shield as an example, it's not a standard video class, and requires extra drivers to work.


1 Answers

There does not seem to be any complete app yet as of 2020-10, but the parts are mostly there:

  • https://github.com/tejado/android-usb-gadget has code to switch the Android device into gadget mode (but no UVC yet)
  • https://git.ideasonboard.org/uvc-gadget.git feeds v4l2 into the uvc gadget output

Sources:

  • http://www.davidhunt.ie/raspberry-pi-zero-with-pi-camera-as-usb-webcam/
  • https://www.raspberrypi.org/forums/viewtopic.php?t=148361
  • https://www.reddit.com/r/androiddev/comments/iabc2o/can_i_use_my_android_as_wired_camera_ie_as_a/g1nrijl/
like image 169
cweiske Avatar answered Oct 09 '22 02:10

cweiske