11

There are lots of guides which tell you how to configure the raspberry Pi Zero as a mass_storage device or Ethernet device, most of these mention the ability to make the Pi act as a webcam but none have explained how to do it.

I've tried following the guide in the documentation in conjunction with the UVC (webcam) documentation to try and figure out how to configure it but so far i can't even get my computer to recognise that there is something plugged in. The only thing I can find on the topic is this thread which makes me think that the is kinda obscure.

How do you set up the camera? Is there a guide? am I fighting a losing battle?

user3797758
  • 291
  • 1
  • 4
  • 16

7 Answers7

5

I have this enumerating and streaming synthetic uncompressed data to FaceTime via my Raspberry Pi Zero W. The ConfigFS example in the kernel gadget documentation works for the most part. It has some typos when it comes to proper ../.. path navigation, the streaming_maxpacket field which no longer exists in ConfigFS, and you'll need to set bDeviceClass=239, bDeviceSubClass=0x02, bDeviceProtocol=0x01. However, for starters it's actually simpler to just run the legacy modprobe g_webcam. I'm assuming you have the required dtoverlay=dwc2 and have tested other gadget modules like g_serial. It sounds like you might already be using g_ether or the ConfigFS equivalent for your workaround networking solution.

When you enable the g_webcam module, it won't enumerate on a typical Mac/Windows/Linux PC until the userspace uvc-gadget program is running. Setting this up has its pitfalls as the required patches were never fully reviewed by Laurent Pinchart and introduce bugs of their own. You can find my patched repo with fixes here. I have run that with ./uvc-gadget -d -u /dev/video0 on both Raspbian 8 Jessie and Raspbian 9 Stretch.

I'm basically describing the same steps as you saw joe60 did on the Raspberry Pi forums, but as it's a very error-prone procedure having another reference point shouldn't hurt.

Note that even once you have the base case working there's a large cross-product of cases for the format (-f), memory type (-o), bulk vs isochronous (-b) and image data source (-d vs -i vs -v), much of which may have limited support in the uvc-gadget application.

jdonald
  • 2,972
  • 14
  • 39
5

After searching a lot I finally have this working now

to get it working I used the following script for the configfs setup https://gist.github.com/kbingham/c39c4cc7c20882a104c08df5206e2f9f

and this version of the uvc-gadget tool https://github.com/wlhe/uvc-gadget

Raatje
  • 174
  • 1
  • 1
1

Use showmewebcam

Janghou
  • 1,446
  • 1
  • 16
  • 20
1

There is a g_webcam gadget mode driver. I'd imagine if you played with the source you could redirect a uvc stream to the webcam, although it would likely be slow, it would fulfil your remit.

source: https://github.com/torvalds/linux/blob/master/Documentation/usb/gadget-testing.txt#L656

0

If the computer won't recognize the camera the cable may be upside down where it plugs in, there are only contacts on one side. Buying a USB or IP camera is another option, I have some D-links that send over wifi. Lower resolution but meant to be remote cameras with features like motion detection and a built-in web server.

Alan Corey
  • 201
  • 1
  • 6
0

To be able to stream and take snapshots you can use this streamer library that basically streams JPEG. It is customisable and straightforward to use. And you don't have to know how it works. It also supports the official RPi Camera apart from USB cameras with a linux driver.

Here is the link to mjpg-streamer.

-1

This guide shows you how to install and run a docker container and live video stream to youtube from a pi zero.

paj
  • 331
  • 1
  • 6