Surveillance Camera
Although my alarm performed as it should have I realized that I needed video surveillance so I could identify the thieves to the police next time. I decided to use a TRENDnet wireless IP netcam, my always on Linux server , and the open source program called Motion to accomplish said surveillance of my driveway and increase the security of my home.
Camera
The TRENDnet ProView Wireless Internet Surveillance Camera TV-IP501W (left) is a nice looking camera and mounted discreetly on the overhang of my roof. It was easy to setup as all I needed to do was run a power cable to it. It uses 802.11g so I didn’t need to worry about a separate ethernet cable. It has a built in web server which is pretty easy to use.
Motion
Although the TRENDnet camera has the ability to upload images to an FTP server, it doesn’t detect motion and drops many, too many, images when configured to do so. I decided to set up Motion, “a software motion detector”, which intelligently detects motion and only saves images that show a material change in the picture. The Motion website has a page with details on interfacing with TRENDnet camera which was helpful in getting everything configured: http://www.lavrsen.dk/foswiki/bin/view/Motion/TrendNet. I installed Motion on my Pogoplug server running Arch Linux by simply running pacman -S motion. The two important config settings in /etc/motion/motion.conf were:
netcam_url http://192.168.1.7/VIDEO.CGI #192.168.1.7 is the IP address of the camera
threshold 3000 #trial and error determined this to be best when camera is at 640x480 resolution
Archiving
Motion does a great job of dropping only images that display motion but I wanted to have a bash script run nightly that would zip up all the images for the day and also create a time-lapse video so I could quickly see the motion for an entire day. Also, I wanted it to only keep 10 days of history. Here’s what I came up with:
#!/bin/bash
# Format: YEAR MONTH DAY
DATE=$(date +%Y%m%d)
PATH="/srv/surveillance/driveway"
TARGET_FILE="$PATH/$DATE"
cd $PATH
#create timelapse video
/bin/rm $TARGET_FILE.mp4
x=1; for i in $(/bin/ls *jpg); do counter=$(printf %03d $x); /bin/ln -s "$i" img"$count$
/usr/bin/ffmpeg -r 5 -i img%03d.jpg -pix_fmt yuv420p $TARGET_FILE.mp4
/bin/rm img*.jpg
#archive images into zip
zip -m $TARGET_FILE.zip *.jpg -x \*.zip
#remove image archives and videos that are at least 10 days old
find /srv/surveillance/driveway/* -mtime +10 -exec /bin/rm {} \;
iPhone Integration
<a href="http://192.168.1.7/VIDEO.CGI"><img src="http://192.168.1.7/IMAGE.JPG"/></a>
on the page so that an image still will show (IMAGE.JPG) and then clicking the image will take me to the live video feed (VIDEO.CGI) directly from the camera.
[ ][3]
Samples
Single image
Time-lapse video