SourceForge Logo

Sourceforge project site

Freshmeat project site

Visual Motion Detection

This is a little project, I, Corvus V Corax (Eric Noack), started on 11.25.2002, in a hurry, and then somehow started to be stuck on it ;-)

current version is motiontrack-0.1.3
motiontrack now supports multi processing
( compile with --enable-cluster )
to run faster on smp machines, servers with more than one cpu, or openmosix like clusters.
Execute any executable with -j <number of processes to spawn> to set process number
This option will just have no effect when compiled without cluster support, but not break execution, to make your scripts safe (however older versions of motiontrack will not know -j

So what is it?

Motiontrack is a set of executables which can be used to detect motions of objects between 2 images, by comparing them pixelwise, or check whether 2 images show the same or not.

Motiontrack is a backend tool, to use in your own scripts, together with other tools to get the images from a webcam, like v4lctl, an apache server to host them, ...

Motiontrack is no all around motiontracking kill'em'all program that does everything from grabbing the video input to web-serving it ...
if you look for this, better check out motion

What will it be?

Future plans are to be able to recognize the objects that are or have been moving with these tools. Early pattern detection has just been implemented to some ASCII art conversion, and to auto-align images.
Future versions might be able to interpret groups of simple geometric patterns (arcs, circles, lines of different angle and width, ..., detected with such routine or its successor) as objects, and identify them, if trained accordingly (neural net programming and such)

What is this good for?

If u use a webcam to scan a specific area, for example, and you want to save the pictures which show something or someone going on, and delete the images with no action, or if you want to check if you should start recording a movie showing an intruder robbing your house, without having to record 24/7 and wasting disk space with dumb data, this is what u want.
Just take 2 images with a delay of 1 second, every now and then, and check them for any changes between them. If there are any, you have action and should take measures, if not just delete the identical images and keep idling.
The problem is, that just comparing the images pixel for pixel always will result in some changes, since light is an analogue data source, and you always will have some flicker, clutter, snow storm, what ever, which creates changes in the image files.
So u have to check wheather your movement was a real object in sight moving, or just random pixel changes
Specially with low quality data this might get difficult. So u need a good program to check this for you:
... motiontrack ...

! Please don't use this software to help monitor places   !
! where it impairs the privacy of other people, like      !
! monitoring public places and streets, CCTV, voyeurism...!
! -- against total surveillance!  !


How can i use it

You can find documentation here

What do i need?

You currently need either a working version of libgd, or ImageMagick installed on your system.
You will compile this under Unix or Linux, which meens you have to be used to the usual configure, make, make install sequence, which means that you need something like the gcc C Compiler (mac OS CC works, too), Gnu make, and the other usual stuff.

If ./configure doesnt work like you want, build a new one with ./ (need's autoconf, automake and that stuff)

./configure now provides the --with-searchdirs=<DIR>:<DIR>:... option, to specify additional prefixes where your libs might be installed.
Also you can use standard ENV variables like CFLAGS, CPPFLAGS, C_INCLUDE_PATH, ... to help it

Ah yes. You need a webcam, and a method to get some images from it. I use v4lctl for this. (comes with XawTV)

What License is it?

Guess what? GPL of course! Version 2 or above.

Who did it?

Motiontrack? Me. Thats

Corvus V Corax.
aka Eric Noack

And where the hell can i get it?

Oh darn. i almost forgot:


here it is ! the sources :)) If you want an rpm, make one and give me ;)

Sourceforge cvs frontend to really actual sources is here

Anon CVS Server access via cvs -z3 co motion

NEW: As per request of some guy in alt.ascii-art: experimental stage windows binaries - not thoroughly tested, use at own risk
MD5sum: a8ef1726b3dddc8d45f3b3b2ce9fba1d

Can i have some screenshots how it works?

Yes of course here they are:

These are 2 images taken with my real low quality webcam of me moving my hand, and a lot of background clutter
(This is an incomplete process, motiontrack can do more meanwhile, but what would be the fun of it if you dont try youself?)


Now i run mdiffer webcam1.jpg webcam2.jpg diffs.jpg


Now i run menhance diffs.jpg enh.jpg

And finally i run msectors enh.jpg sectors.jpg

Console output of sectors is :

This program is free software created and to be distributed under the GPL!
The Authors or distributors provide NO WARRANTY for anything!
You should have recieved and read a copy of the GPL v2 or higher!

   ! Please don't use this software to help monitor places   !
   ! where it impairs the privacy of other people, like      !
   ! monitoring public places and streets, CCTV, voyeurism...!
   ! -- against total surveillance!  !

Printing sectorlist:

Overall sector count:


11,4:85 13,4:69 11,5:62 11,6:68 17,6:80 18,6:71 11,7:61 17,7:84


Where only the "8" and the x,y:f goes to stdout and the rest goes to stderr
The 8 meens that only 8 sectors in sectors.jpg are more than 20%+25 brighter than the average sector!
But this is enough!
Without movement, no matter how bad the quality is, we have only random move-data, and no sector ever reaches more than 120%+25 average brightness
any value over 0, no matter how small meens we have movement. for sure :))

IMPORTANT:Depending on your version of motiontrack, libGD or ImageMagick, you run the process in one shot via "motiontrack", or in single steps with in-between images, and not-loss-free compression algos like in jpg, the amount of "motionsecors" and their position can vary even with the same source images. If you want to check if your local compilation of motiontrack works, trust your eyes by watching the images created by the different process steps (here: diffs.jpg , enh.jpg and sectors.jpg)! They should look like the one you find here, but they wont be identical i guess. Some older versions of libPNG and libGD on some distributions had bugs and such you might get random or garbage images instead, but you will notice that, when you compare them to those here. This is a little confusing but i cant do much about it, sorry.
If that bug happens upgrade to the latest librarys.

What if i want help developing, is there any code documentation?

There is some. Right in the header files there are short function descriptions.
But for a whole project overview you should first read TheCode.txt!