In this post I will show you how to create a cheap CCTV system that uploads to the cloud.
After moving my office into my garage I found I needed such a system so I built one & thought I’d share my newly found knowledge with you all.
My new CCTV system takes images from 2 cameras, 1 mounted outside the garage and a webcam inside the garage. It then records both images and videos and immediately uploads them to the cloud in case the computer which is collecting the information is itself stolen.
I would suggest that if you do not already have a card installed you choose one that is compatible with one of the various TV/PVR software libraries such as MythTV. MythTV has a good guide when it comes to choosing a card and is a good starting point if you are a beginner. The video card that use is a Compro S350 that accepts RCA video connections. This is the video connection that my camera has so I was in luck with this stage of the process.
First of all you need to put the camera in the correct place for the area you want to monitor. For me this was just above my garage door. I set it up so that the view-point of the camera can monitor the shared double drive that our neighbours and us share. The view extends over the road and onto the opposite houses (luckily they are town houses and the bottom floor is a front-door and a garage only).
The wires from this camera go inside the garage and are routed to the back of my Computer where they go into the video card (that I already had installed for Freesat).
Next is the webcam. The webcam’s job is to grab any images of intruders that actually get past the first line of defence, and then upload as many images of the intruders to the cloud for later use if needed.
With the webcam set up so that it faces the garage/office door I have maximised the chances of capturing images of any intruders and uploading them to the cloud before the computer is possibly unplugged and stolen.
Before we install the camera monitoring software we need to make sure that the cameras themselves are working and we know which camera relates to which input.
In VLC, right click on the blank area of the window and select “Open capture device”, you will then be presented with the below box. I am typing this post on my laptop so I only have one input but if all is well you should see at least two inputs.
All you have to do is cycle through the video inputs and take a note of which video input is assigned to which camera.
The ideal software for this project is Motion. This is a brilliant, not to mention free piece of software that allows you to control not only the cameras but the detection status as well as the quality and the interval etc.
For Ubuntu users like me this is simple. You just install it via Software Centre. For other users you will need to follow the instructions that are given on the Motion website.
Once it’s installed you will need to configure it. It is pretty much configured for one camera already.
By default it is located at /etc/motion/ If you have a camera and a webcam you will need three files
All the generic options are placed in motion.conf and all camera specific options go in the particular thread files. The Motion website has good documentation on all of the config options.
In this example I shall be using the Google Doc CLI. We will be using this facility along with the on_picture_save config option. This will allow us to upload images to our Google Docs/Drive accounts as soon as they are taken by motion. This way, if an intruder gets past your other lines of defence and steals your computer you should have plenty of images already in the cloud and safe for future use.
The Google CLI Downloads page has loads of options and as an Ubuntu user I’m very pleased to see a .deb file for each release.
The first time you use the service you will have to authorise the computer you are on to use your Google Account. It makes sense therefore that we do this early. The format of the CLI input is
Google <Service> <command>
. So to authorise your computer just try to list the contents of your Google Drive with
Google docs list
You will then be asked to enter your Google username. Make sure you enter the full email address that you are registered with. Once you enter your username you will be presented with an interface that will give you an authorisation code to enter back into the command line. Enter the code in the command line and Bob’s your Uncle; Fannie’s your Aunt (that good).
We also need to make sure that we upload to the correct folder. The CLI does not take a hierarchical folder structure; it simply takes the name of the directory that you wish to upload to. That means that you need to make sure that you have a directory with a unique name to upload your media content to.
sudo gedit /etc/motion/motion.conf
Find the line that says
Now change it to
on_image_save Google docs upload %f <upload_directory>
for example to upload to the CCTV folder I use
on_image_save Google docs upload %f CCTV
The %f bit is a motion shortcut for the filename. you can change the format of the filename in the motion.conf file
You may be wondering how I have my motion configured.
I have my video files set at 25 frames per second on both cameras with 100% image quality (I’m looking at reducing this though).
I have the external camera set to take 1 shot per video. This is the option that detects the most pixels changed and uses this as the image/thumbnail. On the webcam I want as many shots as I can get of any intruders so as well as the video file each and every frame is saved to a separate file/image (and uploaded).
If you’ve configured motion properly you should be able to fire up http://localhost:8081 and get one camera…
…and change to http://localhost:8082 and get the next camera (your camera order may not be the same as mine).
There are a few things that we still need to consider:
Unless you have massive amounts of [hard drive] space to use you will be needing some sort of system to manage how much media you store. There are several options:
I am currently in the process of creating a CMS for my CCTV system which will allow such options and once the system is complete I will probably be releasing it for beta testing.
I have found that one of the biggest pains of the current system is having to manually start and stop detection. Again there are several options.
That’s it: I have left out the configuration details for motion as every system is different and you may not want your system set up the way I have but with a cup full of technical know-how & a bag full of enthusiasm it isn’t too difficult to create a cheap CCTV system that uploads to the cloud. You can make it quite configurable and suit it to your own needs. There’s nothing saying that you cannot extend this to a whole array of uses included live webcam streaming etc (which is one of the features I have already implemented in the CMS that I am creating).