注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

心情挺好的博客

正在等你光临呢 呵呵

 
 
 

日志

 
 
关于我

喜欢摄影的朋友看过来:) 有时间就跟我一起去拍照去吧. QQ272751 上海圣玛丽摄影化妆培训学校 16年专业摄影培训化妆培训学校 电话:15900513500。 http://www.smlsh.com

网易考拉推荐

Spca5xx-LE WebCam   

2009-01-13 14:09:16|  分类: 技术 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
Spca5xx-LE WebCam PDF Print E-mail
(10 votes)
Written by macsat   
Tuesday, 03 January 2006


Running a webcam directly on your OpenWrt router allows you to create a webpage with a web cam that is ALWAYS on. You can attach a cam to any OpenWrt Compatible router that has USB ports.

This tutorial is specific for spca5xx based webcams. Theese cams include popular models like the Creative NX, Creative NX Pro, Creative NX Pro2, Creative Live!, Logitech Quickcam IM, Logitech Quickcam for Notebook and many more.

The complete list of compatible devices can be found on: http://mxhaard.free.fr/spca5xx.html

 

Index

1) Installing spca5xx
2) Using spcacat

Installing spca5xx

Very often installing software in OpenWrt is as easy as 1-2-3. Unfortunately I havent been able to find any pre-build ipkg packages including the kernel modules and software for using with the spca5xx web cams.
Instead I have found some binaries build by j0chen - thanks a lot for theese very usefull builds.

The first thing to do, is to download the needed files. To (of three) binaries are needed. You will need a kernel module (driver) and a small programme to retrieve images from the web cam. There are two possible kernel modules, the "normal" one and one made specifically for Embedded Devices like the OpenWrt routers - this version is suffixed with "LE".

If your device is supported by the LE version of the driver, I really do suggest that you use this one, as it takes up less ressources than the "full" version. Consult the list of compatible devices here: http://mxhaard.free.fr/spca5xx.html and pay attention to the "Driver" column. If your device is listed with spca5xx/LE, you can use the LE version - if it is listed with spca5xx you will need the full version.

The modules can be found on the Downloads section of this page. Unfortunately I have been forced to make the section registered-users only, in order to try to keep traffic a bit down. So if you decide to go on from here, you will have to register. This also allows you to post questions and comments on the forums, so it might be worhtwhile anyway.

The needed files are:
Kernel Module - LE version: http://www.macsat.com/macsat/component/option,com_docman/task,doc_details/gid,11/Itemid,63/

Kernel Module - Full version: http://www.macsat.com/macsat/component/option,com_docman/task,doc_details/gid,10/Itemid,63/

Software to retrive images: http://www.macsat.com/macsat/component/option,com_docman/task,doc_details/gid,12/Itemid,63/

I will show the way to install the LE version. Installing the non-LE version is EXCATELY the same, just with a different name of the files :-)

After having downloaded the files, you need to copy them to your router. An easy and smooth way to do this is by sftp or ftp.

Start by changing to the directory where you uploaded your two files. Often this will be in /tmp since this is the default "server root" for the sftpd server. Then move the files to the appropiate folders, unpack them and set the correct file rights.

mv spca5xx_lite.o.gz /lib/modules/2.4.30
cd /lib/modules/2.4.30/
gunzip spca5xx_lite.o.gz

mv spcacat.gz /usr/bin
cd /usr/bin
gunzip spcacat.gz
chmod +x spcacat

Now it is time to add the module, so that it is loaded at statup. The kernel module is dependent of the kmod-videodev, so this will be installed first, and then the spca4xx_lite module is set to be loaded at startup.

ipkg install videodev
cat "videodev" >> /etc/modules
cat "spca5xx_lite" >> /etc/modules

In order to test if this works, either reboot your router or run something like this:

insmod videodev
insmod spca5xx_lite

Try running dmesg to see if you get something like this occurs at the end:

Linux video capture interface: v1.00
usb.c: registered new driver spca5xx
spca_core.c: spca5xx driver 00.57.06LE registered

Now connect your web cam, for my cam - a Creative NX Pro - I get this in  my syslog (dmesg): 

hub.c: new USB device 01:02.0-1, assigned address 5
spca_core.c: USB SPCA5XX camera found. Type Creative NX Pro Zc301+hv7131b

This creates a device called /dev/v4l/video0
For some reason, the version of spcacat we have here, dosnt support using this device, but if you create a symlink to it, it will works just fine:

ln -s /dev/v4l/video0 /dev/video0 

 

Using spcacat

The spcacat binary has the following possible switches:
spcacat [-h -d -g -f -s -p -N -P -o]
     -h show this usage message.
     -d  device ask the driver to use specified video output device (/dev/video1)
     -o outputfile  causes the program to output avi  with image data received from the video device to the specified file.
     -g grab with READ method instead of default MMAP
     -f video format  nothing YUV420P  fourcc I420
        jpg JPEG         fourcc MJPG
        yuv YUV420P   fourcc I420
    r16 RGB565 16bits fourcc RGB2
    r24 RGB 24bits  fourcc RGB3
    r32 RGB 32bits  fourcc RGB4
    -v RAW data  fourcc RAWD
     -s widthxheight ask the driver for input size
     -p X take a picture every X seconds
     -p X && -o getPicture every X seconds and record in SpcaPict.jpg (spcacat)
     -N take N pictures and stop
     -P parport device (spcacat, spcaserv)

I have made a small bash script that will retrieve an image every 10 seconds, and save it as SpcaPict.jpg.

My script is called imagesnap.sh and looks like:
#/bin/sh
spcacat -d /dev/video0 -g -f jpg -p 10000 -o > /opt/var/log/spcacat.log

As you can see, I write my log on the /opt location, meaning that I write it on an external storage device. It is NOT recommended to write the output log in the falsh, as it will wear out with all the writing. If you do not have an external storage device attached, I recommend that you write the log (the > /opt/var/log/spcacat.log statement) and the image itselves, to /tmp

To make the script run at startup, you can place it in /opt/www and make a S97webcam like:
cp imagesnap.sh /opt/www
chmod +x /opt/www/imagesnap.sh
echo "/opt/www/imagesnap.sh &" > /etc/init.d/S97webcam
chmod +x /etc/init.d/S97webcam

Now at boot time you will have your webcam create the image /opt/www/SpcaPict.jpg every 10 seconds.

To access the file, I have made a small html page (/opt/www/webcam.html) :

<html><head>
<script language="JavaScript">
<!--
function refreshIt() {
   if (!document.images) return;
      document.images['SpcaPic'].src = 'SpcaPict.jpg?' + Math.random();
      setTimeout('refreshIt()',10000); // refresh every timeout/1000 secs
 }
//-->
</script>
</head>
<body onLoad=" setTimeout('refreshIt()',5000)">
<br><br><br>
<center>
<img src="SpcaPict.jpg" name="SpcaPic">
<br>
Images refreshed every 10 seconds.
</center>
</body></html>

 

Now you can access your webcam by http://<your-router-ip>/webcam.html

(if youre web server is setup to serve this location!)

Last Updated ( Monday, 26 February 2007 )
  评论这张
 
阅读(452)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017