Ubuntu USB webcam server using Motion


Motion is an open source webcam server for Linux operating systems. This software allows you to capture images from a camera connected to computer or server. Motion has many features that make it very versatile. You can set up your webcam server to take a picture every specified interval of time. You can also configure Motion to only take pictures when motion is detected. Motion can handle as many cameras as you need it to (within the reasonable limits of your server that is). If you connect your camera via USB 1 inputs they will only handle one camera. Cameras connected via USB 2 inputs may allow you to connect several cameras using a divider.

For my webcam server that I run on the robot I set it up so that the server continuously captures an image and overwrites the same file every time.

The first thing that you will need to do is prep your computer to compile the source code for motion.

Here you can download the tar package for Motion.
Or if you want to set this up the way that I did you can download my code from here.


Then extract the file to a directory such as /usr/local

cd /usr/localtar -xvzf /path/to/motion-3.2.X.tar.gz

Before you compile the code be sure to have build essential installed:

sudo apt-get install build-essential

You will now have created a directory called motion-3.2

Now change to the new directory

cd motion

Run configure. You can start with the defaults. If you need to modify the installation parameters you can read the next section.

./configure

Build the code

make

Install the code

make install

Replace the motion.conf, thread1.conf, thread2.conf located in /etc/motion/ with the ones that I have included in my zip file download.

To start motion open terminal and type:

sudo motion

To add Motion to startup automatically start with the server, just open “System” from the menu bar on the top of the screen, then “Preferences,” then “Sessions.” Create a new startup program type in a name for it and then type motion in the command section. Click“OK.” Then restart the server.

If you are modifying the motion.conf or thread.conf files you will have to restart motion after you make a change to them. To do this you can restart the computer or use the following command:

sudo /etc/init.d/motion restart

Also, if you only have more than a single webcam you will need one thread.conf file. For each additional camera that you use you will need to add another thread.conf file (thread1.conf, thread2.conf, thread3.conf) You will also need to add the links to these files at end of the motion.conf file.

More information about Motion:
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamServer
http://manpages.ubuntu.com/manpages/precise/man1/motion.1.html

Troubleshooting your cam:
http://askubuntu.com/questions/57314/logitech-webcam-pro-9000-only-works-when-motion-is-run-as-root

Update: The following shoes the only changes that I currently have made to my Motion.config files:

target_dir /var/www/
snapshot_filename image
jpeg_filename image

2 comments:

  1. Ubuntu! Awesome, Im going to get linux ubuntu soon!

    ReplyDelete
  2. These function on Linux Ubuntu is amazing and extremely superb. I really have no idea about these motion function that comes in Linux. It's really awesome and these one is an wonderful and very informative sharing.

    remote desktop connection

    ReplyDelete