Webcam: Difference between revisions

From Leo's Notes
This page was last edited on 8 October 2020, at 16:06.
m Text replacement - "Category:Linux" to "Category:Linux{{Navbox Linux}}"
 
(2 intermediate revisions by the same user not shown)
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}} 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.
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.


Line 16: Line 16:




=== Capturing Utilities/Daemons ===
Capturing Utilities/Daemons
 
To capture images, use any one of the following utilities:
To capture images, use any one of the following utilities:
* [[motion]]
 
* [[fswebcam]]
*[[motion]]
* uvccapture
*[[fswebcam]]
*uvccapture


My Raspberry Pis use [[motion]] to automatically capture snapshots periodically to a NFS share.
My Raspberry Pis use [[motion]] to automatically capture snapshots periodically to a NFS share.


=== Configuration ===
===Configuration===
You may configure the webcam settings using {{code|v4l-utils}}.
You may configure the webcam settings using {{code|v4l-utils}}.


See Also:
See Also:
* http://www.techytalk.info/webcam-settings-control-ubuntu-fedora-linux-operating-system-cli/


*http://www.techytalk.info/webcam-settings-control-ubuntu-fedora-linux-operating-system-cli/
=== Tasks ===


[[Category:Linux]]{{Navbox Linux}}{{Navbox Linux}}
==== Disable Auto Focus ====
<code>v4l2-ctl</code> shows all the settings that are currently set:
{{Highlight
| code = # v4l2-ctl -l
                    brightness 0x00980900 (int)    : min=30 max=255 step=1 default=133 value=133
                      contrast 0x00980901 (int)    : min=0 max=10 step=1 default=5 value=5
                    saturation 0x00980902 (int)    : min=0 max=200 step=1 default=103 value=103
white_balance_temperature_auto 0x0098090c (bool)  : default=1 value=1
          power_line_frequency 0x00980918 (menu)  : min=0 max=2 default=2 value=2
      white_balance_temperature 0x0098091a (int)    : min=2500 max=10000 step=1 default=4500 value=4500 flags=inactive
                      sharpness 0x0098091b (int)    : min=0 max=50 step=1 default=25 value=25
        backlight_compensation 0x0098091c (int)    : min=0 max=10 step=1 default=0 value=0
                  exposure_auto 0x009a0901 (menu)  : min=0 max=3 default=3 value=3
              exposure_absolute 0x009a0902 (int)    : min=1 max=10000 step=1 default=156 value=156 flags=inactive
                  pan_absolute 0x009a0908 (int)    : min=-529200 max=529200 step=3600 default=0 value=0
                  tilt_absolute 0x009a0909 (int)    : min=-432000 max=432000 step=3600 default=0 value=0
                focus_absolute 0x009a090a (int)    : min=0 max=15 step=1 default=2 value=5 flags=inactive
                    focus_auto 0x009a090c (bool)  : default=1 value=1
                  zoom_absolute 0x009a090d (int)    : min=0 max=317 step=1 default=0 value=0
| lang = terminal
}}
To disable auto focus, set the <code>focus_auto</code> setting to 0.
{{Highlight
| code = # v4l2-ctl -l{{!}}grep focus_auto
                focus_absolute 0x009a090a (int)    : min=0 max=15 step=1 default=2 value=5 flags=inactive
                    focus_auto 0x009a090c (bool)  : default=1 value=1
# v4l2-ctl -c focus_auto=0
| lang = terminal
}}{{Navbox Linux}}
[[Category:Linux]]

Latest revision as of 16:06, 8 October 2020

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.


Capturing Utilities/Daemons

To capture images, use any one of the following utilities:

My Raspberry Pis use motion to automatically capture snapshots periodically to a NFS share.

Configuration

You may configure the webcam settings using v4l-utils.

See Also:

Tasks

Disable Auto Focus

v4l2-ctl shows all the settings that are currently set:

# v4l2-ctl -l
                     brightness 0x00980900 (int)    : min=30 max=255 step=1 default=133 value=133
                       contrast 0x00980901 (int)    : min=0 max=10 step=1 default=5 value=5
                     saturation 0x00980902 (int)    : min=0 max=200 step=1 default=103 value=103
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature 0x0098091a (int)    : min=2500 max=10000 step=1 default=4500 value=4500 flags=inactive
                      sharpness 0x0098091b (int)    : min=0 max=50 step=1 default=25 value=25
         backlight_compensation 0x0098091c (int)    : min=0 max=10 step=1 default=0 value=0
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute 0x009a0902 (int)    : min=1 max=10000 step=1 default=156 value=156 flags=inactive
                   pan_absolute 0x009a0908 (int)    : min=-529200 max=529200 step=3600 default=0 value=0
                  tilt_absolute 0x009a0909 (int)    : min=-432000 max=432000 step=3600 default=0 value=0
                 focus_absolute 0x009a090a (int)    : min=0 max=15 step=1 default=2 value=5 flags=inactive
                     focus_auto 0x009a090c (bool)   : default=1 value=1
                  zoom_absolute 0x009a090d (int)    : min=0 max=317 step=1 default=0 value=0

To disable auto focus, set the focus_auto setting to 0.

# v4l2-ctl -l|grep focus_auto
                 focus_absolute 0x009a090a (int)    : min=0 max=15 step=1 default=2 value=5 flags=inactive
                     focus_auto 0x009a090c (bool)   : default=1 value=1
# v4l2-ctl -c focus_auto=0