AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1275038
Accepted
Peter
Peter
Asked: 2020-09-15 05:23:40 +0800 CST2020-09-15 05:23:40 +0800 CST 2020-09-15 05:23:40 +0800 CST

“坐标变换矩阵”和“libinput 校准矩阵”——它们有什么关系?

  • 772

“libinput Calibration Matrix”的确切格式是什么(即它的每个元素代表什么)以及它与“坐标变换矩阵”有什么关系?如果“坐标变换矩阵”负责将触摸屏点映射到显示点,为什么还不够,为什么还需要“libinput 校准矩阵”?每个矩阵负责校准过程的哪一部分?

我还没有找到一个参考站点来解释“libinput Calibration Matrix”代表什么元素(与“坐标变换矩阵”相反)。我设法找到的是相关系数的以下“定义”:

a = (screen_x * 6 / 8) / (c3_x - c0_x)
c = ((screen_x / 8) - (a * c0_x)) / screen_x
e = (screen_y * 6 / 8) / (c3_y - c0_y)
f = ((screen_y / 8) - (e * c0_y)) / screen_y

没有任何解释它们是如何派生的/它们应该代表什么。总结一下:“libinput校准矩阵”的“官方”定义是什么,它与“坐标变换矩阵”有什么不同?

xorg touchscreen xinput libinput
  • 1 1 个回答
  • 3417 Views

1 个回答

  • Voted
  1. Best Answer
    Goffredo Baroncelli
    2021-01-15T11:38:41+08:002021-01-15T11:38:41+08:00

    我开发了 xlibinput_calibrator。在这里 [1] 您可以找到“校准矩阵”计算背后的数学实现。

    基本上,您需要将坐标从“触摸空间”转换为“屏幕空间”。首先,您需要在“触摸空间”和“屏幕空间”中收集至少 3 个点的坐标。[2]

    校准矩阵 (C)、“触摸空间”中的坐标 (tx_i, ty_i, 其中 i=1,2,3) 和“屏幕空间”中的坐标 (sx_i, sy_i) 由以下公式关联:

          ⎡tx₁ tx₂ tx₃⎤
          ⎢ ⎥
    Ti = ⎢ty₁ ty₂ ty₃⎥
          ⎢ ⎥
          ⎣ 0 0 1 ⎦
    
          ⎡sx₁ sx₂ sx₃⎤
          ⎢ ⎥
    Si = ⎢sy₁ sy₂ sy₃⎥
          ⎢ ⎥
          ⎣ 0 0 1 ⎦
    
          ⎡abc⎤
          ⎢ ⎥
    C = ⎢def⎥
          ⎢ ⎥
          ⎣0 0 1⎦
    
    ⎡abc⎤ ⎡tx₁ tx₂ tx₃⎤ ⎡sx₁ sx₂ sx₃⎤
    ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
    ⎢def⎥ x ⎢ty₁ ty₂ ty₃⎥ = ⎢sy₁ sy₂ sy₃⎥
    ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
    ⎣0 0 1⎦ ⎣ 0 0 1 ⎦ ⎣ 0 0 1 ⎦
    
    C * Ti = Si => C = Si * inv(Ti)
    
    

    其中“inv(Ti)”计算 Ti 的逆矩阵。结果是(感谢 Octave):

         sx₁⋅ty₂ - sx₂⋅ty₁     
    a = ──────────────────
         tx₁⋅ty₂ - tx₂⋅ty₁
    
         - sx₁⋅tx₂ + sx₂⋅tx₁     
    b = ────────────────────
          tx₁⋅ty₂ - tx₂⋅ty₁
    
         sx₁⋅(tx₂⋅ty₃ - tx₃⋅ty₂) + sx₂⋅(tx₁⋅ty₃ - tx₃⋅ty₁) + sx₃⋅(tx₁⋅ty₂ - tx₂⋅ty₁)     
    c = ────────────────────────────────────────────── ──────────────────────────────
                                      tx₁⋅ty₂ - tx₂⋅ty₁        
    
         sy₁⋅ty₂ - sy₂⋅ty₁     
    d = ──────────────────
         tx₁⋅ty₂ - tx₂⋅ty₁
    
         -sy₁⋅tx₂ +sy₂⋅tx₁     
    e = ──────────────────
         tx₁⋅ty₂ - tx₂⋅ty₁
    
         sy₁⋅(tx₂⋅ty₃ - tx₃⋅ty₂) - sy₂⋅(tx₁⋅ty₃ - tx₃⋅ty₁) + sy₃⋅(tx₁⋅ty₂ - tx₂⋅ty₁)    
    f = ────────────────────────────────────────────── ────────────────────────────
                                     tx₁⋅ty₂ - tx₂⋅ty₁         
    
    
    

    上面的一个是“通用”公式,其中还考虑了旋转和轴反转(及其组合)等情况。您发布的一个更简单(只需要 2 分)在这些情况下可能会失败。

    您还必须考虑 libinput 需要归一化形式 (Cn) 的矩阵。所以它变成

                       ⎡ b⋅sy b⋅dy⋅sy c ⎤
                       ⎢ a ──── a⋅dx + ──────── + ── - dx⎥
                       ⎢ sx sx sx ⎥
                       ⎢ ⎥
                       ⎢d⋅sx d⋅dx⋅sx f ⎥
                Cn = ⎢──── e ─────── + dy⋅e - dy + ──⎥
                       ⎢ sy sy sy⎥
                       ⎢ ⎥
                       ⎣ 0 0 1 ⎦
    
    
    

    在哪里

    • sx = 1/宽度
    • sy = 1/高度
    • dx = minx
    • dy = 我的

    [1] https://github.com/kreijack/xlibinput_calibrator/blob/master/src/calibrator.cc#L144

    [2] 在 xlibinput_calibrator 中,我取 4 个点,结果矩阵是由点的任意组合计算的 4 个矩阵的平均值。

    • 1

相关问题

  • 如何从命令行重新启动 X Window Server?

  • xorg 中是否有用于更改视频驱动程序的 GUI?

  • 类似于 Eyefinity 的东西?

  • 如何重置我的键盘布局?

  • 帮助让 Flash 播放器在第二个屏幕上工作?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve