|
13 years ago 7 |
Did you know you can turn your Linux box into a security camera recorder or use it to record pictures of wild animals in camera traps? All you need is a simple webcam, but make sure it is weather proof if it is to be sited out of doors.
The program that undertakes this useful function on your Linux Box is called “motion” and can be installed from the Linux Mint Repositories. Unfortunately there is no GUI for motion but I hope this simple Guide will help you get going.
First of all, in your home directory (/home/<yourname>/) create a new directory called something like... /webcam (you can call it whatever you like, just ensure you include it in the configuration file). This new directory can be easily created in Nautilus by Right Clicking in your home directory and selecting create new directory then renaming it.
Now we need to create a configuration file for motion, called motion.config and saving it to the root of you home directory (/home/<yourname>/). The easiest way to start this process is to start gedit from the Mint Menu and copy the following into it:-
target_dir /home/ray/webcam
jpeg_filename %v-%Y%m%d%H%M%S-%q
width 640
height 480
auto_brightness on
threshold 6000
noise_tune on
minimum_motion_frames 2
framerate 2
gap 2
webcam_quality 100
quality 80
This file is then saved into the root of your home directory, in my case /home/ray/...
It is good policy, as you develop your motion.config file to keep the previous version as a backup file by renaming it motion.bak before saving the new version.
Below is a list of the commands used in my configuration file and details about them.
Command |
Values |
Details |
target_dir |
Values: Max 4095 characters Default: Not defined = current working directory |
Target directory for picture and movie files. |
jpeg_filename |
Values: Max 4095 characters Default: %v-%Y%m%d%H%M%S-%q |
File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. |
width |
Values: Device Dependent Default: 352 |
The width in pixels of each frame. Valid range is camera dependent. |
height |
Values: Device Dependent Default: 288 |
The height of each frame in pixels. |
auto_brightness |
Values: on, off Default: off |
Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness |
threshold |
Values: 1 - 2147483647 Default: 1500 |
Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. |
noise_tune |
Values: on, off Default: on |
Activates the automatic tuning of noise level. |
minimum_motion_frames |
Values: 1 - 1000s Default: 1 |
Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. |
framerate |
Values: 2 - 100 Default: 100 (no limit) |
Maximum number of frames to be captured from the camera per second. |
gap |
Values: 0 - 2147483647 Default: 60 |
Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. |
webcam_quality |
Values: 1 - 100 Default: 50 |
Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. |
quality |
Values: 1 - 100 Default: 75 |
The quality for the jpeg images in percent. |
A complete range of options can be found at the Developers website:
http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigFileOptions
From here you can also navigate to other parts of his site to discover more about motion.
To start motion, start the Terminal and simply type in "motion". You will then see the dialogue begin to roll until it waits for your first picture.
To stop motion, you can either turn off your computer or, start the System Monitor and right click on its listing in the current Processes and select END.
I have been playing about with motion for about a week now, using a cheap Logitech Web Cam looking out of the window and has generated many thousands of pictures. The biggest problem has been in the effects of wind and shade causing false events to be recorded and has been overcome, to some extent, using the threshold configuration command. I'm sure interior shots will not suffer from these problems.
Happy Spying!
And now you can look at Automatically store files on a remote server by trollboy should you find a use for this tutorial.
Nice one! Thanks.
Thanks @trollboy. Yes this is a wonderful extension to the above. What I was looking to do is automate the manipulation of all these files as Nautilus slows right the way down with the thousands of pictures that can be generated every day and your tutorial "Automatically store files on a remote server" looks to be a good start.
Nice tutorial. I may have to get a webcam as I now know how to set up motion activation ^_^
Have a look also at Automatically store files on a remote server which was inspired by this.