Motion Dectection with Logitech Quickcam on OpenSUSE 11.1

If you have a webcam or other type of camera that you would like to setup as a motion dectection camera there is a great piece of software called Motion you should have a look at. It supports capturing from multiple camers, adding text on images, converting to video/swf, and an experimental tracking option.
For the rest of this guide I am going to assume that you have a working webcam. If you are using opensuse there is some great information on the openSUSE Wiki site on how to accomplish this.

The remainder of this guide will be specific for openSUSE 11.1 but it should be applicable to most others. The first thing we need to do is download some source code:

  1. Motion Source Code
  2. Motion Compatible FFMpeg Source Code - While you may have ffmpeg installed it likely will not work as expected with motion. Trust me, this version of ffmpeg will work

Now that you have the source code let's get to work. The first step is to compile ffmpeg for our use. You will see that I am putting ffmepg into it's only special location so as to not interfere with existing ffmpeg implementations.

  1. tar -xzf ffmpeg-*.tar.gz
  2. cd ffmpeg
  3. ./configure --enable-shared --prefix=/opt/motion-ffmpeg
  4. make
  5. make install

Now let's get motion installed. You will need to have several different packages installed. I would recommend just running the configure command and it will tell you what is missing. The db parts are optional but I would recommend at least having one of them (ie: mysql). Also, remember that you need the -devel packages as well.

  1. tar -xzf motion-3.x.x.tar.gz
  2. cd motion-3.x.x
  3. ./configure --with-ffmpeg=/opt/motion-ffmpeg --prefix=/usr --sysconfdir=/etc
  4. make
  5. make install

Now we are almost ready to go. If you need an init script. Here is the one that I use: motion. Please note that I have some custom uvcdynctrl commands to turn off the LED and to reset the position of the webcam. The final step before we run motion is to edit the conf file. Based on the configure options given above, the conf file will be located in /etc/. Let's copy the default conf file to the appropriate name:

cp /etc/motion-dist.conf /etc/motion.conf

Also, if you want to set up an rc link to motion do the following:

ln -s /etc/init.d/motion /usr/sbin/rcmotion

The changes that I have made are listed below. Please read the the Motion User Guide and the conf file to make your own adjustements.

norm 1
width 960
height 720
framerate 100
text_left FIP327 %t
text_double on
target_dir /srv/motion/cam1

Finally, if you want to run this through cron here is what I did. In my case I wanted it to start at 5:30 pm and then stop the following morning at 8:30 am.

30 17 * * * /usr/sbin/rcmotion start > /dev/null
30 8 * * * /usr/sbin/rcmotion stop > /dev/null

Now you are ready to give it a go: /etc/init.d/motion start

Enjoy!

Leave a Reply