Webcam


Enabling Support for Your (Webcam) Hardware in Linux


An easy way to tell if the driver is enabled is to use the dmesg command:

$ dmesg | grep cam
[    2.178246] usb 1-1.5: Product: Laptop_Integrated_Webcam_E4HD
[    5.623225] uvcvideo: Found UVC 1.00 device Laptop_Integrated_Webcam_E4HD (0c45:648b)
[    5.655807] input: Laptop_Integrated_Webcam_E4HD:  as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5:1.0/input/input10

If you don't see it, the particular driver may exist as a loadable module.
If you know what that module is named, try using find *.ko under /lib/modules.
You can get a list of all modules available by typing the following at the command line:

$  ls -R /lib/modules/`uname -r`/kernel 
Where `uname -r`, surrounded by forward tick marks, is your kernel version number.

Once you know which module your camera needs you can find out if it is already loaded by typing the following at the command line:

#  lsmod

Most stock kernels are compiled with kmod, which enabling automatic loading of necessary modules when the appropriate hardware is detected.
if you don't have the particular module you're seeking loaded and you think the module may be available, try loading it manually with modprobe.

As the Logitech Webcam C270 as an example.
  • Detect the USB HW
  • Generally, any USB camera with a USB vendor ID of 0x46d
    
        $ lsusb
        Bus 002 Device 003: ID 0a5c:5801 Broadcom Corp. BCM5880 Secure Applications Processor with fingerprint swipe sensor
        Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
        Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
        Bus 001 Device 004: ID 0c45:648b Microdia Integrated Webcam
        Bus 001 Device 003: ID 413c:8197 Dell Computer Corp. 
        Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
        Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
        Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
        Bus 003 Device 003: ID 046d:0825 Logitech, Inc. Webcam C270
        Bus 003 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
        Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
  • Driver
  • Video4Linux, V4L for short, is a collection of device drivers and an API for supporting realtime video capture on Linux systems. It supports many USB webcams, TV tuners, and related devices, standardizing their output, so programmers can easily add video support to their applications.
    
        $ lsmod | grep v4l
        videobuf2_v4l2         20480  1 uvcvideo
        videobuf2_core         36864  2 uvcvideo,videobuf2_v4l2
        videodev              151552  3 uvcvideo,videobuf2_core,videobuf2_v4l2
    
  • Application
  • A list of GUI-based and commandline apps that support webcam capture in most Linux distros can be found.
    • list your video4linux devices
    • 
          $ ls -ltr /dev/video*
          crw-rw----+ 1 root video 81, 0 Dec  4 08:33 /dev/video0
          crw-rw----+ 1 root video 81, 1 Dec  4 08:49 /dev/video1
      
      If you have several video4linux devices, your webcam may show up as /dev/video1 or whatever. But the time (in this case Dec 4 08:49) will be the time when you plugged it in.
    • test the webcam
      • vlc
      • start it and choose: Media -> Open Capture Device -> Video device name = /dev/video1 -> Play
      • mplayer
      • you can use the command
        
            mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video1 -fps 30
        


留言

熱門文章