Closed cse0616 closed 3 years ago
CX and CY are the pupil's coordinates. The end_poiints represent the bounding box coordinates of the eye.
x_ratio and y_ratio would hence represent how far they are from the centre as can be seen by the formula. If pupil is exactly at center they would be 1. For left x_ratio would go less than 1 and for right greater than 1.
If do not lie within the threshold of 0.33 and 3 that means they are not looking straight. These values were manually taken and divine the eye into six portions with the last ones being the target ones. There was no exact special reason to them, it's just it performed well while testing, however you can set what you like.
def find_eyeball_position(end_points, cx, cy): """Find and return the eyeball positions, i.e. left or right or top or normal""" x_ratio = (end_points[0] - cx) / (cx - end_points[2]) y_ratio = (cy - end_points[1]) / (end_points[3] - cy) print(x_ratio, cx, cy) if x_ratio > 3: return 1 elif x_ratio < 0.33: return 2 elif y_ratio < 0.33: return 3 else: return 0
=========================================== Hi Your code is very helpful for me, but I am stuck with a problem.
Thank you so much.