Having a good security lock on your doorstep, if you're often out of the house, is a matter of course, but even the safest security lock can be broken using the right technique or the rough force, and it is therefore appropriate to insure yourself with another layer of security with a tracking layer.
One option is to install a professional security system - cameras, touch sensors, alarm. The security price should always be proportional to the value of the secured property. The dear security system is therefore definitely the right choice for warehouses full of expensive electronics, banks and family homes full of old paintings and jewels after the grandmother. For the average household, the security of a desktop or laptop computer and a simple webcam can be purchased for a few dollars.
There are countless apps running on Linux that allow you to stream video on-line or shoot at regular intervals, and upload your captured images to a Web site via the FTP protocol. A very nice application with many features is WebcamStudio for GNU / Linux. In addition to the classic features, such as online streaming and regular capture, lets you use a connected iPhone or MiniDV as a webcam and many more, an imaginary icing on the cake, it is possible to add information about the currently playing song in Rhytmbox or use some of the many creative filters, but this is far from the subject of this article.
However, because you can not and do not want to spend a whole day watching your home with a webcam or browsing hundreds of pictures, you can use motion detection to create a so-called photopost.
For our purposes, that is, to create a photopost, the Motion program, which is a few of the latest versions of the Ubuntu Linux distribution, is well served in the basic set. If it is not, you can get it with a simple command.
sudo apt-get install motion
To set the motion program, a classic configuration file with the .conf extension is used, for which you create a special directory in the home folder and copy it from the original location using commands
sudo cp /etc/motion/motion.conf ~/.motion/motion.conf
You can then edit it in a text editor such as nano.
sudo nano ~/.motion/motion.conf
Although at first glance the motion program seems to be very simple, it runs without a graphical interface at the command line, the configuration options are really rich. Motion can run in so-called daemon mode, default is set to off if you turn on the daemon mode, so you will write the daemon on the configuration file, the motion will run in the above-mentioned mode and it will start immediately after the system starts.
The Width and Height variables are used to adjust the width and height of the image. It is in pixels and the default value is 320px for both variables.
Framerate, as the name suggests, indicates the recording speed. The value is set in seconds and is set to 2 fps at 2 frames per second.
The Motion detection threshold is very important for moving motion, which indicates how many pixels it needs to change in order to start the photo, in other words, to save the image. The default value is 1500 pixels if you want to have a more sensitive photopast, lower the value of the variable. For our use, however, the value of 1500 pixels is quite sufficient, because we do not want the photopast to trigger any fly that flies in front of the camera.
Another important variable is output_normal. This determines how the capture will take place when you run a photo. The default value is on, which means that the images will be captured throughout the motion at the speed set by the framerate variable described above. The default setting is suitable for us if you do not want to stream the whole video if you run a photo, in which case it would be more accurate to talk about video tracks. Other options are the first, best and center values that limit the number of images stored. If you plan to stream or save a video file, set the value to off.
Finally, the target_dir variable determines to which folder the captured images will be saved. The value is logically the path to the destination folder. It's reasonable to synchronize somewhere automatically (if you're using Dropbox) if someone gets you while you're away, it's likely to steal your photopast, and if you have images stored on your local disk, it does not make sense.
Start the Motion program with the sudo motion command. If everything is set up correctly, snapshots will start appearing in the folder specified by the target_dir variable.
As mentioned above, pictures taken with Motion can be stored in the cloud with Dropbox. Another option is to save images to your own FTP server via the wput program, which you can specify by entering the command
sudo apt-get install wput
In the Motion program configuration file, set the value on_picture_save to
wput ftp://user@password@server %f
Where user, password, and server are the values to connect to your FTP server.
And we get to the final, key part of our entire security system, sending notice if Motion detects some movement. To do this, sendemail will be served by:
sudo apt-get install sendemail
In the Motion configuration file, insert the following lines where you will of course change bold highlighted text to specific values.
on_event_start sendEmail -f YOUR_OUTGOING_ADDRESS@EMAIL -t Q YOUR_INCOMING_ADDRESS@EMAIL -u "SUBJECT" -m "Movement detected!% d% m% Y% H:% M-s smtp.gmail.com:25 -xu YOUR_OUTGOING_ADDRESS@EMAIL - xp EMAIL_PASSWORD
To send a cell phone alert, we will use the e-mail as an SMS. This is a simple trick when using the on_event_start value as the incoming email address of the mail sms gateway (see below), of course, instead of the phone number, we will write your actual phone number, including the international prefix. Bran has a plethora of quantity, always look for the operator's gateway in the country whose network your phone will use. Here is an example of several such gates.