Webcam

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (Removed the duplicate title)
(webcam in action)
 
(9 intermediate revisions by 5 users not shown)
Line 3: Line 3:
 
It is possible to plug and use a webcam on the [[Neo_FreeRunner|Freerunner]]. This is a very rough list of the steps required to do so with [[Debian]] Lenny installed.
 
It is possible to plug and use a webcam on the [[Neo_FreeRunner|Freerunner]]. This is a very rough list of the steps required to do so with [[Debian]] Lenny installed.
  
The webcam used to perform this is a Philips SPC620NC, using the UVC driver.
+
The webcam used to perform this example is a Philips SPC620NC, using the [[http://en.wikipedia.org/wiki/USB_video_device_class UVC]] driver.
  
 
The method described here is still rather ugly, feel free to improve it.
 
The method described here is still rather ugly, feel free to improve it.
Line 9: Line 9:
 
== Make it work on a PC ==
 
== Make it work on a PC ==
  
To be safe, you just first ensure the webcam works on a regular PC, and Linux in particular. You will already run into problems already, and it is much easier and faster to address them this way. The regular documentation applies:
+
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:
  
* for [http://linux-uvc.berlios.de/ UVC-compliant webcams]
+
* to [http://linux-uvc.berlios.de/ UVC-compliant webcams]
  
 
== Add video support to the kernel ==
 
== Add video support to the kernel ==
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
+
# 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
+
# apt-get install bzip2 gcc make libc6-dev libncurses5-dev
 
* uncompress it in /usr/src:
 
* uncompress it in /usr/src:
# cd /usr/src
+
# cd /usr/src
# tar -xjvf $OLDPWD/linux-2.6.24.tar.bz2
+
# 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
+
# 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
+
# cd /usr/src/linux-2.6.24
# gzip -dc /proc/config.gz > .config
+
# gzip -dc /proc/config.gz > .config
# make oldconfig          # just say "n" to power management debugging support
+
# make oldconfig          # just say "n" to power management debugging support
 
* add video support:
 
* add video support:
# make menuconfig
+
# 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/v4l1-compat.ko
# make drivers/media/video/v4l2-common.ko
+
# make drivers/media/video/v4l2-common.ko
# make drivers/media/video/videodev.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/v4l1-compat.ko
# insmod drivers/media/video/v4l2-common.ko
+
# insmod drivers/media/video/v4l2-common.ko
# insmod drivers/media/video/videodev.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
+
# apt-get install subversion
# svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
+
# svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
# cd trunk/linux-uvc
+
# cd trunk
# make
+
# make
  
 
And if all goes well:
 
And if all goes well:
# insmod uvcvideo.ko
+
# 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
+
# mkdir -p /dev/v4l
# mknod /dev/v4l/video0 c 81 0
+
# 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
+
# apt-get install luvcview
# luvcview -f yuv -d /dev/v4l/video0
+
# 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 06:33, 18 October 2010


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:
  1. wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2
  • make sure you have bzip2 and development tools installed:
  1. apt-get install bzip2 gcc make libc6-dev libncurses5-dev
  • uncompress it in /usr/src:
  1. cd /usr/src
  2. tar -xjvf $OLDPWD/linux-2.6.24.tar.bz2
  • fix links bluntly in /lib/modules:
  1. ln -sf /usr/src/linux-2.6.24 /lib/modules/2.6.24/build
  • initialize the kernel sources with the current configuration:
  1. cd /usr/src/linux-2.6.24
  2. gzip -dc /proc/config.gz > .config
  3. make oldconfig # just say "n" to power management debugging support
  • add video support:
  1. 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:
  1. make drivers/media/video/v4l1-compat.ko
  2. make drivers/media/video/v4l2-common.ko
  3. make drivers/media/video/videodev.ko
  4. make drivers/media/video/compat_ioctl32.ko
  • load the modules:
  1. insmod drivers/media/video/v4l1-compat.ko
  2. insmod drivers/media/video/v4l2-common.ko
  3. insmod drivers/media/video/videodev.ko
  4. 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:

  1. apt-get install subversion
  2. svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
  3. cd trunk
  4. make

And if all goes well:

  1. 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:

  1. mkdir -p /dev/v4l
  2. 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:

  1. apt-get install luvcview
  2. 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

Personal tools


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 is a Philips SPC620NC, using the UVC driver.

The method described here is still rather ugly, feel free to improve it.

Make it work on a PC

To be safe, you just first ensure the webcam works on a regular PC, and Linux in particular. You will already run into problems already, and it is much easier and faster to address them this way. The regular documentation applies:

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:
# wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2
  • 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
  • load the modules:
# insmod drivers/media/video/v4l1-compat.ko
# insmod drivers/media/video/v4l2-common.ko
# insmod drivers/media/video/videodev.ko

The errors encountered while loading modules can be obtained with the "dmesg" command. They are typically also logged in /var/log/messages.

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/linux-uvc
# make

And if all goes well:

# insmod uvcvideo.ko

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

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.

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

Known problems

  • the resolution was limited to 160x120 with our Philips SPC620NC