# Boxes: where is it?

> Ask where something is in a picture: a Box question answers with the box around it, or null when it is not there, with a calibrated confidence.

Source: https://docs.tarkova.com/curva/guides/boxes/

## How it works, step by step

1. **Box question** (Box, max_boxes, Up to 20, when, min_confidence): A Box asks where something is in a picture. It can sit next to other questions in the same decision, and max_boxes sets how many boxes may come back (default 1, at most 20). In the example: Box("the parcel on the doorstep"), asked of two photos: door_parcel.png and door_empty.png.
2. **Upright picture** (Turned upright, EXIF removed, 1,568 px): The picture is prepared like any other, so a photo taken sideways is turned upright first. The edges you get back belong to the upright picture. In the example: Both photos are 800 by 600 PNGs, so they keep their size.
3. **Model writes edges** (Verbal, 0 to 1000, Or null, One option order): A Box is an extraction question, so the model writes its answer: edges as whole numbers from 0 to 1000 or null, and how sure it is. A box has no option order, so it is not asked in two orders. In the example: Qwen3-VL on Bedrock answered door_parcel.png in 1.19 s and door_empty.png in 0.86 s.
4. **Fractions** (Divide by 1000, Within 0 to 1, Order fixed, From top-left): Curva turns the edges into fractions of the picture from its top-left corner, keeps them within 0 to 1, and puts top above bottom and left left of right. Boxes past max_boxes are cut. In the example: door_parcel.png: top 0.62, left 0.40, bottom 0.78, right 0.58, an overlap of 0.60 with the parcel as drawn.
5. **How it comes back** (box, boxes, null, []): box holds the first box, or null when the thing is not there. boxes holds every box, so a question with a higher max_boxes reads that list. In the example: door_empty.png: box null, boxes []. The model found no parcel, and the drawing has none.
6. **Found, confidence** (found, confidence, calibrated): confidence is the probability that the answer is right, and found is the probability that the thing is there. When a box came back they are equal; when the answer is not there, found is 1 minus confidence. Until calibrated, this is the model's own figure. In the example: door_parcel.png: found 0.98, confidence 0.98. door_empty.png: found 0.0, confidence 1.0. Both calibrated: false.
7. **Feedback** (True box, null, Overlap 0.5, 30 labels): Send the true box, or null. An answer counts as right when it overlaps the true box by at least half, and from 30 labels Curva can calibrate the confidence. Boxes are rough on real photos: 82% reached that overlap on RefCOCO (n 125, Qwen3-VL), so check yours first. In the example: Sent as feedback, the true parcel box would mark this answer right, since 0.60 is over 0.5.

A Box question asks *where* something is in a picture: the signature on a form, the total on a
receipt, the dent on a parcel. The answer is the box around it, or nothing when it is not there,
with a confidence you can calibrate like any other answer.

```python
from curva import Asset, Box, decide
d = decide("Find the total on the receipt photo.", {"total": Box("the printed total")}, assets={"photo": Asset.image("receipt.jpg")})
d["total"].box   # {"top": 0.63, "left": 0.07, "bottom": 0.65, "right": 0.58}, or None
```

```ts

const d = await decide("Find the total on the receipt photo.", { total: box("the printed total") }, { assets: { photo: Asset.image("receipt.jpg") } });
d.answers.total.box;
```

A Box goes with other questions in the same call: the merchant, the total amount, a box around
it and "is this a receipt at all?" are one decision.

## The answer

```json
{"type": "box", "found": 0.94,
 "box": {"top": 0.71, "left": 0.12, "bottom": 0.80, "right": 0.45},
 "boxes": [{"top": 0.71, "left": 0.12, "bottom": 0.80, "right": 0.45}],
 "confidence": 0.94, "calibrated": false}
```

- Edges are fractions of the picture from its top-left corner: `top` and `bottom` of its height,
  `left` and `right` of its width. They always lie within 0 to 1, with `top` above `bottom` and
  `left` left of `right`.
- `box` is the first box, or `null` when the thing is not there.
- `boxes` holds every box, up to `max_boxes` (default 1, at most 20): `Box("each signature", max_boxes=5)`.
- `confidence` is the probability that the answer is right; `found` is the probability that the
  thing is there. They are one number seen two ways: `found` equals `confidence` when a box came
  back, and `1 - confidence` when the answer is "not there".

## Feedback

Send the true box, or `null` when it was not there:

```python

curva.feedback(d.id, "total", {"top": 0.62, "left": 0.06, "bottom": 0.66, "right": 0.58})
```

An answer counts as right when its box overlaps the true one by at least half (intersection over
union of 0.5 or more), and "not there" is right only when the truth is `null`. From these labels
the confidence is calibrated per project, as for [extraction](/curva/guides/extraction/).

## How it works

- Every model is asked for the edges as whole numbers from 0 to 1000, the convention vision models
  follow best (measured before this was built: a mean overlap of 0.96 on drawn scenes with
  `gemini-3.1-flash-lite`). Curva turns them into fractions.
- A Box is an extraction question, so it is answered in verbal mode, takes `when`, `rules`,
  `examples`, `min_confidence` and `target_accuracy`, and is not debiased (a box has no option
  order). A council keeps the box most members agree on.
- Photos are turned upright before the model sees them (see [Images](/curva/guides/images/)), so the edges
  are those of the upright picture.
