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:
- 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.
- Then you can go google and search something like "046d:092f linux driver"
- For my Quickcam Chat I found that the spca5xx was a good option
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.
- apt-get install spca5xx-source
- 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)
- Get your kernel headers if you don't have them. apt-get install linux-headers-2.6.*-*-*
- cd /usr/src
- tar jxvf spca5xx-source.tar.bz2
- cd modules
- patch -lp1 < /tmp/qcexpress.patch
- cd spca5xx
- make
- make install
How to grab images
- Download spcacat source code from LibLand or get the version I used..Spcacat Code.
- tar -zxvf spcaview-20061208.tar.gz
- make install_spcacat
- And this will hopefully creates de binary at /usr/local/bin/spcacat
- To get a nice SpcaPict.jpg, type spcacat -N 1 -o
- apt-get install libjpeg62-dev
- Get videodog last version or the one I used videodog 0.3.1
- tar -zxvf videodog031tar.gz
- make
- Test videodog with this ./videodog -x 352 -y 288 -w 3 -d /dev/video0 -j -f test.jpg
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