|
| 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**. |
0 commit comments