> 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/sdks/node/visualization.md). Agents can also search and read this documentation through its [MCP server](https://docs.eyepop.ai/~gitbook/mcp).

# Visualization

Draw predictions on an HTML canvas

`@eyepop.ai/eyepop-render-2d` draws predictions onto a canvas — boxes, keypoints, contours, and more.

```shell
npm install --save @eyepop.ai/eyepop @eyepop.ai/eyepop-render-2d canvas
```

This example runs under Node. A browser works at runtime — take the context from a DOM canvas and pass `source: { file }`, since resolving a `path` is not supported there — but `Render2d.renderer` is typed against the node-`canvas` context, so TypeScript needs a cast.

```typescript
import { writeFile } from 'node:fs/promises'
import { createCanvas, loadImage } from 'canvas'
import { EyePop, PopComponentType } from '@eyepop.ai/eyepop'
import { Render2d } from '@eyepop.ai/eyepop-render-2d'

const image = await loadImage('people.jpg')
const canvas = createCanvas(image.width, image.height)
const context = canvas.getContext('2d')
context.drawImage(image, 0, 0)

const endpoint = await EyePop.workerEndpoint({
    pop: {
        components: [
            { type: PopComponentType.INFERENCE, ability: 'eyepop.person:latest' },
        ],
    },
}).connect()

try {
    const renderer = Render2d.renderer(context, [
        Render2d.renderBox({ showClass: true, showConfidence: true }),
    ])

    const results = await endpoint.process({ source: { path: 'people.jpg' } })
    for await (const result of results) {
        renderer.draw(result)
    }
} finally {
    await endpoint.disconnect()
}

await writeFile('people-annotated.png', canvas.toBuffer('image/png'))
```

Renderers compose: pass several to `Render2d.renderer()` to draw boxes, poses, and contours over the same prediction.

### Depth maps

`Render2d.renderDepth()` paints a frame's [depth map](https://docs.eyepop.ai/platform/depth-and-world-coordinates/depth-maps.md) over it as a turbo heatmap — near is warm, far is cool, and sky pixels are left untouched unless `renderSky` is set.

```typescript
const renderer = Render2d.renderer(context, [
    Render2d.renderDepth({ opacity: 0.5, renderSky: false }),
])
```

The Node SDK draws depth in 2D only; for world coordinates as a 3D scene, `examples/webpack/src/world-demo.html` in this repository does it with three.js.

{% hint style="info" %}
The full renderer list and options live with the package at [`src/eyepop-render-2d`](https://github.com/eyepop-ai/eyepop-sdk-node/blob/main/src/eyepop-render-2d/README.md).
{% endhint %}

### Next steps

* [Running Inference](https://docs.eyepop.ai/sdks/node/inference.md) — produce the predictions to draw
* [Composable Pops](https://docs.eyepop.ai/sdks/node/composable-pops.md) — chain models into a pipeline
* [Depth and World Coordinates](https://docs.eyepop.ai/platform/depth-and-world-coordinates.md) — depth maps, calibration, and meters


---

# 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/sdks/node/visualization.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.
