Tracking a mouse cursor

Motion sensors have been commonplace in user interfaces for a long time. A computer's mouse senses its own motion relative to a surface such as a table. The mouse is a real, physical object, so it is reasonable to apply the laws of motion in order to predict changes in mouse coordinates. We are going to do exactly this as a demo of the Kalman filter.

Our demo will implement the following sequence of operations:

  1. Start by initializing a black image and a Kalman filter. Show the black image in a window.
  2. Every time the windowed application processes input events, use the Kalman filter to predict the mouse's position. Then, correct the Kalman filter's model based on the actual mouse coordinates. On top of the black image, ...

Get Learning OpenCV 4 Computer Vision with Python 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.