PyAutoGUI .moveTo() 不使用眼动仪数据及时移动光标 - Tobii Pro Fusion 眼动仪

问题描述 投票:0回答:0

总的来说,我是眼动追踪的新手,但我有这个项目需要我使用它。我正在使用 Python 3.10 和 Tobii Pro Fusion 眼动仪。

对于这个项目,我只需要使用我上面提到的眼动仪给出的眼睛数据(屏幕上每只眼睛的坐标 - 可能)来移动光标。现在这一切都是实时发生的几秒钟。

这里是一些代码:

import time
import pyautogui
import tobii-research as tr

screen_w, screen_h = pyautogui.size()

def gaze_data_callback(gaze_data):
  left_x = gaze_data('left_gaze_point_on_display_area')[0] 
  left_y = gaze_data('left_gaze_point_on_display_area')[1]
  pyautogui.moveTo(left_x * screen_w, left_y * screen_h)

while True:
  eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA, gaze_data_callback, as_dictionary=True)
  time.sleep(1)
  my_eyetracker.unsubscribe_from(tr.EYETRACKER_GAZE_DATA, gaze_data_callback)

这有点管用,但有一个非常短的延迟(可能是因为睡眠(1))并且眼动仪不断地打开和关闭,但它不能正常工作。关于如何保持眼动仪开启并仍然保持光标平稳准时移动的任何想法?

我一直在寻找文档,但没有任何东西真正适用于我正在尝试做的事情。另外,我已经尝试了一段时间,并将 time.sleep(1) 更改为 time.sleep(5) 但是光标移动有很大的延迟,有时它根本不跟随并停留在第一个坐标 I看过了。代码:

import time
import pyautogui
import tobii-research as tr

screen_w, screen_h = pyautogui.size()

def gaze_data_callback(gaze_data):
  left_x = gaze_data('left_gaze_point_on_display_area')[0] # gives the x coordinates of left eye
  left_y = gaze_data('left_gaze_point_on_display_area')[1] # gives the y coordinates of left eye
  pyautogui.moveTo(left_x * screen_w, left_y * screen_h)

eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA, gaze_data_callback, as_dictionary=True)
time.sleep(5)
my_eyetracker.unsubscribe_from(tr.EYETRACKER_GAZE_DATA, gaze_data_callback)

有什么办法可以解决这个问题吗?

python python-3.x pyautogui eye-tracking
© www.soinside.com 2019 - 2024. All rights reserved.