Webcam: Difference between revisions
m Text replacement - "<code>" to "{{code|" |
m Text replacement - "</code>" to "}}" |
||
| Line 1: | Line 1: | ||
== Linux == | == Linux == | ||
To get a webcam working for Linux, ensure that it's supported. Newer webcams tend to have support though cheaper non-HD webcams from China might not. You should see a {{code|/dev/video0 | To get a webcam working for Linux, ensure that it's supported. Newer webcams tend to have support though cheaper non-HD webcams from China might not. You should see a {{code|/dev/video0}} device when the webcam is plugged into the computer. If not, check {{code|dmesg}} and see if the USB device is being detected. {{code|lsusb}} should also list it. | ||
The default permissions set to {{code|/dev/video0 | The default permissions set to {{code|/dev/video0}} is set by udev. If you need to change the device permissions (say making it world read/writable), you will need to create a udev rule by creating a new file in {{code|/etc/udev/rules.d/}} with the following contents: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| Line 9: | Line 9: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The Vendor ID and product ID must match the values from {{code|lsusb | The Vendor ID and product ID must match the values from {{code|lsusb}}. For the example above (a Microsoft LifeCam VX-2000): | ||
# lsusb | # lsusb | ||
Bus 001 Device 005: ID 045e:0761 Microsoft Corp. | Bus 001 Device 005: ID 045e:0761 Microsoft Corp. | ||
| Line 18: | Line 18: | ||
* uvccapture | * uvccapture | ||
You may configure the webcam settings using {{code|v4l-utils | You may configure the webcam settings using {{code|v4l-utils}}. See http://www.techytalk.info/webcam-settings-control-ubuntu-fedora-linux-operating-system-cli/ | ||
=== fswebcam === | === fswebcam === | ||
| Line 36: | Line 36: | ||
=== uvccapture === | === uvccapture === | ||
Another utility to capture webcam images is {{code|uvccapture | Another utility to capture webcam images is {{code|uvccapture}}. | ||
[[Category:Linux]] | [[Category:Linux]] | ||
{{Navbox Linux}} | {{Navbox Linux}} | ||
Revision as of 19:15, 24 February 2017
Linux
To get a webcam working for Linux, ensure that it's supported. Newer webcams tend to have support though cheaper non-HD webcams from China might not. You should see a /dev/video0 device when the webcam is plugged into the computer. If not, check dmesg and see if the USB device is being detected. lsusb should also list it.
The default permissions set to /dev/video0 is set by udev. If you need to change the device permissions (say making it world read/writable), you will need to create a udev rule by creating a new file in /etc/udev/rules.d/ with the following contents:
SUBSYSTEM=="video4linux", BUS=="usb", SYSFS{idVendor}=="045e", SYSFS{idProduct}=="0761", NAME="video0", MODE="0666"
The Vendor ID and product ID must match the values from lsusb. For the example above (a Microsoft LifeCam VX-2000):
# lsusb Bus 001 Device 005: ID 045e:0761 Microsoft Corp.
To capture images, use any one of the following utilities:
- fswebcam
- uvccapture
You may configure the webcam settings using v4l-utils. See http://www.techytalk.info/webcam-settings-control-ubuntu-fedora-linux-operating-system-cli/
fswebcam
fswebcam -r 640x480 --jpeg 85 -D 1 web-cam-shot.jpg
Dumping fswebcam images via HTTP
You can make a quick an dirty wrapper around the command above so that it can be viewed via the web.
<?php
system("fswebcam -r 640x480 --jpeg 85 -D 1 /tmp/out.jpg > /dev/null");
header("Content-Type: image/jpeg");
echo file_get_contents("/tmp/out.jpg");
uvccapture
Another utility to capture webcam images is uvccapture.