Getting Coordinate of Mouse Clicks in Linux
Here is an update to the previous post. Continuing my project on making a self adjusting eye tracker with a webcam, I need to get the coordinates from mouse clicks some how. This is because I do not want to use a 'calibration screen' to get the relative position of the user and the webcam. As the user shifts their heads the calibration will immediately be off. As a result, it seems more sensible if the 'calibration' was the user's mouse clicks. Users click throughout using a computer and it is likely that when the user is clicking, they are also looking where they are clicking. Therefore, the system will automatically calibrate it self with each click by continuously adjusting the known relative position of the user and the webcam on each new click. Getting the coordinates of mouse clicks was actually pretty easy (xdotool). Getting an event when the mouse was click was hard. I saw many 'solutions' online with libraries like pygame and Xlib (I think I know why it didn't work) but they didn't seem to work. I finally came across PyUserInput which seems to work. This is specifically for Python 2.7 running in Linux (Ubuntu). PyUserInput easily allows you to detect when a mouse click occurs anywhere. It actually uses Xlib (which I thought didn't work earlier). The issue though is that version 15rc of Xlib doesn't work and gives and error message. On the other hand, using version 14 of Xlib worked perfectly...so that was an interesting snag. The code looks something like this: (pymouse is part of PyUserInput) To actually get the location of the mouse, the good ol' xdotool saves the day. Simply use xdotool getmouselocation and it will output in bash. Of course I will be calling it through python and getting the variables. The next step will be taking data of the head, eyes and click data and hopefully finding some sort of modeling/training method to make this possible. *Also, I will not be doing head tracking since last time I said it was too slow. Instead, I will use the eye tracking boxes to track the head. To get the eye gaze location or pupil location, I will image process the data within the eye box. Doing this will give my actual gaze and head location data. (pupil tracking now here!)














