Skip to content

Commit 952bb4a

Browse files
authored
Merge pull request #253 from Integration-Automation/feat/coordinate-space-batch
Add coordinate-space mapping (model grid <-> physical pixels)
2 parents d8ad5f9 + 745dbb8 commit 952bb4a

15 files changed

Lines changed: 368 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
## Table of Contents
1515

16+
- [What's new (2026-06-20) — Coordinate-Space Mapping (Model Grid ⇄ Physical Pixels)](#whats-new-2026-06-20--coordinate-space-mapping-model-grid--physical-pixels)
1617
- [What's new (2026-06-20) — Voice-Command Router](#whats-new-2026-06-20--voice-command-router)
1718
- [What's new (2026-06-20) — Locale-Aware Number, Currency & Date Parsing](#whats-new-2026-06-20--locale-aware-number-currency--date-parsing)
1819
- [What's new (2026-06-20) — Perceptual-Hash Image Dedupe](#whats-new-2026-06-20--perceptual-hash-image-dedupe)
@@ -97,6 +98,12 @@
9798

9899
---
99100

101+
## What's new (2026-06-20) — Coordinate-Space Mapping (Model Grid ⇄ Physical Pixels)
102+
103+
Translate computer-use model clicks to real pixels. Full reference: [`docs/source/Eng/doc/new_features/v45_features_doc.rst`](docs/source/Eng/doc/new_features/v45_features_doc.rst).
104+
105+
- **`CoordinateSpace` / `xga_space` / `normalized_space` / `downscale_png`** (`AC_to_physical` / `AC_to_model`, `ac_*`): computer-use/VLA models click in a fixed grid (Anthropic downscales to XGA; Gemini returns a 1000×1000 grid), not physical pixels. This maps both ways (round + clamp), `xga_space` aspect-preserves without upscaling, and `downscale_png` resizes a screenshot to the model's input size (Pillow, already core). Pure-arithmetic mapping — unit-tested without a model/GPU.
106+
100107
## What's new (2026-06-20) — Voice-Command Router
101108

102109
Trigger flows hands-free from recognized speech. Full reference: [`docs/source/Eng/doc/new_features/v44_features_doc.rst`](docs/source/Eng/doc/new_features/v44_features_doc.rst).

README/README_zh-CN.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
## 目录
1414

15+
- [本次更新 (2026-06-20) — 坐标空间映射(模型网格 ⇄ 物理像素)](#本次更新-2026-06-20--坐标空间映射模型网格--物理像素)
1516
- [本次更新 (2026-06-20) — 语音指令路由器](#本次更新-2026-06-20--语音指令路由器)
1617
- [本次更新 (2026-06-20) — 区域设置感知的数字、货币与日期解析](#本次更新-2026-06-20--区域设置感知的数字货币与日期解析)
1718
- [本次更新 (2026-06-20) — 感知哈希图像去重](#本次更新-2026-06-20--感知哈希图像去重)
@@ -96,6 +97,12 @@
9697

9798
---
9899

100+
## 本次更新 (2026-06-20) — 坐标空间映射(模型网格 ⇄ 物理像素)
101+
102+
将电脑操作模型的点击转成物理像素。完整参考:[`docs/source/Zh/doc/new_features/v45_features_doc.rst`](../docs/source/Zh/doc/new_features/v45_features_doc.rst)
103+
104+
- **`CoordinateSpace` / `xga_space` / `normalized_space` / `downscale_png`**(`AC_to_physical` / `AC_to_model``ac_*`):电脑操作/VLA 模型以固定网格点击(Anthropic 缩小到 XGA;Gemini 返回 1000×1000 网格),而非物理像素。本功能双向映射(四舍五入 + 夹限),`xga_space` 保持长宽比且不放大,`downscale_png` 将截图缩到模型输入尺寸(Pillow,已是核心)。纯算术映射 —— 无需模型/GPU 即可单元测试。
105+
99106
## 本次更新 (2026-06-20) — 语音指令路由器
100107

101108
以已识别语音免手动触发流程。完整参考:[`docs/source/Zh/doc/new_features/v44_features_doc.rst`](../docs/source/Zh/doc/new_features/v44_features_doc.rst)

README/README_zh-TW.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
## 目錄
1414

15+
- [本次更新 (2026-06-20) — 座標空間對映(模型網格 ⇄ 實體像素)](#本次更新-2026-06-20--座標空間對映模型網格--實體像素)
1516
- [本次更新 (2026-06-20) — 語音指令路由器](#本次更新-2026-06-20--語音指令路由器)
1617
- [本次更新 (2026-06-20) — 區域設定感知的數字、貨幣與日期解析](#本次更新-2026-06-20--區域設定感知的數字貨幣與日期解析)
1718
- [本次更新 (2026-06-20) — 感知雜湊影像去重](#本次更新-2026-06-20--感知雜湊影像去重)
@@ -96,6 +97,12 @@
9697

9798
---
9899

100+
## 本次更新 (2026-06-20) — 座標空間對映(模型網格 ⇄ 實體像素)
101+
102+
將電腦操作模型的點擊轉成真實像素。完整參考:[`docs/source/Zh/doc/new_features/v45_features_doc.rst`](../docs/source/Zh/doc/new_features/v45_features_doc.rst)
103+
104+
- **`CoordinateSpace` / `xga_space` / `normalized_space` / `downscale_png`**(`AC_to_physical` / `AC_to_model``ac_*`):電腦操作/VLA 模型以固定網格點擊(Anthropic 縮小到 XGA;Gemini 回傳 1000×1000 網格),而非實體像素。本功能雙向對映(四捨五入 + 夾限),`xga_space` 保持長寬比且不放大,`downscale_png` 將截圖縮到模型輸入尺寸(Pillow,已是核心)。純算術對映 —— 無需模型/GPU 即可單元測試。
105+
99106
## 本次更新 (2026-06-20) — 語音指令路由器
100107

101108
以已辨識語音免手動觸發流程。完整參考:[`docs/source/Zh/doc/new_features/v44_features_doc.rst`](../docs/source/Zh/doc/new_features/v44_features_doc.rst)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Coordinate-Space Mapping (Model Grid ⇄ Physical Pixels)
2+
=======================================================
3+
4+
Computer-use / VLA models do not click in physical pixels. Anthropic recommends
5+
downscaling the screenshot to XGA (~1024×768) and mapping clicks back; Gemini's
6+
computer-use model returns a normalized **1000×1000** grid; others assume the
7+
display size you declared. ``CoordinateSpace`` captures the physical resolution
8+
and the model's grid and converts both ways, so an agent loop can feed the model
9+
a right-sized screenshot and translate its clicks back to real coordinates.
10+
11+
The mapping is pure arithmetic (no dependency); :func:`downscale_png` uses Pillow
12+
(already a core dependency). Imports no ``PySide6``.
13+
14+
Headless API
15+
------------
16+
17+
.. code-block:: python
18+
19+
from je_auto_control import (
20+
CoordinateSpace, xga_space, normalized_space, downscale_png)
21+
22+
space = normalized_space(1920, 1080, grid=1000) # Gemini-style 1000x1000
23+
space.to_physical(500, 500) # -> (960, 540) model click -> real pixel
24+
space.to_model(960, 540) # -> (500, 500) real pixel -> model grid
25+
26+
xga = xga_space(2560, 1440) # Anthropic-style downscale, aspect-preserved
27+
small_png = downscale_png(screenshot_png, xga) # send this to the model
28+
29+
``xga_space`` preserves aspect ratio and never upscales; ``normalized_space``
30+
builds a square grid. Both ``to_physical`` / ``to_model`` round and clamp to valid
31+
pixel/grid bounds.
32+
33+
Executor commands
34+
-----------------
35+
36+
================================ ===================================================
37+
Command Effect
38+
================================ ===================================================
39+
``AC_to_physical`` Map a model-grid ``(x, y)`` to physical pixels.
40+
``AC_to_model`` Map physical pixels to a model grid (inverse).
41+
================================ ===================================================
42+
43+
Both take ``x, y, physical_w, physical_h, model_w, model_h`` and return
44+
``{x, y}``. The same operations are exposed as MCP tools (``ac_to_physical`` /
45+
``ac_to_model``) and as Script Builder commands under **Agent**.

docs/source/Eng/eng_index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Comprehensive guides for all AutoControl features.
6767
doc/new_features/v42_features_doc
6868
doc/new_features/v43_features_doc
6969
doc/new_features/v44_features_doc
70+
doc/new_features/v45_features_doc
7071
doc/ocr_backends/ocr_backends_doc
7172
doc/observability/observability_doc
7273
doc/operations_layer/operations_layer_doc
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
座標空間對映(模型網格 ⇄ 實體像素)
2+
====================================
3+
4+
電腦操作 / VLA 模型並不是以實體像素點擊。Anthropic 建議將螢幕截圖縮小到 XGA
5+
(~1024×768)再把點擊映射回去;Gemini 的電腦操作模型回傳正規化的 **1000×1000** 網格;
6+
其他模型則假設你宣告的顯示尺寸。``CoordinateSpace`` 捕捉實體解析度與模型網格並雙向轉
7+
換,因此 agent loop 可餵給模型一張尺寸正確的截圖,並把它的點擊轉回真實座標。
8+
9+
對映為純算術(無相依);:func:`downscale_png` 使用 Pillow(已是核心相依)。不匯入
10+
``PySide6``。
11+
12+
無頭 API
13+
--------
14+
15+
.. code-block:: python
16+
17+
from je_auto_control import (
18+
CoordinateSpace, xga_space, normalized_space, downscale_png)
19+
20+
space = normalized_space(1920, 1080, grid=1000) # Gemini 式 1000x1000
21+
space.to_physical(500, 500) # -> (960, 540) 模型點擊 -> 真實像素
22+
space.to_model(960, 540) # -> (500, 500) 真實像素 -> 模型網格
23+
24+
xga = xga_space(2560, 1440) # Anthropic 式縮小,保持長寬比
25+
small_png = downscale_png(screenshot_png, xga) # 把這張送給模型
26+
27+
``xga_space`` 會保持長寬比且永不放大;``normalized_space`` 建立方形網格。
28+
``to_physical`` / ``to_model`` 皆會四捨五入並夾限到有效的像素/網格範圍內。
29+
30+
執行器指令
31+
----------
32+
33+
================================ ===================================================
34+
指令 效果
35+
================================ ===================================================
36+
``AC_to_physical`` 將模型網格 ``(x, y)`` 對映到實體像素。
37+
``AC_to_model`` 將實體像素對映到模型網格(反向)。
38+
================================ ===================================================
39+
40+
兩者皆接受 ``x, y, physical_w, physical_h, model_w, model_h`` 並回傳 ``{x, y}``。相同操
41+
作亦提供為 MCP 工具(``ac_to_physical`` / ``ac_to_model``),以及 Script Builder 中
42+
**Agent** 分類下的指令。

docs/source/Zh/zh_index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ AutoControl 所有功能的完整使用指南。
6767
doc/new_features/v42_features_doc
6868
doc/new_features/v43_features_doc
6969
doc/new_features/v44_features_doc
70+
doc/new_features/v45_features_doc
7071
doc/ocr_backends/ocr_backends_doc
7172
doc/observability/observability_doc
7273
doc/operations_layer/operations_layer_doc

je_auto_control/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@
251251
from je_auto_control.utils.voice import (
252252
VoiceCommand, VoiceRouter, default_voice_router,
253253
)
254+
# Coordinate-space mapping (model grid <-> physical pixels)
255+
from je_auto_control.utils.coordinate_space import (
256+
CoordinateSpace, downscale_png, normalized_space, xga_space,
257+
)
254258
# Background popup/interrupt watchdog (unattended automation)
255259
from je_auto_control.utils.watchdog import (
256260
PopupWatchdog, WatchdogRule, default_popup_watchdog,
@@ -705,6 +709,7 @@ def start_autocontrol_gui(*args, **kwargs):
705709
"format_currency", "format_date", "format_decimal", "parse_decimal",
706710
"parse_number",
707711
"VoiceCommand", "VoiceRouter", "default_voice_router",
712+
"CoordinateSpace", "downscale_png", "normalized_space", "xga_space",
708713
# MCP server
709714
"AuditLogger", "HttpMCPServer", "MCPContent", "MCPPrompt",
710715
"MCPPromptArgument", "MCPResource", "MCPServer", "MCPTool",

je_auto_control/gui/script_builder/command_schema.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,28 @@ def _add_misc_specs(specs: List[CommandSpec]) -> None:
10191019
fields=(),
10201020
description="Remove all registered voice commands.",
10211021
))
1022+
specs.append(CommandSpec(
1023+
"AC_to_physical", "Agent", "Coords: Model -> Physical",
1024+
fields=(
1025+
FieldSpec("x", FieldType.FLOAT), FieldSpec("y", FieldType.FLOAT),
1026+
FieldSpec("physical_w", FieldType.INT),
1027+
FieldSpec("physical_h", FieldType.INT),
1028+
FieldSpec("model_w", FieldType.INT),
1029+
FieldSpec("model_h", FieldType.INT),
1030+
),
1031+
description="Map a model-grid coordinate to physical pixels.",
1032+
))
1033+
specs.append(CommandSpec(
1034+
"AC_to_model", "Agent", "Coords: Physical -> Model",
1035+
fields=(
1036+
FieldSpec("x", FieldType.INT), FieldSpec("y", FieldType.INT),
1037+
FieldSpec("physical_w", FieldType.INT),
1038+
FieldSpec("physical_h", FieldType.INT),
1039+
FieldSpec("model_w", FieldType.INT),
1040+
FieldSpec("model_h", FieldType.INT),
1041+
),
1042+
description="Map a physical-pixel coordinate to a model grid.",
1043+
))
10221044
specs.append(CommandSpec(
10231045
"AC_generate_sop", "Report", "Generate SOP Document",
10241046
fields=(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Coordinate-space mapping between model grids and physical pixels."""
2+
from je_auto_control.utils.coordinate_space.coordinate_space import (
3+
CoordinateSpace, downscale_png, normalized_space, xga_space,
4+
)
5+
6+
__all__ = [
7+
"CoordinateSpace", "downscale_png", "normalized_space", "xga_space",
8+
]

0 commit comments

Comments
 (0)