Slashdot Mirror


Algorithms for Motion Tracking?

Keith Handy asks: "I seem to be unable to find algorithms and/or open source programs that will do accurate motion tracking, i.e. you mark a point on an object in frame 36, and the program can follow that point on that object through all the frames following it. This is useful not just for analyzing motion, but also for interpolating/extrapolating frames of video -- so if you had something at only 15 fps, you could generate inbetween frames (which are not just crossfades between the frames) and actually smooth the effect of the motion. Not something so complicated as to get into actual physics -- just something that will indicate where (in 2D only) that part of the object has moved from one frame to the next, for any given point in the whole picture. And for that matter it doesn't have to be 100% accurate, just any means of generating a reasonable motion-flow map." This doesn't strike me as an easy algorithm to develop, but are there any papers online or offline, that might describe an algorithm that can at least track objects in an image?

"In other words, I want something that does this, in order to write code that will do things like this and this. I already know how to write code to blur and warp images, so to be able to track motion would give me (and you) the same capabilities as these expensive plug-ins.

Anyone know any other resources, directions, or existing code I could look into to find out more about how this works, so I can incorporate it into my own programming instead of paying hundreds or thousands of dollars for limited, proprietary use of the technology?"

14 of 32 comments (clear)

  1. Book by rm-r · · Score: 5, Informative

    Hmm, not sure about any resources on the net, but I did similar stuff at uni so I can recommend a book. Try Image processing, analysis and machine vision by hlavac et al. It's a very good book with plenty of code-neutral algorithms. Good luck.

    --

    J-aims
    --
    Yo, whatever happened to peas? Join T( H)GS
    1. Re:Book by JabberWokky · · Score: 2
      I'm just tossing in a second for that book - FWIW, I wrote exactly what you're looking for (the intelligent interpolation of frames) in a class that used this book (or the previous edition) as the core text. Good book, good class. If I had the code, I'd toss it to you. Incidently, the frames I used were every other from a sequence of a Star Trek episode (IIRC, it was found via Archie on an MIT ftp site)... which allowed me to go back and compare with the actul frames that I had pulled out and see where the errors were. As a result, I also wrote a few nice vdiff image programs - I'm sure a fm: search will now pull a dozen versions up, but the technique I just described is useful to refine your processing code.

      --
      Evan "Tired, and I'm not gonna rewrite that for easier parsing" E.

      --
      "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
  2. Video compression by cperciva · · Score: 3, Informative

    I think the best use of this would be in video compression -- if you can recognize the movement of objects between frames, you can encode how much things have moved instead of re-encoding the entire image.

    Which is exactly what MPEG does... very crudely. The MPEG solution seems to be to compare a block (8x8?) of pixels with every block in the previous frame.

    The fact that MPEG doesn't use anything more sophisticated than this suggests to me that there probably aren't any algorithms which consistently work better.

    1. Re:Video compression by rm-r · · Score: 2, Informative

      Motion tracking is also useful in military software, ie to find that pesky moving Afghan and point a gun at him. Similar technology is also used in some CCTV systems, but apart from that it doesn't seem to have crossed over into the mainstream much. There's a lot of cool software and ideas out there, much of it in the public domain if not GPL'd exactly so I'm sure it's just waiting for someone with a really good idea...

      --

      J-aims
      --
      Yo, whatever happened to peas? Join T( H)GS
    2. Re:Video compression by rw2 · · Score: 2

      The fact that MPEG doesn't use anything more sophisticated than this suggests to me that there probably aren't any algorithms which consistently work better.

      Not that I know, but it could also be that there aren't any algorithms that work better considering the horsepower available in many devices. There could be many algorithms that work much better assuming a dual Athlon 1900+'s to execute it.

  3. openCV by bjpirt · · Score: 5, Informative

    have a look at openCV (stands for open computer vision), it was originally developed by intel, but was later open souced. runs on both linux and windows and is mainly used for real time motion tracking of live video sources. i'm sure there are some pretty nice algorithms in the source there somewhere. They have their stuff on sourceforge

    and a yahoo groups support forum thing here

    the original intel pages are here
    cheers,
    bjpirt

  4. what about intercorrelation ? by dario_moreno · · Score: 3, Interesting

    Compute the 2D FFT of each frame (in grayscale), then get
    the intercorrelation function of two neighbouring
    frames. The maxima are more or less where
    the objects have moved.

    I only used this method on artificially generated
    frames, ie 1 frame with translation and noise
    added. Still, the intercorrelation sinks quite
    fast. On natural images, there must be a lot
    of fiddling to do.

    --
    Google passes Turing test : see my journal
  5. KLT Feature Tracker by The+Whinger · · Score: 5, Informative

    Have a look at the KLT tracker - that will probably do what you want.

    An implementation can be found here:

    http://vision.stanford.edu/~birch/klt/

  6. tracking motion by Anonymous Coward · · Score: 3, Interesting
    i don't know if this would suit your needs, but a package called "motion" has been available for quite some time which in fact is oriented to tracking frame differences from a video source:

    http://motion.technolust.cx

    there are some examples and a sample video which demonstrate tracking "motion."

  7. MPEG by markj02 · · Score: 2
    If your goal is merely frame interpolation, I suspect that using a decent MPEG2 encoder and interpolating based on the motion compensation would be good enough.

    For other applications (e.g., colorization), you need somewhat better segmentation. Doing this well in the general case is still a research topic; but that's good: you can get lots of research software from around the net that does this sort of thing. Look for keywords like "computer vision", "motion", "segmentation", and "tracking" on Google.

  8. some brainstormed ideas... by eizan · · Score: 2, Interesting

    why don't you try this far-fetched possibility:

    break up the iimage into N x N submatrices, and do a fourier transform on each subsection of the image. then do this for the next frame, and calculate the phase differences between each frame, and use linear/cubic/etc interpolation to generate the frames in between. not too difficult, and I think there is even a 2-D FFT library located somwhere on download.com. this, however might introduce a couple of artifacts, but if you're doing high framerate video, it shouldn't be too noticeable.

    or even more far-fetched:
    assuming that the translation of the objects in the image plane between frames are small and uniform enough, you might also be able to pull this off with a properly trained neural network on subsections of the image (so each individual feature fits approximately in each subsection). neural networks can do non-linear regression, but thier outputs are continuous, so I figure if you train it right, it'll give you what you want.

    good luck :-)

  9. just use the MPEG algorithm by dutky · · Score: 4, Informative
    Other folk have mentioned the MPEG motion compensation algorithm (though I think they got it a bit wrong). The algorithm chops up the current frame into 8x8 pixel block on even block sized boundries (first block at (0,0):(7,7), second block at (0,8):(7,15), and so on). These blocks are then compared against all possible 8x8 pixel blocks, local to the original block, in the adjacent frame (we compare against the blocks shifted by 1, 2, 3, 4, 5, 6, 7, and 8 pixels in both the x and y directions). Essentially, each block is compared against every possible sub block of a 12x12 pixel block centered on the original block's position. The comparisson succeeds if the difference between the two blocks in small enough (this is a threshold that you set).

    Once you have done this for every block in the original frame, you have a set of motion vectors from which you can construct an intermediate frame.

  10. interesting aside by isorox · · Score: 2

    I found the audio commentry on the SG1 dvd for Small Victories facinating, with how they used lasers as points (they later brushed out some), so they could sync the CGI bugs with the moving camera.

    Also, the BBC have something camera based in the works
    http://www.bbc.co.uk/rd/tour/virtualproduction.h tm l

  11. no. Re:Actually... by leuk_he · · Score: 2

    checking the size of a jpg file would not work. maybe an uncompressed jpg file would contain the information. A very small change in the original picture could lead to very much change in the resulting bytes of the jpg file.

    but try seaching for webcam motion detector on google and you will find some useful stuff.