Skip navigation

Ever wanted to be able to check in on your house while you were away?  is a piece of open source software that enables your webcams, that you may have laying around the house, work as motion detectors. Motion should run on most linux distributions but for this tutorial, I’m using the desktop version of  linux.

Requirements

  • PC with Ubuntu installed
  • USB webcam(s)
  • 30-90 minutes of free time

Step One

Okay lets start off by downloading the linux driver for your webcam. This great man wrote a single driver that is compatible with about 260 different webcams! You can download it here, to your desktop preferably. If this driver does not work for your camera please search  for the right driver.

Once you’ve downloaded the driver we can start compiling it, but first make sure you have the package build-essential installed you can do so by typing in sudo apt-get install build-essential into the terminal, information on this package can be located here.

Build-essential

We are now ready to start compiling the source code for the driver. Once we extract the .tar.gz file by right-clicking on it and selecting Extract Here. This should take a few seconds to complete.

Then open up terminal again and type in cd ~/Desktop/gspcav1-20071224, then type ./configure, this should take a minute or two (don’t worry if this gives out errors, just precede to compiling).

After that, start compiling it by typing in make. After it’s been compiled you can install it by typing in sudo make install this will install the package. You should now have a webcam that is recognized by linux now!

Step Two

Ubuntu has added Motion to the repository so it is now super easy to install (no compiling required). All you need to do to install Motion is, type sudo apt-get install motion in the command line.

sudo apt-get install motion

Step Three

It’s now time to setup Motion’s configuration files. You can download my config files that I’ve already filled in; here (read through the entire motion.conf file and change the settings to fit your needs).

Put the files in the Motion Config.zip file in your /etc/motion/ folder on your server by first extracting the files onto the desktop, then typing sudo mv ~/Desktop/Motion Config.zip_FILES /etc/motion/ into the terminal.

sudo mv motion config

Please note: that if you have more than one webcam you will need one thread.conf for each extra cam (example; thread0.conf, thread1.conf, thread2.conf) You will also need to add the links to these files at end of the motion.conf file.

Step Four (optional)

Wput is a command line FTP client that allows you to upload security photos to a remote FTP server. To install this type sudo apt-get install wput into the terminal. We can configure Motion to use wput to upload photos that have been taken by adding

# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)# The filename of the picture is appended as an argument for the command.on_picture_save wput ftp://USERNAME:PASSWORD@REMOTE SERVER %f

to your motion.conf file (if your using the motion.conf I provided this is already in there, just replace the server info in the ftp:// section)

Step Five

Lets make Motion startup automatically with the computer. Open “System” from the menu bar on the top of the screen, then “Preferences,” and “Sessions.” Create a new startup program type in a name for it and then type motion in the command section. Click “OK.” You can now restart the computer.

Motion Autostart

Configuration

If you need more information about getting Motion running visit; here. There is also a ton of configuration options. From taking movies instead of photos, to launching a script when motion is detected; here. A wonderful person by the name of Morgan Storey has made a few scripts available, to automate the mundane process of activating motion when you leave (via screensaver) and help clean up after Motion (deleting old security photos locally and over FTP). Here are the scripts if you would like to use them.

Conclusion

You should now be able to open a web interface for Motion now by typing in localhost:8000 from the server itself or XXX.XXX.X.XXX:8000 from another computers web browser. To view a live stream of your webcam type localhost:8001 from the server itself or XXX.XXX.X.XXX:8001 from another computers web browser. You can change settings from this interface here too, you can even make Motion generate it’s own config files to fit your setup exactly!

Enjoy your new home-brew security system! All thanks to  and all the other great open source developers. Keep up the great work!

4 Comments

    • Bob
    • Posted April 12, 2008 at 11:25 am
    • Permalink

    Very nice tutorial! Worked perfect for me. Thanks!

    • Brent
    • Posted March 10, 2009 at 12:38 am
    • Permalink

    Question from a noob playing w/ Linux:

    What exactly should I fill in to the address that you list as XXX.XXX.X.XX ? And how can I get that address?

    • Dave
    • Posted April 21, 2009 at 4:39 am
    • Permalink

    @Brent: The address you need will be the one of your router. To get it, you can look at the router configuration information – this depends on what router you use. Of course, it’s not that simple though. In order to allow incoming connections you would need to set your router to allow connections into your PC. This can be done manually on the router itself, or through uPnP.

    However, don’t just open it up and be happy. There’s security to consider – if you can get in without a password, so can anyone else. Consider adding user authentication on your Apache installation to help.

  1. Hi Brent,

    If you’re still watching this page or haven’t worked out the problem, the XXX represents the
    ‘address of the ‘puter which is connected to the webcame.

    You can find this by opening a terminal and typing

    ifconfig

    this will give you an address like 192.168.1.100

    enter this in the URL window of your browser, followed by :8001

    So it would look like this:

    192.168.1.100:8001

    Hope this helps.


3 Trackbacks/Pingbacks

  1. [...] Deconstructing kdramas and kpop culture — Dramabeans created an interesting post today on How-to Part 1: Cheap Ubuntu-based home securityHere’s a short outline [...]

  2. [...] journey into the magical world of open source software I would like to expand on my home security tutorial. A wonderful person by the name of Morgan Storey has made a few scripts available, to automate [...]

  3. By Andy Regan on 26 Feb 2009 at 9:27 am

    Webcam Motion Detection in Ubuntu Linux…

    I bought a cheap usb webcam to add to the list of devices for my fyp. The idea is to push presence updates when motion is detected. I’ll be using Motion to handle motion detection. Detailed installation and configuration instructions can be fo…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: