之前成功在 Ubuntu 下使用了 4C 眼动仪,但是不知道什么原因目前无法使用 TobiiProEyeTrackerManager 软件来进行眼动仪的标定,也就无法使用它的 gaze visualization 功能来查看注视点的位置。虽然程序里可以输出注视点的归一化坐标,但是这样还是不直观,所以尝试了一下用 tobii 检测到的注视点位置来控制鼠标光标的位置。

除了之前那个 github 工程,还参考了这个工程: https://github.com/lhy0403/TobiiMouse.讲道理这个应该可以直接用的,不过调通后怎么也检测不到设备,所以将其中控制鼠标的部分提出来和之前的结合。

其中和鼠标控制有关的部分在 mouse_integrationnoise_cancellation
在主函数一开始添加

MouseIntegration::init();//get the width and height of current screen
MouseIntegration::SetWorkingMode(TOBII_MOUSE_MODE_ABSOLUTE);

gaze_point_callback 中添加

MouseIntegration::OnGaze(gaze_point->position_xy[0], gaze_point->position_xy[1]);

mouse_integration 如下, noise_cancellation 没有改
mouse_integration.h

#ifndef MOUSE_INTEGRATION_H
#define MOUSE_INTEGRATION_H#include <tuple>
//#include "tobiimouse.h"
#include "noise_cancellation.h"#include <X11/X.h>
#include "X11/Xlib.h"
#include <X11/extensions/Xrandr.h>using namespace std;enum MOUSEWORKINGMODE_E{TOBII_MOUSE_MODE_ABSOLUTE,TOBII_MOUSE_MODE_MOVE_BY_POSITION,
};namespace MouseIntegration
{void SetWorkingMode(MOUSEWORKINGMODE_E mode);void init();void MoveMouseTo(int x, int y);void MoveMouseOffset(int x, int y);tuple<int, int> ProcessGazePosition(float x, float y);void OnGaze(float x, float y);};#endif // MOUSE_INTEGRATION_H

mouse_integration.cpp

#include "mouse.h"
#include <iostream>
#include <vector>namespace MouseIntegration
{static MOUSEWORKINGMODE_E WorkingMode;static int ScreenHeight;static int ScreenWidth;static int LastX;static int LastY;static Display* _display;static Window _root_window;
}void MouseIntegration::init()
{NoiseCancellation::init();//used to filter the data// TODO: Multiple Display supports._display = XOpenDisplay(None);_root_window = XRootWindow(_display, 0);XRRScreenResources *screens = XRRGetScreenResources(_display, DefaultRootWindow(_display));XRRCrtcInfo *info = XRRGetCrtcInfo(_display, screens, screens->crtcs[0]);ScreenWidth = info->width;ScreenHeight = info->height;XRRFreeCrtcInfo(info);XRRFreeScreenResources(screens);
}void MouseIntegration::MoveMouseTo(int x, int y)
{XSelectInput(_display, _root_window, KeyReleaseMask);XWarpPointer(_display, None, _root_window, 0, 0, 0, 0, x, y);XFlush(_display);
}void MouseIntegration::SetWorkingMode(MOUSEWORKINGMODE_E mode)
{WorkingMode = mode;
}tuple<int, int> MouseIntegration::ProcessGazePosition(float x, float y)
{float width = ScreenWidth;float height = ScreenHeight;auto realGazeX = width * x;auto realGazeY = height * y;auto filtered = NoiseCancellation::CancelNoise(realGazeX,realGazeY);//auto count = ScreenCount(_display); //Get total screen count.float gazeX_f = get<0>(filtered);float gazeY_f = get<1>(filtered);return tuple<int, int>(static_cast<int>(gazeX_f), static_cast<int>(gazeY_f));
}void MouseIntegration::OnGaze(float x, float y)
{auto data = ProcessGazePosition(x,y);auto posiX = get<0>(data);auto posiY = get<1>(data);switch (WorkingMode) {case TOBII_MOUSE_MODE_ABSOLUTE:MoveMouseTo(posiX, posiY);break;case TOBII_MOUSE_MODE_MOVE_BY_POSITION:MoveMouseOffset(posiX, posiY);break;}LastX = posiX;LastY = posiY;
}

使用的 IDE 是 Qt Creator,工程的 pro 文件如下

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qtSOURCES += main.cpp\mouse_integration.cpp\noise_cancellation.cppHEADERS +=mouse_integration.h\noise_cancellation.hLIBS += -L$$PWD/lib/lib/x64/ -ltobii_stream_engine
LIBS += -L$$/lib/x86_64-linux-gnu/ -lpthread
LIBS += -L$$/usr/lib/x86_64-linux-gnu/ -lX11
LIBS += -L$$/usr/lib/x86_64-linux-gnu/ -lXrandr

开始编译的时候会出现链接库找不到的问题,主要是因为用到了 X11 这个库,但是没有链接,可以通过

locate libX11 libXrandr

找到 libX11libXrandr 的位置,然后在 pro 文件中加上链接库的位置即可。

Ubuntu下使用Tobii Eye Tracker 4C眼动仪控制鼠标光标相关推荐

  1. Ubuntu下使用Tobii Eye Tracker 4C眼动仪

    Ubuntu下使用Tobii Eye Tracker 4C眼动仪 在 tobii 的官网论坛上有关于如何在 linux 上使用 4C 的帖子,目前经测试这个项目是可行的,github 地址:https ...

  2. Tobii Eye Tracker 4C 眼动仪用户手册--眼动仪开发入门(1)

    原网址:用户手册 SDK version: 4.0 目录 入门 将SDK集成到您的游戏中 导入资产 实施眼动追踪功能 独立构建 API概述 TobiiAPI 凝视点数据 头部姿势数据 用户存在 Gaz ...

  3. Ubuntu下使用眼动仪Tobii Eye Tracker 4C

    01 安装 & 使用 安装.使用过程参考:https://github.com/Eitol/tobii_eye_tracker_linux_installer 下面过程主要是github中自述 ...

  4. Tobii 眼动仪配置SDK-- 眼动仪开发入门(2)

    环境介绍 系统:win10 64位 硬件:Tobii eye tracker 4C 软件: Visual Studio 2015 选择SDK 开发本款眼动仪可以根据以及的需求选择不同的SKD,如图所示 ...

  5. Tobii眼动仪系列软件安装与使用

    Tobii眼动仪系列软件 本文使用眼动仪:Tobii Eye Tracker 5 Tobii Experience | Tobii Ghost 软件下载地址 Tobii Experience(用来校准 ...

  6. Tobii Studio眼动仪教程 - 真正的测谎机器

    一.眼动仪介绍: 1.介绍: 眼动仪是心理学基础研究的重要仪器.眼动仪用于记录人在处理视觉信息时的眼动轨迹特征,广泛用于注意.视知觉.阅读等领域的研究.现有不同厂家生产的多种型号的眼动仪,如 EyeL ...

  7. matlab 处理眼动仪数据总结(一) :数据读取

    matlab 处理眼动仪数据总结(一) :数据读取 因为虚拟现实技术的不断提高,其独有的安全性和有效性,使得其在市场调研.医疗康复.教育等领域开始被普遍使用,同时也开始被多数高校的运动实验室所采用的. ...

  8. matlab 处理眼动仪数据总结(一) :数据读取

        由于虚拟现实技术的不断提升,其独有的安全性和有效性,使得其在市场调研.医疗康复.教育等领域开始被广泛使用,同时也开始被多数高校的运动实验室所采用的.现在主流的眼动仪是tobii和vive两大公 ...

  9. Eyelink眼动仪与Psychopy连接

    本文介绍了如何将Eyelink眼动仪与Psychopy连接并输出Eyelink官方.EDF数据文件.在网上找了很久没找到这方面的操作流程,有用iohub(Psychopy内置眼动组件)实现的,但是感觉 ...

最新文章

  1. 亚信科技CTO欧阳晔博士:5G网络助推边缘AI|MEET 2022
  2. 运行jar应用程序引用其他jar包的四种方法
  3. coreldraw 双层边框
  4. python监听器_监听器 - python成长中 - 博客园
  5. MYSQL高可用-Percona XtraDB Cluster
  6. diolog js_js组件-js插件-jquery插件-dialog对话框弹层
  7. js实现搜索框智能提示上下移动效果
  8. H5 表格标签基本使用
  9. 拓端tecdat|R语言GARCH-DCC模型和DCC(MVT)建模估计
  10. SSM、SSH框架原理
  11. 曹操为何杀死神医华佗?
  12. 平价的蓝牙耳机哪家质量好?学生党公认的五款高品质蓝牙耳机
  13. ug585-Zynq-7000中文文档阅读笔记
  14. ChatGpt真的会取代程序员吗,有点过分担心了
  15. 致远项目管理SPM系统核心价值
  16. 基于硬件定时器的软件定时器
  17. toad for mysql_toad for mysql
  18. IBM待遇完全揭密--工资 级别等(最强完整版)
  19. 构建一个轻量级的嵌入式虚拟平台,开发工程用板stm32 picoc解释器,大量自定义函数,sarm拓展,lwip移植,nes模拟器移植,系统优化,等等技术的融合
  20. 常用linux的37个命令

热门文章

  1. 替换Word中的中文引号为英文引号
  2. 飞机大战纯c课程设计报告(里面的本来有图的,但是我就懒得导入)
  3. Vehicle Spy3学习记录
  4. 关于VsCode中TypeScript文件提示:标识符“xxx“重复,此处也声明了“xxx“ 解决方案
  5. 三国杀online网页版服务器更新,[OL][公告]《三国杀online》2月28日版本更新公告
  6. 使用putty连接Ubuntu虚拟机--SSH
  7. 西门子S7—200 Smart恒压供水控制程序
  8. 转载:一线算法工程师整理!超实用的3大多目标跟踪算法
  9. 爬取薅羊毛网站百度云资源
  10. ipad id密码忘了怎么办,如何处理