Friday, November 9, 2007

Debian Etch + Quickcam Chat


This is the key feature for my next sad and freak project. I need a webcam working on my linux server. I've failed several times to configure it properly, but I finally achieved it. Here you will find how to configure a Logitech Quickcam Chat on an Etch Debian.
Find your webcam driver

To find if your webcam has linux drivers the best approach is to:

  1. Connect your usb webcam to your linux and type lsusb command to get the USB ID of of your webcam, something like this: Bus 001 Device 002: ID 046d:092f Logitech, Inc.
  2. Then you can go google and search something like "046d:092f linux driver"
  3. For my Quickcam Chat I found that the spca5xx was a good option
Installing Quickcam Chat

The main trouble found when installing the Quickcam Chat was that the source code provided by the spca5xx debian package supported the Quickcam Chat by didn't include the its USB ID, so the only way to make it work out is to apply a patch over the spca5xx code.

  1. apt-get install spca5xx-source
  2. Get the qcexpress.patch (I missed a line or something creating the patch file, you will get an error applying it, don't worry it works)
  3. Get your kernel headers if you don't have them. apt-get install linux-headers-2.6.*-*-*
  4. cd /usr/src
  5. tar jxvf spca5xx-source.tar.bz2
  6. cd modules
  7. patch -lp1 < /tmp/qcexpress.patch
  8. cd spca5xx
  9. make
  10. make install
And that's it, you will see the typical messages showing that your linux has properly loaded the webcam and as a result of this there will be a new device /dev/video0

How to grab images
  1. Download spcacat source code from LibLand or get the version I used..Spcacat Code.
  2. tar -zxvf spcaview-20061208.tar.gz
  3. make install_spcacat
  4. And this will hopefully creates de binary at /usr/local/bin/spcacat
  5. To get a nice SpcaPict.jpg, type spcacat -N 1 -o
Another way to grab images

  1. apt-get install libjpeg62-dev
  2. Get videodog last version or the one I used videodog 0.3.1
  3. tar -zxvf videodog031tar.gz
  4. make
  5. Test videodog with this ./videodog -x 352 -y 288 -w 3 -d /dev/video0 -j -f test.jpg
I finally use the videodog as its more lightweight and the command-line is more appropriate for my use-cases.

Python web sample


import subprocess
import os

def GrabWebcamImage():
  os.system('[videodogPath]/videodog -x 352 -y 288 -w 3 -d /dev/video0 -j -f upload/webcam.jpg')

def index():
  GrabWebcamImage()
  msg = """
  <html>
  <script language="javascript">
  setTimeout("window.location = '[yourURL]/index.py'"
  </script>
  <title>Webcam</title>
  <body>
  <img src="upload/webcam.jpg">
  </body>
  </html>
  """
  return msg

if __name__ == '__main__':
  print  index()

No comments:

Post a Comment