Tag Archives: surveillance

Controlling my video surveillance from my iPhone

My video surveillance works great, but there’s a problem. I don’t want it on when I’m home, it tends to fill up my hard drive. I thought to myself “what’s the easiest way to do this?”. I came up with starting and stopping the motion service (the service doing the surveillance) via php-pages on a web server. Not very high tech, but it’s easy to implement.

To start with I installed Apache, PHP, etc. Just apt-get install in Debian.

The next step is to make the Apache user able to start and stop motion, I did this with some sudo tricks and added the following to /etc/sudoers after installing sudo.

Cmnd_Alias MOTION = /etc/init.d/motion
User_Alias MOTIONUSERS = www-data
MOTIONUSERS ALL = NOPASSWD : MOTION

This gives the www-data-user rights to use sudo and restart motion without a password.

Now, the last step is to create two simple php pages. I have one called start.php and one called stop.php.

<html>
<head>
<link rel="apple-touch-icon" href="Safe.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="safe_114.png"/>
<title>Start Motion</title>
</head>
<body>
<?
system('sudo /etc/init.d/motion start');
print $list_line;
?>
<br>
<h1>Started!</h1>
</body>
</html>

<html>
<head>
<link rel="apple-touch-icon" href="Safe.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="safe_114.png"/>
<title>Stop Motion</title>
</head>
<body>
<?
system('sudo /etc/init.d/motion stop');
?>
<br>
<h1>Stopped!</h1>
</body>
</html>

Each file contains a line to start/stop motion plus apple touch icons. The icons are used when I add the start and stop pages on my home screen on my iPhone.

Icons added to home screen

Icons added to home screen

I can now start motion when I leave home and stop it just before i open the front door and thus avoid any extra pictures or alarms.

Deleting old surveillance pictures

My surveillance at home takes a LOT of pictures, two every second when there’s activity. This tends to build up to a lot over time, so I though I’d need some kind of script deleting old pictures.

I’m using find to delete all files older than six days. This is then put in roots crontab.

# crontab -e

# m h  dom mon dow   command
0 0     *       *       *       find /tmp/motion -type f -mtime +6 -exec rm {} \;

This simple command runs once every night and deletes all old files located in /tmp/motion.

Loads o' surveillance files

Loads o' surveillance files

Video surveillance in Linux with a webcam, round 3

Alright, after a few mistakes, profanities and other unpleasantries I now have my video surveillance up and running!

I got motion to cooperate with my new webcam and it’s now pointed at my front door. First I tried Ubuntu, didn’t work. Then I tried FreeBSD, didn’t work. Last I tried Debian 6, works as intended! I’m more than pleased.

It works!

It works!

My plan is to write some sort of script now that checks if my mobile phone is in the vicinity. If so, the surveillance should be turned off. This is probably easiest to do with Bluetooth, but I’ll get back to you all on that.

Video surveillance in Linux with a webcam, round 2

In my last post I described my video surveillance system in Linux. Can’t say that I’m 100% pleased with it though, so I thought I’d try a console program called motion instead. It pretty much does the same thing, but I don’t have to use a web interface etc. This is, just like ZoneMinder, just a matter of apt-get install motion.

The first problem I ran into was that my webcam wouldn’t work with motion, no idea why. It just gave me a bunch of error messages and no pictures. I swapped it for an older Logitech model (with some strange picture artefacts, but hey… it works).

Image from motion

Image from motion

In motion you can set the numbers of pixels that have to change between each picture to use as motion detection. Further you can run a web service where you can access the picture(s). This seems more suited for my needs, no fancy stuff!

Video surveillance in Linux with a webcam

The latest project I have at home is to get some sort of video surveillance up and running. I have a Logitech webcam and thought I’d give it a go.

To start with I connected the camera to my Mac server via USB and used USB passthrough to connect it to a virtual machine running Ubuntu 10.04 LTS. This was pretty straight forward and didn’t take long time.

The next step is to install some kind of surveillance software. I chose Zoneminder. It has video monitoring, motion detection, recording, etc. In Ubuntu it was just a matter of apt-get install zoneminder and then linking the config file from /etc/zm/apache.conf to /etc/apache2/conf.d/zm.conf. The last step was to start Apache and Zoneminder.

I'm testing the surveillance system

I'm testing the surveillance system

Are there any problems with this setup? Oh yes. I haven’t figured out how to tune the motion detection, it pretty much triggers on nothing. It also uses a LOT of CPU. My play is to find some other program (simple, console, any ideas?) and hopefully get things working they way I want them to.