Saturday, August 11, 2012

Low Cost CCTV Solution

Over the past several months, I have implemented and refined a home-security system built around the open source application, ZoneMinder. It started with a fairly simple requirement: being able to investigate any alerts generated by our ADT monitored alarm system.

The Software

  • Ubuntu - I opted for this distro because there was the potential for the system to double as a media centre. I honestly believe that Canonical have done a great job making a Linux distribution for everyone to use and I wanted to make sure any non-techies using the machine wouldn't be (completely) lost!
  • ZoneMinder - after installing Ubuntu, installing ZoneMinder was a breeze; it's available via the standard package repositories.
  • MySQL - required for ZoneMinder's database. Installing the application via apt meant that this was installed and the relevant DB creation was taken care of automatically.
  • Apache - required for ZoneMinder's web interface. Again, this was automatically installed an configured as part of the apt installation routine.

The Hardware

  • Samsung X60 - I bought this machine back in 2005 (my first laptop purchase) and for a couple of years it was my primary machine for work and gaming. However, it soon became obsolete and was added to a pile of spares. I set up the laptop underneath the TV in our lounge, using the docking station I had purchased with the machine. This meant I could connect the machine to the TV, which prompted the choice of Ubuntu as the OS (see above).
  • Logitech Quickcam 4000 - this device was directed towards the centre of the living room. Not only did this provide ZoneMinder with a great view over the main thoroughfare of the house, but when not monitoring the room the camera could be used by Skype, turning the sofa into a comfy video-calling booth.
  • Logitech QuickCam Express - I positioned this to face the rear of the house; covering the back door.

With the system installed and configured and both of the cameras in place, I had a view over most the lower floor of our home. However, this was only the start; I had previously considered using a smartphone as a wifi-enabled network webcam, and I thought it would be perfect if I could hook one up to the ZoneMinder server. Sure enough, after a bit of searching online, I came across a guide on Google+ for re-purposing an Android smartphone as a remotely accessible camera, by simply serving the camera feed over HTTP. The only caveat: the software (IP Webcam) required the device be running Android 2.2 (Froyo) or higher. The two devices I had earmarked for use were an old T-Mobile G1/HTC Dream and a HTC Hero, which were only officially upgraded to 1.6 (Donut) and 2.1 (Eclair) respectively. To get around this issue I simply installed the most stable version of Cyanogenmod for both devices, Cyanogenmod 6 (Android 2.2/Froyo) on the G1/Dream and Cyanogenmod 7 (Android 2.3/Gingerbread) on the Hero.

Using the remote monitor feature in ZoneMinder, I was quickly able to configure both devices as wifi cameras and I positioned them in windows to cover the front and rear exterior of the property. With all the cameras in place, it was possible to fine-tune ZoneMinder's configuration:

  • Monitor Calibration - to ensure a negligible number of false alarms, I found I had to adjust the sensitivity of the monitors/cameras and set "preclusive" zones; a region whereby any detected motion negates any potential alarms from being fired. This was mainly to compensate for changes in lighting conditions (when the Sun is obscured by a cloud, for example).
  • Secure Remote Access - using port forwarding on my home router, and configuring Apache to serve the ZoneMinder control panel over HTTPS, I was able to view the monitors when outside of the house.
  • Emailing Alerts - having ZoneMinder generate email alerts should certain conditions be met (enough alarms being triggered, for example).

One final step I took to improve the remote viewing capabilities of my Android phone was to install the Lite version of IP Camera Viewer. This little app allows you to set up multiple camera feeds (not just those of ZoneAlarm) to view on your phone. You are able to view each feed independently, or as a matrix/grid. While it doesn't react to any of ZoneMinders alarms, it does provide a really quick and easy way to check up on home should an alert be received.