Python is a dynamic, flexible and object-oriented programming language with a low learning curve which means that anyone with little programming knowledge can develop applications using Python in a short time.
For the last 3 years Python has been my favourite programming language and the fact that OpenCV offers python bindings helped me to erase any doubt of using it. But, there were a few more things to consider before choosing Python definitely. One of them is the OpenCV hardware requirements. To keep track of the reference points it is necessary to continuously scan and process the new frames captured and this is performed with the OpenCV library.
Although I prefer Python, I was considering writing MouseTrap in C because OpenCV is written in C and the hardware requirements of MouseTrap could increase using Python bindings of the library. After executing some tests with both languages I saw the requirements were almost the same in both cases so I made my decision to use Python.
MouseTrap process the captured frames and calculates the reference points using OpenCV and following these steps:
- Get the current frame
- Detect the eyes region using the Haar Training method.
- Calculate the forehead point using the coordinates of the eyes region and distance formulas.
- Calculate the Optical Flow of the detected point using the Lucas-Kanade method to keep its track.
Depending on the selected movement method, MouseTrap will execute different calculations to get the new position if the mouse should be moved.