之前成功在 Ubuntu 下使用了 4C 眼动仪,但是不知道什么原因目前无法使用 TobiiProEyeTrackerManager 软件来进行眼动仪的标定,也就无法使用它的 gaze visualization 功能来查看注视点的位置。虽然程序里可以输出注视点的归一化坐标,但是这样还是不直观,所以尝试了一下用 tobii 检测到的注视点位置来控制鼠标光标的位置。
除了之前那个 github 工程,还参考了这个工程: https://github.com/lhy0403/TobiiMouse.讲道理这个应该可以直接用的,不过调通后怎么也检测不到设备,所以将其中控制鼠标的部分提出来和之前的结合。
其中和鼠标控制有关的部分在 mouse_integration 和 noise_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