Using the code I found at How do I track motion using OpenCV in Python? and http://appdelegateinc.com/blog/2010/08/02/motion-tracking-with-a-webcam/; I can track motion quite well using Python and OpenCV. I modified it slightly so instead of drawing circles on the image, it will print out the (x,y) co-ords of what it detects. Now, this works great for showing the "exact" location of the motion, but I would like to find out the general direction, for example, is it going up or down.
I have an idea, namely once I have a few points, use gnuplot to plot all the y-coords VS number, then calculate a line of best fit. If the gradient is positive then the motion is up, and if it is negative, the motion is down.
While I'm fairly certain this would work, it seems rather "hacky". I'm wondering if there is a better way of doing this, since I'm quite new to OepnCV.