Coder Social home page Coder Social logo

geerlingguy / pi-webcam Goto Github PK

View Code? Open in Web Editor NEW
1.4K 37.0 100.0 419 KB

Automation to configure a Raspberry Pi as a USB OTG webcam

Home Page: https://www.youtube.com/watch?v=8fcbP7lEdzY

License: MIT License

raspberry-pi webcam video uvc-gadget camera hq-camera

pi-webcam's Introduction

Raspberry Pi Webcam

CI

Raspberry Pi Zero W with HQ Camera and wide-angle lens on Tripod

Inspired by David Hunt's blog post showing how to use a Raspberry Pi Zero with a Pi Camera as a USB Webcam, as well as justinschuldt's gist, I wanted to make my Raspberry Pi do the same thing, but automated and with all the scripts wrapped in version control, since the blog post was a little bit vague in some areas.

This Ansible playbook can be run on most Raspberry Pis to set it up as a USB webcam.

What does that mean? Well, after running the playbook:

  • You plug the Pi into your computer
  • You wait until it boots
  • Bingo! Webcam usable in any software (Zoom, Teams, Meet, OBS, QuickTime, etc.)

It works on Mac, Windows, and all the flavors of Linux I've tested so far. It even works on another Raspberry Pi (I've tested it on a Pi 4 and Pi 400).

Video overview of this project

I published a video in November 2020 detailing how to set up your Pi Webcam using this project. Click the thumbnail below to view it:

Raspberry Pi Zero is a REAL USB webcam

Caveats

The playbook is meant to run on a brand new installation of Raspbian that has not had any configuration changes via raspi-config or any other tools, though it should work correctly with an existing installation.

Note: This modifies your boot config, and as such you should not run this playbook on a microSD or other boot volume you're not ready to reformat and re-flash!

Setting up the Hardware

It doesn't matter if you set up the software or hardware first, you just need to do both to have a functional webcam.

There are a number of different components you can purchase instead of these, but here's the list of what I'm using in my 'official' version that is well-tested and that I use frequently on my Mac and Windows laptops:

Once you have everything, it's a matter of putting it all together.

Check out my video on YouTube for a detailed assembly and setup guide: Raspberry Pi Zero is a PRO HQ webcam for less than $100!

Mounting the webcam

The HQ Camera includes a female tripod socket, so any tripod or mounting arm will do. I've used a variety of mounts depending on the purpose, for example:

Setting up the Software

There are two ways you can run this automated setup. You can either run everything on the Raspberry Pi itself (e.g. if you plug in a keyboard, mouse, and monitor), or you can run it from another computer.

Setup on the Raspberry Pi

Pro Tip: If you want to use a Pi Zero for the webcam, and don't want to wait half an hour for it to run all this automation, you can put the flashed microSD card into a newer Pi (like the Pi 4) and do all this work there, then when it's done pull the card and pop it into a Pi Zero.

  1. Flash the latest Raspberry Pi OS to a microSD card.
  2. Once Raspbian is loaded on the card, insert the card in your Pi, and plug in your Pi to boot it up.
  3. Follow the setup wizard, and if you want to easily be able to log into the Pi later, connect to a WiFi network, and also run the raspi-config tool and enable SSH.
  4. The Raspberry Pi should ask to be restarted. Go ahead and restart now, and wait for it to boot back up.
  5. Open the Terminal application (in the launcher or in Menu > Accessories > Terminal).
  6. Install Ansible and Git: sudo apt update && sudo apt install -y python3-dev python3-pip libyaml-dev libffi-dev git && sudo pip3 install --no-binary pyyaml ansible (Warning: this can take a while, especially on slower Pis!).
  7. Clone this repository to your Pi: git clone https://github.com/geerlingguy/pi-webcam.git
  8. Go into the repository directory: cd pi-webcam
  9. Use the local inventory file: cp inventory-local.example inventory
  10. Run the Ansible playbook: ansible-playbook main.yml
  11. You can shutdown the Pi at this point.

Setup from another Computer

  1. Make sure you have Ansible installed on your computer.

  2. Flash the latest Raspberry Pi OS a microSD card. Make sure you added an ssh file to the boot volume so SSH is enabled on first boot.

  3. Once Raspbian is loaded on the card and you have the ssh file in the boot volume, insert the card in your Pi, and plug in your Pi to boot it up.

  4. Make sure you can log into the Pi via SSH. Ideally, add your SSH key to the Pi using ssh-copy-id. If you don't, make sure to add the -k parameter to the ansible-playbook command later so you can enter the SSH password.

  5. Clone or download this repository to your computer.

  6. Use the ssh inventory file: cp inventory-ssh.example inventory

  7. Update the IP address in inventory to match the IP address or hostname of your Raspberry Pi.

  8. Edit the config.yml file to your liking (the defaults should be fine though).

  9. Run the Ansible playbook:

    ansible-playbook main.yml
    
  10. You can shutdown the Pi at this point (log in via SSH then sudo shutdown now).

Plugging in the Camera

You could've done this earlier, but if you haven't yet, plug the camera module into the Raspberry Pi using the appropriate camera connector.

Using the Pi as a webcam

At this point, it should (assuming everything worked) be set up as a USB webcam.

All you need to do is grab a USB cable and plug the Pi into any USB port on your computer. But which port do you plug into on the Pi? Well, I have a handy little table here:

Pi Model Which USB Port for device mode Webcam use?
Pi Zero / Pi Zero W 'USB' port (next to 'PWR IN')
Pi A/A+ 'USB' port (you need a non standard Type-A to Type-A USB cable)
Pi 4 USB-C 'Power' port

Once it's plugged in, you need to wait 30 seconds or so before the Pi will be booted and fully ready, then you can open any video recording/conferencing software, go to the camera selection, and BOOM! Select the 'Pi Webcam'.

What about the other Pi models? Unfortunately, other Pi models do not have full support for Device mode, so they cannot be used as a webcam.

Powering down the Pi

If you want, and you still have WiFi enabled, or the Pi is otherwise connected to your network, you can log into it via SSH and run sudo shutdown now to power it off cleanly.

But I like living on the edge... it's not like the thing is writing a ton of data to the microSD card. When I'm finished using it as a webcam, I just unplug it. Simple as that.

If, for some strange reason, it did end up getting corrupted, I could just re-run this automation to set it up again. No big deal! I haven't had that happen yet, though.

Known issues

Well... most of the known issues have to do with the other projects this project relies on:

  • If you're not using a Mac, you may need to adjust the brightness setting in the uvc-gadget.c file and re-compile it manually. I'm looking into a better way to allow this to be configured.
  • The upstream repository providing the uvc-gadget application currently defaults to 720p resolution, which is great for most use cases. You can stream at 1080p, though the Pi Zero and older Pis may drop frames at that resolution. Follow this issue for progress making resolution more easily configurable.
  • The Pi 4 model B currently locks up when you try to use USB Device mode and enable the webcam for some reason. You can run the 2020-02-07 Raspbian release to work around this bug for now. Follow this issue for progress resolving this bug.
  • This stuff is a little bit of a complicated ball of string, so future Raspberry Pi OS and kernel updates could cause issues. I would not run this on a Raspberry Pi that is controlling a breathing machine or something like that.

Yadda, yadda, standard "if something breaks don't blame me" disclaimer. The worst thing I've done to my Pi in testing this so far is accidentally breaking off the locking connector for the camera cable. Oops.

License

MIT.

Author

I'm Jeff Geerling, and I approve of this repository.

pi-webcam's People

Contributors

geerlingguy avatar oskar456 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi-webcam's Issues

Stuck at step when running Ansible

I'm using a clean install of Raspian Lite Bullseye on the Pi Zero W v1.1
I'm able to get through most steps, however running any ansible commands, even just --version, gives me the response "Illegal Instruction".
I've tried apt update and a second clean install, but I've had no luck.
Not sure where to proceed from there.

The only other error that pops up is as PyYAML installs; versions 6, 5.4.1, and 5.4 all error out with exit status 4.
I wasn't sure if this has any relation, as 5.3.1 then installs without issue.

Any help/advice is appreciated, thank you!

Could not find a version that satisfies the requirement ansible-core

Hi there,

I am following the setup on the pi steps on fresh raspbian lite installation and I get the following error when trying to install ansible for python (see below).

I have to reinstalling my piwebcam because osx monterry fails to detect the cam.

Have you run into this issue?

pi@piwebcam:~ $ python3 -m pip install ansible
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting ansible
  Downloading https://www.piwheels.org/simple/ansible/ansible-5.0.0-py3-none-any.whl (63.3MB)
    100% |████████████████████████████████| 63.3MB 7.7kB/s


Collecting ansible-core<2.13,>=2.12.0 (from ansible)
  Could not find a version that satisfies the requirement ansible-core<2.13,>=2.12.0 (from ansible) (from versions: 0.0.1a1, 2.11.0b1, 2.11.0b2, 2.11.0b3, 2.11.0b4, 2.11.0rc1, 2.11.0rc2, 2.11
.0, 2.11.1rc1, 2.11.1, 2.11.2rc1, 2.11.2, 2.11.3rc1, 2.11.3, 2.11.4rc1, 2.11.4, 2.11.5rc1, 2.11.5, 2.11.6rc1, 2.11.6, 2.11.7rc1)
No matching distribution found for ansible-core<2.13,>=2.12.0 (from ansible)

Test on rPi B (256 MB)

I tried with the http://downloads.raspberrypi.org/raspbian/images/raspbian-2020-02-07/ on a rPi4 and it worked. Then I switched the SD to my rPi B (256 MB) model and it doesn't work. The systemd service is running and uvc-gadget is constantly using 100 % cpu. If it works with a rPi A (without +) it should work with a B, shouldn't it?

Otherwise great timing for doing the youtube video. I was searching for a webcam last weekend and was very disappointed that I can get a rPi cam HQ for ~50 € but no regular 4k webcam for that price.

Maybe has something to do with geerlingguy/uvc-gadget#1

Pi zero 1.3 cannot get device description

Installation done. After plugging the cam into a notebooks usb interface you can hear the usb connection sound but windows says that its not possible to get the device description.

image

image

Pi recognized as webcam but VLC (v4l2) doesnt recognize as video device

Hello,
I followed the steps as per the Readme file. And everything seems fine. After plgging it on a Linux Mint I have it as a usb device:

T: Bus=01 Lev=01 Prnt=01 Port=10 Cnt=03 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=568c Rev=60.53 S: Manufacturer=CNFGH16N51640017D222 S: Product=Integrated_Webcam_HD S: SerialNumber=200901010001 C: #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo I: If#=0x1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
When I try google hangouts, it doesnt give me an option to choose the device. When I try VLC it doesnt work and this is the log file:

v4l2 debug: opening device '/dev/video1' v4l2 debug: device Integrated_Webcam_HD: Integrate using driver uvcvideo (version 5.4.86) on usb-0000:00:14.0-11 v4l2 debug: with capabilities 0x04A00000 (overall 0x84A00001) v4l2 error: not a video capture device main debug: no access modules matched main debug: dead input

What can be causing this?

Thanks

Consider testing with the Arducam 12MP IMX477 with autofocus

Not quite sure how I would be able to get the pipeline to work just glancing at the example Python code (https://github.com/ArduCAM/RaspberryPi/blob/master/Motorized_Focus_Camera/Autofocus.py), but Riding Nerdy on YouTube mentioned that camera has a built-in AF motor that is software-controlled.

Would need to use something like OpenCV + a contrast-detect algorithm to lock focus. It's not going to compete with a mirrorless camera, but it would be interesting to see if it could be used as a webcam with autofocus—total price of the unit is a slight bit more than the HQ camera + 6mm lens, but not by much.

Not working for me on Mac

Hi @geerlingguy, thank you for providing this repo!

I followed the instructions to set things up. I'm on a Pi Zero W connected to a MacBook Pro. It powers on and I can SSH on to it (I don't have a micro hdmi to connect it to a monitor.) When I check About this Mac > System Report, the camera is not showing up.

On the Pi, when I run sudo systemctl status piwebcam I get:

🔴 piwebcam.service - Pi webcam
   Loaded: loaded (/etc/systemd/system/piwebcam.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2021-01-08 21:55:09 GMT; 12min ago
  Process: 302 ExecStart=/home/pi/uvc-gadget/piwebcam (code=exited, status=1/FAILURE)
 Main PID: 302 (code=exited, status=1/FAILURE)

Jan 08 21:55:08 raspberrypi sudo[433]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jan 08 21:55:09 raspberrypi piwebcam[302]: V4L2 device is mmal service 16.1 on bus platform:bcm2835-v4l2
Jan 08 21:55:09 raspberrypi piwebcam[302]: V4L2: Getting current format: JPEG 1024x768
Jan 08 21:55:09 raspberrypi piwebcam[302]: V4L2: Setting format to: MJPG 1280x720
Jan 08 21:55:09 raspberrypi piwebcam[302]: V4L2: Getting current format: MJPG 1280x720
Jan 08 21:55:09 raspberrypi piwebcam[302]: v4l2 open succeeded, file descriptor = 3
Jan 08 21:55:09 raspberrypi piwebcam[302]: UVC: device open failed: No such file or directory (2).
Jan 08 21:55:09 raspberrypi sudo[433]: pam_unix(sudo:session): session closed for user root
Jan 08 21:55:09 raspberrypi systemd[1]: piwebcam.service: Main process exited, code=exited, status=1/FAILURE
Jan 08 21:55:09 raspberrypi systemd[1]: piwebcam.service: Failed with result 'exit-code'.

It looks like UVC: device open failed: No such file or directory (2). might be a clue, but I'm not sure how to debug that further.

Any tips on what else I can look at to troubleshoot?

Thank you!

Use ini_file module instead of lineinfile for config.txt changes

Since that file is ini syntax, and since the lineinfile stuff results in some parameters being in the wrong section (although the regex was ... 'fun' to get right), it would be best to use the ini_file module instead.

I just noticed on a new install the dtoverlay=dwc2 parameter was being added under [pi4] instead of in [all].

Adding a mic to the webcam

Hi,

I was wondering if it is possible to adapt the scripts you have to support an optional microphone, which would just work if you have it plugged in or have the same behavior as now if the mic's not connected. This will help make an all-in-one package for a decent performing pi webcam. I'm thinking of this breakout board.

Let me know, since I was thinking of making one of these.

Thanks!

TASK [Ensure piwebcam service is enabled at boot.] fails in ansible playbook

I've been using the raspberry pi zw as a webcam with this setup for for the past year without any problems. Then suddenly my piwebcam stops working. I did a complete reinstall of the OS and software through ssh but the playbook fails on the final step, ensuring the piwebcam service is enabled at boot. The config.yml file shows 'true' for enabling at boot and I left the Inventory as is on 127.0.0.1 and tried it on the pi's IP. Any advice?

`TASK [Ensure piwebcam service is enabled at boot.] ************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": "/usr/bin/systemctl", "msg": "Failed to list units: Connection timed out", "rc": 1, "stderr": "Failed to list units: Connection timed out\n", "stderr_lines": ["Failed to list units: Connection timed out"], "stdout": "", "stdout_lines": []}

PLAY RECAP ****************************************************************************************************************
127.0.0.1 : ok=10 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
`

pi zero w freezes when opening camera app on pc

I followed all instructions and I am able to see the uvc-camera in the device manager.
But when i try to view the video feed, using any camera app (obs, windows camera app etc.), the app instantly freezes and so does the pi.
I also tried multiple usb cables.
Any idea what could cause this?

Webcam not working on Windows 10 with Teams or Skype

I have a very strange Problem with Teams and Skype on Windows 10:
The Camera is detected after startup and usable via the Windows Camera App.
I can setup the Camera on both Teams and Skype correctly.
As soon a I start a call (both Teams and Skype) everything looks normal to me, I can see myself through the Pi-Webcam as well as the counter-party.
However they can not see me, they only see my profile Picture, as if I would not be using a Webcam.
I tried everything that came to my mind - even testing it on different PCs, but no luck.
I don't even know how I could debug this problem.
Maybe someone faced the same problem already or has suggestions where to dig deeper into the configuration.
Cheers,
Thiemo.

Not working on Raspberry Pi 4B or A/A+

I wanted to be able to have this project work great on the Pi 4, even though it makes the footprint a little larger... but it seems to not work so well. When you start the service, the system just halts, no input, no log output, nothing. And when you have it enabled on boot, the system gets to the step polkit.service (according to the GUI boot screen) and then does the same (just... stops).

The green LED goes on and remains steady, lit until you physically power off the Pi. Nothing responds to input.

Strange thing, and it looks like I'm not the only one who's experienced this—see https://gist.github.com/justinschuldt/36469e2a89d95ef158a8c4df091e9cb4#gistcomment-3467068

Current workaround

You can download the 2020-02-07 Raspbian release and run it instead of the latest kernel, and it should work on that version. Don't run sudo apt-get update or rpi-update or you'll be upgraded to the newer kernel that doesn't currently work with this project.

Error when following setup on pi

Summary

I've tried going through the set up you've laid out, but I keep getting this error at the 6th step. I thought well maybe it just needs some thing run a second time.

I've tried this right on a Pi Zero w/wifi and a Pi4.

I used the Raspberry Pi OS (32-bit) Released on 2021-01-11

Is this error expected?
If not, how can I help get this solved?

Command I run

sudo apt update && sudo apt install -y python3-dev python3-pip libyaml-dev libffi-dev git && sudo pip3 install --no-binary pyyaml ansible

Output including error

pi@raspberrypi:~ $ sudo apt update && sudo apt install -y python3-dev python3-pip libyaml-dev libffi-dev git && sudo pip3 install --no-binary pyyaml ansible
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
31 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version (1:2.20.1-2+deb10u3).
libffi-dev is already the newest version (3.2.1-9).
libyaml-dev is already the newest version (0.2.1-1).
python3-dev is already the newest version (3.7.3-1).
python3-pip is already the newest version (18.1-5+rpt1).
0 upgraded, 0 newly installed, 0 to remove and 31 not upgraded.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting ansible
  Using cached https://www.piwheels.org/simple/ansible/ansible-2.10.5-py3-none-any.whl
Collecting ansible-base<2.11,>=2.10.4 (from ansible)
  Using cached https://www.piwheels.org/simple/ansible-base/ansible_base-2.10.5-py3-none-any.whl
Requirement already satisfied: jinja2 in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.4->ansible) (2.10)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.4->ansible) (2.6.1)
Collecting PyYAML (from ansible-base<2.11,>=2.10.4->ansible)
  Using cached https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-2zqo0cr_ --no-warn-script-location --no-binary pyyaml --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel Cython:
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools
    Using cached https://files.pythonhosted.org/packages/f7/30/f963996d7efea5a336455a3c727711469280c318e2711e295007dea04d7e/setuptools-52.0.0-py3-none-any.whl
  Collecting wheel
    Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
  Collecting Cython
    Downloading https://www.piwheels.org/simple/cython/Cython-0.29.21-cp37-cp37m-linux_armv7l.whl (4.7MB)
  THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
      Cython from https://www.piwheels.org/simple/cython/Cython-0.29.21-cp37-cp37m-linux_armv7l.whl#sha256=888fa3a6110c293cea2a45077496dcca6c35df67b5fdb5317180549fc4f73480:
          Expected sha256 888fa3a6110c293cea2a45077496dcca6c35df67b5fdb5317180549fc4f73480
               Got        d0e1ab871ec84e249aa786d272a0220c91643c86853eebf702bec180d145a949


  ----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-2zqo0cr_ --no-warn-script-location --no-binary pyyaml --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel Cython" failed with error code 1 in None

Rewrite instructions for running this project on the Pi itself

It might be simpler/easier for people to just SSH into the Pi (or be on the Terminal on the Pi), and run a bash script in the repo, or run a series of commands to install Ansible, run the playbook, etc...

Would have to remove the automatic reboot though, if it's running on localhost :)

Basically, I want this to be as approachable as possible—most of the other people who write up guides throw around terms like UVC Gadget or 'modify your boot config and add some dtoverlays'. Most people who would benefit from a cheap but great webcam like this one should not need to spend 6 hours learning about every aspect of the Pi's hardware and Linux kernel features!

Not working on M1 pro

Sadly couldn't reopen the stale issue.

This is what I wrote:
Same here - not working on an M1 pro. It's showing up in the system report as USB device (regardless whether connected with USB micro -> usb c or with a usb a connector in between), yet not as camera. Any other clues? In the linked thread https://developer.apple.com/forums/thread/693784 they mention that the software needs to be changed, so this is beyond my skills, sadly. Appreciate any help!

Mac OS Monterey does not recognise the cam

Great Project!
After updating to Mac OS Monterey, the Pi USB cam does not show up as a selectable camera anymore.
When doing a system_profiler SPUSBDataType it shows up as connected.
I have tried in on an intel mac and apple silicon - both on Monterey.

When attaching to a Mac on Big Sur, the same Pi/Camera shows up and works perfectly.
thx

ansible-playbook main problem

**I get this error when running the command

ansible-playbook main**

TASK [Clone uvc-gadget to the Pi.] *********************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": ["/usr/bin/git", "fetch", "--tags", "origin"],
"msg": "Failed to download remote objects and refs: fatal: unterminated line in .git/packed-refs: ...\n"}

I am running
ansible [core 2.12.3]
config file = /home/pi/pi-webcam/ansible.cfg
configured module search path = ['/home/pi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
ansible collection location = /home/pi/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110]
jinja version = 2.11.3
libyaml = True

I dont know how to proceed.

uvc-gadget causes 100% cpu when camera is idle [rpi-zero-w]

(Just made this rpi zero HQ camera following your Youtube + this github together with my 5yo daughter. She is very happy, so thanks for that @geerlingguy for bundling this into an ansible playbook.)

Question: when I'm not using the camera (usb cable is connected to my computer, but not actively using the camera) I see 100% cpu usage mainly because of uvc-gadget. When I start using the camera the cpu usage drops to around 20%.

Any idea why this is so? I'm using a rpi Zero W if it matters.

  CPU[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]   Tasks: 33, 7 thr; 1 running
  Mem[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||                                        39.5M/368M]   Load average: 1.15 1.16 1.02 
  Swp[                                                                                                    0K/100.0M]   Uptime: 01:34:43

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
  386 root       20   0  3660  2824  2756 R 93.7  0.7 32:23.42 /home/pi/uvc-gadget/uvc-gadget -f1 -s1 -r0 -u /dev/video1 -v /dev/video0
  580 pi         20   0  8344  3072  2264 S  2.5  0.8  0:48.88 htop
  772 pi         20   0  6332  3352  1900 R  2.5  0.9  0:01.83 htop

ModuleNotFoundError: No module named 'yaml' - Resolved

Ran into the error:

ModuleNotFoundError: No module named 'yaml'

I'm using a Raspberry Pi3 with 2021-12-02-Raspbian-buster for setup. I did not do a sudo update before doing the install steps below.
I did follow the install steps and encountered the error when I tried to execute the playbook
ansible-playbook main.yml

I hunted a bit on the net and found a resolution.

python3 -m pip install pyyaml

https://stackoverflow.com/questions/50868322/importerror-no-module-named-yaml

Screen Output

Hey @geerlingguy! Thanks putting all this together.

Any thoughts on adding an option for enabling video output on HDMI or other kind of output (TFT screen)

By reading thought this gist having the video0 means the camera is enabled and that would be the input for the video1 output which is the one used over USB.

Maybe we can take video0 also as input for other output like external display.

If any help is needed just ping me, I can test it on a external TFT if you don't have one.

Regards.

Fatal Error Running Ansible Playbook

Followed the guide, went to run the main.yml cmd and got the following error,

fatal: [127.0.0.1]: FAILED! => {"reason": "couldn't resolve module/action 'make'. This often indica tes a misspelling, missing collection, or incorrect module path.\n\nThe error appears to be in '/ho me/pi/pi-webcam/tasks/uvc-gadget.yml': line 9, column 3, but may\nbe elsewhere in the file dependin g on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Build uvc-gadget.\ n ^ here\n"}

Don't see what the issue could be so im a little stuck.

Pi0w

Webcam use on new Raspberry Pi Zero 2 W?

This issue is open to investigate whether this project works correctly on the Raspberry Pi Zero 2 W. I should've tested this earlier, but I completely forgot to do it! Has anyone else tested on one?

About low FPS when checking linux and shows error with libuvc package

When I plug it in Linux system and test below, it only has 2 FPS info.
image
Also, the image are nearly black and message like below:
process[camera/mycam-1]: started with pid [28584]
unsupported descriptor subtype VS_COLORFORMAT
attempt to claim already-claimed interface 1
Not a JPEG file: starts with 0xd5 0x19
Couldn't convert frame to RGB: Unknown error (-99)

image

ansible-playbook: command not found

got as far as
cp inventory-local.example inventory, OK so far
ansible-playbook main.yml
then,
bash: ansible-playbook: command not found
I`m pretty new to this so go easy on me !!
Any advise would be gratefully recieved

Not working on Raspberry Pi Zero WH (V1.1)

I was trying to follow the steps using vnc but I didn't have success. I tried also some configuration that I found in some issues but with my Omen 15 computes didn't work. It says that the device was not correctly instaled.

Some help please I really need in a month!

Task [Clone uvc-gadget to the pi.] FAILED! permission denied

everyhing goes well until the uv-gadget needs to be cloned to the pi and i get this error.

fatal: [127.0.0.1] FAILED! => {"changed": false, "cmd" "/usr/bin/git clone --origin origin http://github.com/geerlingguy/uvc-gadget.git /home/pi/uvc-gadget", msg" : fatal: could not create leading directories of '/home/pi/unc-gadget' : Permission denied", "rc": 128, "stderr": "fatal: could not create leading directories of '/home/pi/uvc-gadget' : Pwemission dienied\n" "stdeer_lines": ["fatal: could not create leading directories of '/home/pi/unc-gadget': Permission dienied"], "stdout": "", "stdout_lines" : []}

files where corrupted

Allow configuration of resolution, framerate, white balance, brightness

At a minimum, I'd like to be able to set:

  • Resolution: Maybe default to 1280x720 (720p) so the Pi Zero doesn't drop frames as much?
  • Framerate: Default to 30 fps
  • Brightness: Default to 55
  • White Balance: Default to 'auto'

In an ideal world, the config.yml could have a section at the top like:

##
# Common settings.
##

# The human-readable name of the device that appears when selecting the camera.
device_name: "Pi USB Camera"

# The video resolution. Older Pis may drop frames at higher resolutions.
resolution: '1920x1080'

# The video framerate. Older Pis may drop frames at higher framerates.
framerate: '30'

# The video brightness. This default seems to work well with most Macs and PCs.
brightness: '55'

camera rotation

First, thanks for simplifying the process and awesome tutorial on youtube. It works in Pi0W without any problems. I use Pi0 case which position the case in the up-right to get the picture in the right orientation. Physical camera rotation is not possible considering how the camera module is fitted in the case. Would u please share how to rotate the camera orientation from configuration so i can put the camera sideways (USB cable from below).

Thank you

Intermittent failures

Hi there,

Not sure if I have everything setup properly but originally I used uvc-gadget repo on my Pi Zero, and now am using this repo. Every now and then, few hours, maybe longer, sometimes less, the camera just stops working.

I've tried using separate power, just incase that was causing it but didn't work, I've tried different USB ports, currently have it connected to my monitor which acts as a USB hub, also connected direct to my PC but the same thing happens. The camera just stops working and requires a power cycle to get working again (at least that's what works for me).

Any ideas?

v4l2 camera capabilities

Here's the ask, as requested. ;) When you've got this connected to a Linux host, can you paste the output from v4l2-ctl --all -L --list-formats-ext -d /dev/(whatever)? I'm curious to see what all capabilities they've implemented... Thanks!

Configure Camera Settings

It would be nice to implement a possibility to configure the Camera. For example, rotate the image by 90 degree or to increase the gain.

Compute module

Anyone tested a compute module as isn't that the only one to have 4x CSI lane and gadget mode?

Webcam Picture is really dark on Linux and Windows with raspberry-pi zero

Hi,

i used the instructions and the hardware you meantioned.
I didnt upgrade the raspbian os and install with ansible the whole stuff.
But the picture was really dark.

i playaround with the uva-gadget.c settings. but that seems not really help.
#!define PU_BRIGHTNESS_DEFAULT_VAL 55

Doing the stuff (brightness and contras) in the piwebcam script helps and seems more usable.
/usr/bin/v4l2-ctl -c brightness=65

And you can do that in run-time.

Does this work on for Pi Camera v1 and v2?

Hi there!
Thanks for making this awesome resource. I just wanted to know if this can be used with other Raspberry Pi camera modules (v1, v2), and could you also elucidate if any changes need to be made to the project to get it to work with them?

Usb device descriptor read error 110 on pi zero w

Hi there! I have followed the description for this project but I am experiencing a strange problem. I am using a Pi zero w and it is connected to my laptop which is running ubuntu. This is the output of sudo dmesg -w (from the host)

[20734.381420] usb 1-2: new full-speed USB device number 12 using xhci_hcd
[20749.909000] usb 1-2: device descriptor read/64, error -110
[20765.524782] usb 1-2: device descriptor read/64, error -110
[20765.764747] usb 1-2: new full-speed USB device number 13 using xhci_hcd
[20781.388423] usb 1-2: device descriptor read/64, error -110
[20797.008059] usb 1-2: device descriptor read/64, error -110
[20797.120080] usb usb1-port2: attempt power cycle
[20797.780028] usb 1-2: new full-speed USB device number 14 using xhci_hcd
[20803.020035] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[20808.399879] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[20808.611859] usb 1-2: device not accepting address 14, error -62
[20808.739876] usb 1-2: new full-speed USB device number 15 using xhci_hcd
[20813.771821] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[20819.151710] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[20819.359637] usb 1-2: device not accepting address 15, error -62
[20819.359803] usb usb1-port2: unable to enumerate USB device

I don't know how to debug this. Any suggestions?

uvc-gadget pegs CPU @ 100% when 'idle'?

Once booted up, and after USB-host releases a video streaming session, uvc-gadget is soaking up nearly 100% of the CPU core.

When USB-host is connected & receiving video, uvc-gadget CPU utilisation is only 10-20% (RPi-Zero).

Is anyone else seeing this?

For a low-power freak, this is somewhat of a splinter in the mind ;)

not working on M1 mac

Great project that i used before many times. However, for some reason it's only recognised for a few seconds on my new m1 mac. It will appear as a video source in zoom for example for a few seconds catch a frame but then disappear. If i use it as a source for openv (python api) then one frame is captured but all subsequent frames fail, with this error message:
"
OpenCV: out device of bound (0-0): 1
OpenCV: camera failed to properly initialize!
"

I've tried two different cameras and am using a raspberry pi zero w v1. Do you know what could be going wrong?
thanks

Following the steps but does not work after plugin to pc

Hi there,
Thanks for your writing. I want to ask when I finished all those steps and shutdown raspberry pis. When I plug it to pc, it does not show any devices in pc. Do you know what may caused this issue?

I am using pi zero w and mac

Low FPS in Google Meet and issues in Microsoft Teams

Hi @geerlingguy,

Great project. I have made it work on my Mac. It works perfectly with Zoom, FaceTime. I have problems with:

  • Google Meet in the browser (both Chrome and Safari): the frame rate is very low (ca. 1 fps) and latency is also around 1 second.
  • Skype and MS Teams seem to crash instantly when I change it to Pi Webcam.
    Do you also have those issues?

Thanks,
Tomasz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.