> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glasswarp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Observe the screen

> Capture frames, regions of interest, and only what changed.

## One-shot screenshot

```python theme={null}
frame = gw.screenshot(sid)
with open("screen.jpg", "wb") as f:
    f.write(frame.jpeg)
```

Downscale for cheaper model calls, or crop to a region of interest:

```python theme={null}
small = gw.screenshot(sid, max_width=1280, quality=80)
roi = gw.screenshot(sid, x=100, y=200, w=800, h=600)
```

## observe — frame + change + targets

```python theme={null}
obs = gw.observe(sid, max_width=1280, mark=True)
print(len(obs.jpeg), "bytes")
print(len(obs.dirty), "changed regions")
print(len(obs.targets), "targets")
```

Pass your own targets to get a Set-of-Mark annotated frame back:

```python theme={null}
from glasswarp import targets_from_grid

targets = targets_from_grid(x0=100, y0=200, x1=900, y1=800, rows=8, cols=8)
obs = gw.observe(sid, mark=True, targets=targets)
```

## Only look when something changed

```python theme={null}
rects = gw.dirty_rects(sid)
if rects:
    frame = gw.screenshot(sid)
    # ...feed to your model
else:
    ...  # nothing changed; skip the expensive call
```

<Tip>
  Combine dirty rects with ROI screenshots: when a small region changes, capture
  only that region and skip full-frame model calls.
</Tip>

See [Vision](/concepts/vision) for the concepts and [Agent
loop](/guides/agent-loop) to put it together.
