Turn your webcam into a security camera in Linux
If you have a webcam sitting around, a great alternative use for it is to turn it into a security camera. Having a security camera in your house, office, or apartment can provide numerous benefits. This guide is for beginners who have no experience in setting up webcam security cameras. I will show you how to turn your webcam into a security camera using GNOME.
The first step is to make sure you camera is detected. Go to System >> Administration >> System Log. In System Log go to Open and choose “messages.” At the bottom of the log make sure you see an entry related to your webcam. My log is shown below:
The second step is to install motion. You can download the package appropriate for your distribution from the motion web site. Alternatively, Motion is in most repositories so you can install it using apt-get install motion.
The third step is to actually fire up Motion. Motion runs from the terminal. Open a terminal and type motion to get started. What’s nice about Motion is that it only records movement. Run your hand in front of your webcam so that motion will record some images. Press CTRL+C in the terminal to stop motion.
Now, navigate to /tmp directory and you will see the timestamped images captured by Motion. See below:
However, saving files to the /tmp directory is not very helpful. You can change this directory by going into the /etc/motion/motion.conf and changing the line that says target_dir /tmp to a directory of your choice.
Also, it is not very helpful to have these images saved to your local hard drive because if someone broke into your home they would probably steal the computer that has the images on it. Therefore, we will set Motion to save the images to an external server via FTP.
In order to do this you need to install wput. Wput is widely available in the repositories and can be installed using apt-get install wput. After you install wput, add the following line at the end of the /etc/motion/motion.conf file:
on_picture_save wput ftp://username:password@yourserver %f
The %f is added at the end of the file to upload each picture as it is taken. Motion is a very handy tool and can also record full movies instead of pictures (which I demonstrated). Please see the configuration options at the Motion homepage to learn about the many other things you can do with Motion.
Does anyone know a better way to do this in Linux? Please tell us your way in the comments. Check back tomorrow and I will write a similar post for Windows XP users.