Webcam
From Openmoko
(Small tidying; added link to Wikipedia UVC page) |
Yavannadil (Talk | contribs) (webcam in action) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 18: | Line 18: | ||
* download the source code for the kernel: | * download the source code for the kernel: | ||
− | + | # wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2 | |
* make sure you have bzip2 and development tools installed: | * make sure you have bzip2 and development tools installed: | ||
− | + | # apt-get install bzip2 gcc make libc6-dev libncurses5-dev | |
* uncompress it in /usr/src: | * uncompress it in /usr/src: | ||
− | + | # cd /usr/src | |
− | + | # tar -xjvf $OLDPWD/linux-2.6.24.tar.bz2 | |
* fix links bluntly in /lib/modules: | * fix links bluntly in /lib/modules: | ||
− | + | # ln -sf /usr/src/linux-2.6.24 /lib/modules/2.6.24/build | |
* initialize the kernel sources with the current configuration: | * initialize the kernel sources with the current configuration: | ||
− | + | # cd /usr/src/linux-2.6.24 | |
− | + | # gzip -dc /proc/config.gz > .config | |
− | + | # make oldconfig # just say "n" to power management debugging support | |
* add video support: | * add video support: | ||
− | + | # make menuconfig | |
Basically, look for "Device drivers", "Multimedia devices", then enable "Video For Linux", "Video For Linux API 1", "Video For Linux API 1 compatible Layer", "Video capture adapters" as modules. If the driver for your webcam is found in the kernel already, also enable it there. | Basically, look for "Device drivers", "Multimedia devices", then enable "Video For Linux", "Video For Linux API 1", "Video For Linux API 1 compatible Layer", "Video capture adapters" as modules. If the driver for your webcam is found in the kernel already, also enable it there. | ||
* compile the relevant kernel modules: | * compile the relevant kernel modules: | ||
− | + | # make drivers/media/video/v4l1-compat.ko | |
− | + | # make drivers/media/video/v4l2-common.ko | |
− | + | # make drivers/media/video/videodev.ko | |
+ | # make drivers/media/video/compat_ioctl32.ko | ||
* load the modules: | * load the modules: | ||
− | + | # insmod drivers/media/video/v4l1-compat.ko | |
− | + | # insmod drivers/media/video/v4l2-common.ko | |
− | + | # insmod drivers/media/video/videodev.ko | |
+ | # insmod drivers/media/video/compat_ioctl32.ko | ||
The errors encountered while loading modules can be obtained with the "dmesg" command. They are typically also logged in /var/log/messages. | The errors encountered while loading modules can be obtained with the "dmesg" command. They are typically also logged in /var/log/messages. | ||
Line 46: | Line 48: | ||
To obtain and compile the latest source tree for the driver: | To obtain and compile the latest source tree for the driver: | ||
− | + | # apt-get install subversion | |
− | + | # svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk | |
− | + | # cd trunk | |
− | + | # make | |
And if all goes well: | And if all goes well: | ||
− | + | # insmod uvcvideo.ko | |
== Add the device node == | == Add the device node == | ||
Line 58: | Line 60: | ||
In our case, the relevant device node was not created automatically. Here's how to do so: | In our case, the relevant device node was not created automatically. Here's how to do so: | ||
− | + | # mkdir -p /dev/v4l | |
− | + | # mknod /dev/v4l/video0 c 81 0 | |
== Plug the camera itself == | == Plug the camera itself == | ||
Line 70: | Line 72: | ||
A good webcam test application is [http://www.quickcamteam.net/software/linux/v4l2-software/luvcview luvcview]. You can install and test it this way: | A good webcam test application is [http://www.quickcamteam.net/software/linux/v4l2-software/luvcview luvcview]. You can install and test it this way: | ||
− | + | # apt-get install luvcview | |
− | + | # luvcview -f yuv -d /dev/v4l/video0 | |
+ | |||
+ | Webcam in action: [http://www.cymraeg.ru/daoulagad.html] | ||
== Known problems == | == Known problems == | ||
* the resolution was limited to 160x120 with our Philips SPC620NC | * the resolution was limited to 160x120 with our Philips SPC620NC | ||
+ | |||
+ | This limitation may depend on video format; for example, luvcvideo on FreeRunner&debian told me that Logitech QuickCam E3500+ supports up to 176x144 with YUV, and up to 640x480 with MJPG | ||
+ | |||
+ | [[Category:Middleware]] | ||
+ | [[Category:Low-level software]] |
Latest revision as of 07:33, 18 October 2010
Languages: |
English • العربية • Български • Česky • Dansk • Deutsch • Esperanto • Eesti • Español • فارسی • Suomi • Français • עברית • Magyar • Italiano • 한국어 • Nederlands • Norsk (bokmål) • Polski • Português • Română • Русский • Svenska • Slovenčina • Українська • 中文(中国大陆) • 中文(台灣) • Euskara • Català |
It is possible to plug and use a webcam on the Freerunner. This is a very rough list of the steps required to do so with Debian Lenny installed.
The webcam used to perform this example is a Philips SPC620NC, using the [UVC] driver.
The method described here is still rather ugly, feel free to improve it.
Contents |
[edit] Make it work on a PC
To be safe, you just first ensure the webcam works on a regular PC, and Linux in particular. This will minimise the problems you are likely to face (though it may not eliminate them altogether). The regular documentation applies:
[edit] Add video support to the kernel
The 2.6.24 kernel is provided without video input support enabled. There is a way to add the necessary modules without recompiling everything:
- download the source code for the kernel:
- make sure you have bzip2 and development tools installed:
- apt-get install bzip2 gcc make libc6-dev libncurses5-dev
- uncompress it in /usr/src:
- cd /usr/src
- tar -xjvf $OLDPWD/linux-2.6.24.tar.bz2
- fix links bluntly in /lib/modules:
- ln -sf /usr/src/linux-2.6.24 /lib/modules/2.6.24/build
- initialize the kernel sources with the current configuration:
- cd /usr/src/linux-2.6.24
- gzip -dc /proc/config.gz > .config
- make oldconfig # just say "n" to power management debugging support
- add video support:
- make menuconfig
Basically, look for "Device drivers", "Multimedia devices", then enable "Video For Linux", "Video For Linux API 1", "Video For Linux API 1 compatible Layer", "Video capture adapters" as modules. If the driver for your webcam is found in the kernel already, also enable it there.
- compile the relevant kernel modules:
- make drivers/media/video/v4l1-compat.ko
- make drivers/media/video/v4l2-common.ko
- make drivers/media/video/videodev.ko
- make drivers/media/video/compat_ioctl32.ko
- load the modules:
- insmod drivers/media/video/v4l1-compat.ko
- insmod drivers/media/video/v4l2-common.ko
- insmod drivers/media/video/videodev.ko
- insmod drivers/media/video/compat_ioctl32.ko
The errors encountered while loading modules can be obtained with the "dmesg" command. They are typically also logged in /var/log/messages.
[edit] Compile the UVC driver
To obtain and compile the latest source tree for the driver:
- apt-get install subversion
- svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
- cd trunk
- make
And if all goes well:
- insmod uvcvideo.ko
[edit] Add the device node
In our case, the relevant device node was not created automatically. Here's how to do so:
- mkdir -p /dev/v4l
- mknod /dev/v4l/video0 c 81 0
[edit] Plug the camera itself
The Freerunner needs to run in USB host mode in order to do this. A special USB cable (or gender changer) is necessary to do so.
Again, you can use the command "dmesg" to verify that the camera is properly recognized.
[edit] Install and try a viewer
A good webcam test application is luvcview. You can install and test it this way:
- apt-get install luvcview
- luvcview -f yuv -d /dev/v4l/video0
Webcam in action: [1]
[edit] Known problems
- the resolution was limited to 160x120 with our Philips SPC620NC
This limitation may depend on video format; for example, luvcvideo on FreeRunner&debian told me that Logitech QuickCam E3500+ supports up to 176x144 with YUV, and up to 640x480 with MJPG