由alea技术开发的intelligaze api的python包装器

python-alea的Python项目详细描述


皮亚利亚

intelligaze api的python包装器由Alea Technologies

C API

alea提供了一个api来与眼睛跟踪器交互。这个api通过com操作,用python包装起来不那么简单。(在技术上可能的情况下,它需要外部包,并跳过几个环。)一个更简单的解决方案是为API引入一个C++包装器,然后将其编译成一个DLL。生成的dll更容易通过python的ctypes访问。

原始api的这个“c api”包装器的源代码包含在这里。

下载并安装

pyalea可以通过python包索引(pypi)获得,并且可以通过pip安装。

pip install python-alea

用法

安装后,可以将alea包导入到python脚本中:

import alea

将数据记录到文件中

然后,您可以使用aleatracker类来快速方便地与您的眼睛跟踪器交互。例如,以下脚本初始化与intelligaze服务器的连接,校准眼睛跟踪器,并将10秒的数据记录到文本文件中。

import time
from alea import AleaTracker

# Initialise the connection to the IntelliGaze Server,
# using the PyGaze alea code.
tracker = AleaTracker("pg=12", file_path="my_data.tsv")

# Calibrate the eye tracker, using the default options.
tracker.calibrate()

# Start recording to file.
tracker.start_recording()
# Log a message to the data file.
tracker.log("recording_started")

# Wait for 10 seconds.
time.sleep(10.0)

# Stop recording.
tracker.stop_recording()

# Close the connection to the eye tracker.
tracker.close()

凝视相关功能的流式采样

你可以使用aleatracker的sample方法来获得相应的凝视坐标,以及当前的瞳孔大小。当连接打开时,这将始终返回最新的可用示例。

注意:使用sample方法不需要录制,使用sample方法不影响录制。您可以同时执行这两项操作,但不必执行。

import time
from alea import AleaTracker

# Initialise the connection to the IntelliGaze Server,
# using the PyGaze alea code.
tracker = AleaTracker("pg=12", file_path="my_data.tsv")

# Calibrate the eye tracker, using the default options.
tracker.calibrate()

# Run for 10 seconds.
t0 = time.time()
while time.time() - t0 < 10.0:
    # Get the latest sample
    time_stamp, gaze_x, gaze_y, pupil_size = tracker.sample()
    # Print the current sample to the terminal.
    print("t=%.3f, x=%.2f, y=%.2f, s=%.2f" % (time_stamp, gaze_x, gaze_y, pupil_size))
    # Wait for 33 milliseconds.
    time.sleep(0.033)

# Close the connection to the eye tracker.
tracker.close()

故障排除

  • 确保Intelligaze服务器正在运行!如果没有它,python包装器就没有什么可谈的了。
  • 请确保安装Intelligaze服务器!你可以通过Alea Technologies website从intelligaze下载它。
  • 请确保运行的是Microsoft Windows操作系统(在Windows 7和10上进行了测试)。Linux和OS X支持目前不可用。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何下载多个。java中的PDF文件   linux Java打开文件,形成实际用户主页~/   java如何在时间线内维护TableView选择?   java Hibernate注释@Where vs@WhereJoinTable   Java读/写访问异常FileNotFoundException(访问被拒绝)   继承在Java中是否可以扩展最后一个类?   Android HttpClient使用java使应用程序崩溃。lang.OutOfMemoryError:pthread_create   java为什么即使我在proguardproject中添加了jar文件,也会出现这种错误。txt?   如果添加JButton,swing Java FocusListener和KeyListener将无法工作   java使用solrj检索json格式的SolrDocument   使用Microsoft Visual Studio代码进行Java编程   java NoClassDefFoundError:org/apache/log4j/Logger   哈希集中包含相等对象的java   java中的参数化构造函数是否需要有一个主体?   java类似于NetBeans不必要的代码检测器   Java实践问题   java Blackberry“[projectname].调试文件丢失”和“I/O错误:找不到程序”jar