> For the complete documentation index, see [llms.txt](https://docs.eyepop.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eyepop.ai/platform/abilities/open-vocabulary/detect-and-segment.md). Agents can also search and read this documentation through its [MCP server](https://docs.eyepop.ai/~gitbook/mcp).

# Detect and segment

Find, segment and outline what you name, with SAM3 and Grounding DINO

`eyepop.sam3.detect`, `.segment` and `.contour` find every instance of each prompt and return boxes, masks or polygons; `eyepop.grounding-dino.detect` returns boxes, faster. Each Pop below runs on the street photo with the code in [Running the examples](https://docs.eyepop.ai/platform/abilities/open-vocabulary.md#running-the-examples), which prints the prediction. The outputs were captured from production and trimmed; your numbers will differ slightly. The pictures draw each response onto the photo.

### SAM3: detect

One detector, two prompts, two labels in one pass.

```json
{
  "components": [
    {
      "type": "inference",
      "ability": "eyepop.sam3.detect:latest",
      "params": {
        "prompts": [{ "prompt": "sunglasses" }, { "prompt": "bollard" }]
      }
    }
  ]
}
```

```json
"objects": [
  { "classLabel": "sunglasses", "confidence": 0.812, "x": 115.29, "y": 430.048, "width": 41.923, "height": 15.292 },
  { "classLabel": "sunglasses", "confidence": 0.8408, "x": 268.154, "y": 436.376, "width": 41.132, "height": 14.238 },
  { "classLabel": "bollard", "confidence": 0.9272, "x": 658.125, "y": 625.429, "width": 30.849, "height": 90.703 },
  "…"
]
```

<figure><img src="https://1072321683-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDoCvfjveqiJFmk0cnXCp%2Fuploads%2Fgit-blob-a441e5d604810ddc8687908cd3d86ff97a14b4b6%2Fopen-vocabulary-sam3-detect.jpg?alt=media" alt="The street photo with boxes around the two pairs of sunglasses and the three bollards" width="400"><figcaption><p>Two pairs of sunglasses and three bollards, from two prompts.</p></figcaption></figure>

Neither label exists in any fixed-class model.

### SAM3: segment

`eyepop.sam3.segment` adds a `mask` to every object it finds: which pixels of the box belong to the object.

```json
{
  "components": [
    {
      "type": "inference",
      "ability": "eyepop.sam3.segment:latest",
      "params": {
        "prompts": [{ "prompt": "bus" }, { "prompt": "person" }]
      }
    }
  ]
}
```

```json
{
  "classLabel": "bus",
  "confidence": 0.9433,
  "x": 5.537, "y": 231.899, "width": 795.761, "height": 500.581,
  "mask": { "bitmap": "AAAAAAAAAAAAAAAAAAAA…", "width": 284, "height": 135, "stride": 36 }
}
```

<figure><img src="https://1072321683-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDoCvfjveqiJFmk0cnXCp%2Fuploads%2Fgit-blob-81bebe2220ae5a24fde623b1dc4968739c15ac92%2Fopen-vocabulary-sam3-segment.jpg?alt=media" alt="The street photo with the bus filled in pink and each of the four people filled in green" width="400"><figcaption><p>One mask for the bus and one for each person.</p></figcaption></figure>

The mask is a bitmap covering the box, here at a lower resolution than the box itself; scale it to the box to draw it. See [Masks, Contours and Depth](https://docs.eyepop.ai/platform/response-format/predictions/masks-contours-and-depth.md) for decoding it.

### SAM3: contour

`eyepop.sam3.contour` traces the same mask into a polygon instead — the shape to draw, or to measure an area with. The Pop is the segment Pop with `eyepop.sam3.contour:latest`:

```json
{
  "classLabel": "bus",
  "confidence": 0.9433,
  "x": 5.537, "y": 231.899, "width": 795.761, "height": 500.581,
  "contours": [
    { "points": [{ "x": 211.482, "y": 237.461 }, { "x": 200.274, "y": 241.169 }, "…"] }
  ]
}
```

<figure><img src="https://1072321683-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDoCvfjveqiJFmk0cnXCp%2Fuploads%2Fgit-blob-210086e8dbf4390a87a13bfeb29e4f442ce6e728%2Fopen-vocabulary-sam3-contour.jpg?alt=media" alt="The street photo with the outline of the bus traced in pink and the outline of each person traced in green" width="400"><figcaption><p>The same objects as polygons: 212 points around the bus.</p></figcaption></figure>

### Grounding DINO: detect

`eyepop.grounding-dino.detect` takes the same prompts as SAM3 and is faster.

```json
{
  "components": [
    {
      "type": "inference",
      "ability": "eyepop.grounding-dino.detect:latest",
      "params": {
        "prompts": [{ "prompt": "person" }, { "prompt": "bollard" }]
      }
    }
  ]
}
```

```json
"objects": [
  { "classLabel": "person", "confidence": 0.6894, "x": 223.461, "y": 405.527, "width": 120.234, "height": 453.515 },
  { "classLabel": "person", "confidence": 0.6489, "x": 50.081, "y": 398.144, "width": 194.935, "height": 504.14 },
  "…"
]
```

<figure><img src="https://1072321683-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDoCvfjveqiJFmk0cnXCp%2Fuploads%2Fgit-blob-d6be7c406671c7d269625e1cc6f740798e95fe2b%2Fopen-vocabulary-grounding-dino-detect.jpg?alt=media" alt="The street photo with boxes around the four people, scored between 0.41 and 0.74, and no bollards" width="400"><figcaption><p>Four people, and no bollard above the default threshold.</p></figcaption></figure>

It finds the four people, with lower scores than SAM3 gives them, and none of the bollards SAM3 found. When a fast detector misses what you asked for, lower `confidenceThreshold` or switch to `eyepop.sam3.detect`.

### Next steps

* [Open vocabulary](https://docs.eyepop.ai/platform/abilities/open-vocabulary.md) — the `prompts` parameter, limits and confidence
* [Masks, Contours and Depth](https://docs.eyepop.ai/platform/response-format/predictions/masks-contours-and-depth.md) — decoding masks and contours

Questions about building a Pop? Reach us at <help@eyepop.ai>.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eyepop.ai/platform/abilities/open-vocabulary/detect-and-segment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
