Hi, I am currently doing a project on Eye tracking via internet camera, however, I am almost a newbie to C++. (The last time I touched it was abt 7-8 yrs ago) I am able to track the eyeball using the CAMShift program, but I will need to determine the direction and distance the eyeball moved from its last location. Appreciate if the experts here can help. Thks.
If you know the previous position then you can calculate both, e.g. if old position was 10,10 and new position is 20,20, then it's moved 10*sqrt(2) units north-east. The distance is calculated with Pythagoras: sqrt( (newx-oldx)^2 + (newy-oldy)^2 ) and the direction can be worked out either with triangle geometry (watch out for dividing by zero!) or subtracting new from old and checking if the result is negative, zero or positive. Essentially this is nothing more than a rectangular to polar conversion: x,y -> r,theta.