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:
Log screenshot

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:
Tmp image

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.

Trackbacks & Pings

Comments

  1. how about zoneminder.
    http://www.zoneminder.com

  2. I found this article (making a webcam into a sercurity camera) very interesting. Could you tell me how to do this using Windows Vista? I want to set the camera up about 100ft away from my computer (to pick up images from outside). Thanks very much!!
    Susan

  3. hi there ,
    all works well on ubuntu . but don’t know due to what reason , after taking a few picture camera stops working. can any one help ?
    thanx.

  4. programa para cameras d vigilancia ;D

    very usefull

  5. how to play mp3 when motion decet motion

  6. well i got it working the directory for me was in my user folder not temp folder and it is vary sensitive i got ubuntu 10.04 so ya

  7. How to make video instead of pictures.
    It saves .jpg and .sfw (flash video) but this one doesn’t open any video.

    I checked the config file but I couldn’t find the option for it.

    Anyone?

    Thanks,
    Koala

  8. My computer wont let me open up the motion.conf file in Notepad or Libre office, it says access denied in Libre and a similar message in notepad. In addition, I cannot delete the photos that have already been taken and now sit in my tmp/motion folder, because it says I’m not the owner. I am the admin on this computer so I dont know how I cant be the owner. Please Help?

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.