Difference between revisions of "Sekuro-box"
(→What is the Sekuro-box ?) |
m |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 16: | Line 16: | ||
* Reading this guide | * Reading this guide | ||
− | For this project, I bought a Creative Webcam for Notebook (about 50€) as it's a tiny webcam and it is reported as providing a quite good quality picture under linux, but there is cheaper webcams available (you | + | For this project, I bought a Creative Webcam for Notebook (about 50€) as it's a tiny webcam and it is reported as providing a quite good quality picture under linux, but there is cheaper webcams available (you may already have one by the way, i was one of the latest person on earth without a webcam).<br /> |
http://images.creative.com/iss//images/inline/products/webcam_notebook/fe_1.jpg | http://images.creative.com/iss//images/inline/products/webcam_notebook/fe_1.jpg | ||
Line 29: | Line 29: | ||
== The easy way == | == The easy way == | ||
− | For the guys who do not want to compile/install/configure things, i've done a complete disk image (for the Kuro-box HG only) that you'll just have to put in your kurobox, you can download it here (it's based on the debian image with some custom modifications explained in this article) : | + | For the guys who do not want to compile/install/configure things, i've done a complete disk image (I've built it for the Kuro-box HG only, people with standard Kuro-box will have to follow the [http://www.kurobox.com/mwiki/index.php/Contest_sekuro-box#The_hard_way hard way] steps to build their own image) that you'll just have to put in your kurobox, you can download it here (it's based on the debian image with some custom modifications explained in this article) :<br /> |
− | < | + | [http://www.kurobox.com/sylver/contest/06-07-01_sekuro-box/sekuro-box_1.0.tar.gz Sekuro-box image v1.0]<br /> |
+ | ''Note that this image is compatible with "standard" boot and with U-boot !'' | ||
− | Usage is simple : | + | Usage is "simple" : |
* As with this image, your kuro-box will ask for an IP adress using DHCP, make sure that you have a DHCP server to serve an IP to the kurobox :) | * As with this image, your kuro-box will ask for an IP adress using DHCP, make sure that you have a DHCP server to serve an IP to the kurobox :) | ||
+ | * The image is based on Debian, check [[debian_install|Install Debian]] for installation details ! | ||
+ | * Default user is unchanged from original debian image (tmp-kun/tmp-kun) | ||
* First time you run the image, create a /mnt/webcam folder to store all pictures/videos | * First time you run the image, create a /mnt/webcam folder to store all pictures/videos | ||
* Plug your webcam in one of the USB connector (webcam support is done through [http://mxhaard.free.fr/spca5xx.html SPCA5xx] & [http://www.saillard.org/linux/pwc/ PWC] drivers, check the links to know if your webcam is supported) | * Plug your webcam in one of the USB connector (webcam support is done through [http://mxhaard.free.fr/spca5xx.html SPCA5xx] & [http://www.saillard.org/linux/pwc/ PWC] drivers, check the links to know if your webcam is supported) | ||
Line 71: | Line 74: | ||
export ARCH=ppc | export ARCH=ppc | ||
make menuconfig | make menuconfig | ||
− | Device Drivers > Multimedia Devices > Video For Linux and press "m" to build it as a module (you can press "y" to build it in the kernel) | + | Device Drivers > Multimedia Devices > Video For Linux |
+ | and press "m" to build it as a module (you can press "y" to build it in the kernel) | ||
* now compile the kernel | * now compile the kernel | ||
make oldconfig | make oldconfig | ||
make vmlinux (or "make uImage" if running U-boot) | make vmlinux (or "make uImage" if running U-boot) | ||
− | objcopy -O binary vmlinux /boot/vmlinux.bin (or "cp uImage /boot" | + | objcopy -O binary vmlinux /boot/vmlinux.bin (or "cp arch/ppc/boot/images/uImage /boot" if running U-boot) |
cp System.map /boot && cp .config /boot (could be usefull to rebuild your kernel later) | cp System.map /boot && cp .config /boot (could be usefull to rebuild your kernel later) | ||
make modules | make modules | ||
Line 124: | Line 128: | ||
* Motion installation : | * Motion installation : | ||
apt-get install motion | apt-get install motion | ||
+ | * Create the folder where to store captures : | ||
+ | mkdir /mnt/webcam | ||
==== Motion configuration ==== | ==== Motion configuration ==== | ||
− | + | You'll need to configure motion to fit your needs ! | |
+ | To achieve that, edit the configuration file : | ||
+ | nano /etc/motion/motion.conf | ||
+ | Active the daemon mode : | ||
+ | daemon on | ||
+ | Use device /dev/video0 : | ||
+ | videodevice /dev/video0 | ||
+ | Configure capture resolution (320x240 is recommended as 640x480 is too much for the Kuro-box) | ||
+ | width 320 | ||
+ | height 240 | ||
+ | Set framerate to a value that will not overload the Kuro-box (5 fps seems to be a good value) | ||
+ | framerate 5 | ||
+ | If you want motion to create a video from the captured picture, set this : (warning, it's using a lot of CPU and therefore cause motion instability) | ||
+ | ffmpeg_cap_new on | ||
+ | Choose the compression method : | ||
+ | ffmpeg_video_codec mpeg4 | ||
+ | or | ||
+ | ffmpeg_video_codec msmpeg4 | ||
+ | Set target dir to /mnt/webcam | ||
+ | target_dir /mnt/webcam | ||
+ | Set webcam port to 8000 and allow anyone to connect it : | ||
+ | webcam_port 8000 | ||
+ | webcam_localhost off | ||
==== Video encoding application installation ==== | ==== Video encoding application installation ==== | ||
Line 147: | Line 175: | ||
=== Cron job to clean old files === | === Cron job to clean old files === | ||
− | If you let motion fills your hard disk with pictures/videos, | + | If you let motion fills your hard disk with pictures/videos, you'll fast have the disk full problem ! |
To prevent that, we will set up a cron job to clean files older than 30 days (you can change that value for your needs) ! | To prevent that, we will set up a cron job to clean files older than 30 days (you can change that value for your needs) ! | ||
First, install cron : | First, install cron : | ||
Line 154: | Line 182: | ||
crontab -e | crontab -e | ||
enter this line : | enter this line : | ||
− | 00 20 * * * find /mnt/ | + | 00 20 * * * find /mnt/webcam -mtime +30 -exec rm {} \; |
Every days at 20:00 (08:00PM), it'll check for files older than 30 days in /mnt/motion and delete them ! | Every days at 20:00 (08:00PM), it'll check for files older than 30 days in /mnt/motion and delete them ! | ||
+ | |||
+ | |||
+ | |||
+ | {{Articles|Open Contest|Kurobox}} |
Latest revision as of 18:42, 11 August 2007
Contents
The Sekuro-box
Here is my new contest entry !
What is the Sekuro-box ?
What can be that Sekuro-box ? It's a security center based on the fantastic Kuro-box, it will allow you to :
- Remotely watch for a place using a Webcam
- Record (in jpg or avi) any activity in front of the webcam (using a motion detection software)
- Keep the pictures/videos during a certain time so you'll not have a disk full problem !
Requirements
What do you need for this project ?
- A Kuro-box (standard or HG)
- A Webcam supported by a Linux driver
- Something or someone to watch
- Reading this guide
For this project, I bought a Creative Webcam for Notebook (about 50€) as it's a tiny webcam and it is reported as providing a quite good quality picture under linux, but there is cheaper webcams available (you may already have one by the way, i was one of the latest person on earth without a webcam).
Some examples of how it looks like
Here is a sample of what you can get :
That what we call "caught in action" ! As you can see, this allowed me to have the proof that my cat was going on the sofa when we're away, even if he knows that it is totally forbidden ! With that proof, i finally applyied an immediate sanction : no meat for 1 month ! I guess you can think about some applications in your case :D
The easy way
For the guys who do not want to compile/install/configure things, i've done a complete disk image (I've built it for the Kuro-box HG only, people with standard Kuro-box will have to follow the hard way steps to build their own image) that you'll just have to put in your kurobox, you can download it here (it's based on the debian image with some custom modifications explained in this article) :
Sekuro-box image v1.0
Note that this image is compatible with "standard" boot and with U-boot !
Usage is "simple" :
- As with this image, your kuro-box will ask for an IP adress using DHCP, make sure that you have a DHCP server to serve an IP to the kurobox :)
- The image is based on Debian, check Install Debian for installation details !
- Default user is unchanged from original debian image (tmp-kun/tmp-kun)
- First time you run the image, create a /mnt/webcam folder to store all pictures/videos
- Plug your webcam in one of the USB connector (webcam support is done through SPCA5xx & PWC drivers, check the links to know if your webcam is supported)
- Then go to http://kurobox_ip/motion
- Here you'll have a record of past events, and you'll be able to watch the live stream from you webcam !
The hard way
First of all, you'll need a development environement with gcc & needed stuff ! I suggest you installing a Debian image as it will save a lot of time installing all needed applications ;) With Debian, install the developement tools this way :
apt-get install make automake gcc g++ patch libncurses5-dev
Also install some tools you will need later :
apt-get install wget bzip2
Then follow these guides :
- Install udev on Debian without breaking the system
- Install usbmount for automatic USB devices mounting
Now you're ready for the next step.
Compile the kernel with video4linux support
You need to compile the kernel with the video4linux module !
- First of all, download the vanilla linux kernel sources :
cd /usr/src wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.1.tar.bz2
- get the linux kernel patch for the kurobox
wget http://genbako.vodapone.com/kurobox-sources-2.6.17.patch
- untar the kernel sources, apply the patch and create the symbolic link
tar xjf linux-2.6.17.1.tar.bz2 patch -Np0 < kurobox-sources-2.6.17.patch ln -s linux-2.6.17.1 linux
- now go to linux directory an copy the .config file according to the kurobox you have :
for the standard Kuro-box :
cd linux && cp config_kurobox .config
For the Kuro-box HG
cd linux && cp config_kuroboxhg .config
- then you need to configure the kernel to support video4linux (needed for the webcam)
export ARCH=ppc make menuconfig Device Drivers > Multimedia Devices > Video For Linux and press "m" to build it as a module (you can press "y" to build it in the kernel)
- now compile the kernel
make oldconfig make vmlinux (or "make uImage" if running U-boot) objcopy -O binary vmlinux /boot/vmlinux.bin (or "cp arch/ppc/boot/images/uImage /boot" if running U-boot) cp System.map /boot && cp .config /boot (could be usefull to rebuild your kernel later) make modules sudo make modules_install
- now reboot to run your new kernel :D
reboot
Build the kernel module for your webcam
SPCA5xx driver
If you need SPCA5xx driver :
- Download module sources
wget http://mxhaard.free.fr/spca50x/Download/spca5xx-20060501.tar.gz
- Detar the archive
tar xzf spca5xx-20060501.tar.gz && cd spca5xx-20060501
- compile module
export ARCH=ppc => as it will use kernel sources to compile, we need this line ! make
- install module
make install
- now plug your webcam and check that the spca5xx module is loaded :
> lsmod Module Size Used by spca5xx 677520 0 videodev 11072 1 spca5xx (will only be present if you built video4linux as a module)
PWC driver
If you need PWC driver :
- Download PWC module (snapshot version would be better as it supports more webcams) :
wget http://www.saillard.org/linux/pwc/snapshots/pwc-v4l2-20060627-042701.tar.bz2 (pick a version from the snapshot page
- Detar the archive
tar xjf pwc-v4l2-20060627-042701.tar.bz2
- Compile module
export ARCH=ppc => as it will use kernel sources to compile, we need this line ! make
- Install module
make install
- now plug your webcam and check that the spca5xx module is loaded :
> lsmod
Others drivers
If you need another driver : If you found another driver to handle your webcam, then the process to install it should be almost the same (don't forget the "export ARCH=ppc", it is really important if you want your driver to compile correctly. <to be completed...>
Motion application installation
Now that the webcam driver is installed, we will install the application that will process the output of the webcam ! We will choose motion as it allows to capture pictures/videos when a mouvement is detected in the field of the webcam, and its CPU needs are compatible with the Kuro-box CPU !
Application installation
- Motion installation :
apt-get install motion
- Create the folder where to store captures :
mkdir /mnt/webcam
Motion configuration
You'll need to configure motion to fit your needs ! To achieve that, edit the configuration file :
nano /etc/motion/motion.conf
Active the daemon mode :
daemon on
Use device /dev/video0 :
videodevice /dev/video0
Configure capture resolution (320x240 is recommended as 640x480 is too much for the Kuro-box)
width 320 height 240
Set framerate to a value that will not overload the Kuro-box (5 fps seems to be a good value)
framerate 5
If you want motion to create a video from the captured picture, set this : (warning, it's using a lot of CPU and therefore cause motion instability)
ffmpeg_cap_new on
Choose the compression method :
ffmpeg_video_codec mpeg4
or
ffmpeg_video_codec msmpeg4
Set target dir to /mnt/webcam
target_dir /mnt/webcam
Set webcam port to 8000 and allow anyone to connect it :
webcam_port 8000 webcam_localhost off
Video encoding application installation
If you want to be able to record videos, you'll also need to install ffmpeg !
- ffmpeg installation :
apt-get install ffmpeg
Web survey pages installation
You'll need to install an http server with php support if you want to be able to check if your webcam have detected something ! For this, you should follow the firsts steps of my Install Torrentflux + Transmission + SQLite guide ! Modify lighttpd to allow .cgi execution :
nano /etc/lighttpd/conf-available/10-cgi.conf
and add the this line in "cgi.assign" section :
".cgi" => "",
I did an updated version of MotionCGI you'll have to install in your server home :
cd /var/www wget http://www.kurobox.com/sylver/contest/06-07-01_sekuro-box/motion.tar.gz tar xzf motion.tar.gz && rm motion.tar.gz cd motion cp motion.cgi.conf /etc
Now you can log to http://kurobox_ip/motion ! The web interface will allow you to check captured images/videos and most impotant thing, it'll allow you to start or stop the motion daemon !
Cron job to clean old files
If you let motion fills your hard disk with pictures/videos, you'll fast have the disk full problem ! To prevent that, we will set up a cron job to clean files older than 30 days (you can change that value for your needs) ! First, install cron :
apt-get install cron
Then add the cron job :
crontab -e
enter this line :
00 20 * * * find /mnt/webcam -mtime +30 -exec rm {} \;
Every days at 20:00 (08:00PM), it'll check for files older than 30 days in /mnt/motion and delete them !