GazeTracking
GazeTracking copied to clipboard
recognition not accurate
In the original code, the recognition of blinking when looking to the right or in the middle is not accurate, mainly due to poor proportional positioning. The parameters for looking to the left and right are symmetrical, making it difficult to recognize when looking to the middle. In reality, the performance is poor. Using the following code to modify the judgment of proportion can achieve better results (which has been tested locally)
def look_right(self): """Returns true if the user is looking to the right""" if self.pupils_located: return self.get_horizontal_ratio() <= 0.45
def look_left(self):
"""Returns true if the user is looking to the left"""
if self.pupils_located:
return self.get_horizontal_ratio() >= 0.8
def look_center(self):
"""Returns true if the user is looking to the center"""
if self.pupils_located:
return self.look_right() is not True and self.look_left() is not True
def look_down(self):
"""Returns true if the user closes his eyes"""
if self.pupils_located:
blinking_ratio = (self.eye_left.blinking + self.eye_right.blinking) / 2
return blinking_ratio > 5