For the complete documentation index, see llms.txt. This page is also available as Markdown.

Masks, Contours and Depth

The exact shape of an object, as a mask or contours, and a depth map for the whole frame

A box says roughly where an object is. A segmentation ability says exactly which pixels belong to it, as a mask, and a contour finder turns that mask into contours, polygons you can draw or measure. A depth ability goes further and estimates, for every pixel of the frame, how far away it is, as a depth map.

Masks

A mask is a black-and-white image the size of the object's box: a pixel is set where the object is and clear where it is not. A small diamond-shaped object, 10 pixels wide and 4 high, looks like this:

{
  "classLabel": "diamond",
  "x": 100, "y": 50, "width": 10, "height": 4,
  "mask": { "width": 10, "height": 4, "stride": 2, "bitmap": "DAA/AD8ADAA=" }
}
The 10 by 4 pixel object, magnified, inside its dashed box from x 100 to 110 and y 50 to 54. Left: the mask marks its 16 pixels with 1 and every other pixel of the box with 0. Right: the contour is one polygon of 12 points around the same pixels.
The diamond's mask and its contour, laid over the pixels of the image.
Key
Type
Meaning

width, height

integer

The mask's size in mask pixels

stride

integer

Bytes per row of the bitmap

bitmap

string

The pixels, base64-encoded, one bit each

world

string

A point cloud for the mask, in meters, when the Pop asks for world coordinates. See World Coordinates

The mask covers the object's box. Its top-left pixel is at the box's x and y, and it stretches over the box's width and height. When the mask's own width and height differ from the box's, scale it to the box to draw it.

How the bitmap is laid out

The bitmap is a grid of bits, one per pixel, row by row from the top:

  • Each row takes stride bytes: width bits, rounded up to whole bytes.

  • Within a byte, the highest bit is the leftmost pixel. A 1 is a pixel of the object.

The diamond's mask shows the layout. Each row needs 10 bits, so stride is 2 bytes, and the last 6 bits of every row are unused:

Example: decode a mask

np.unpackbits reads the highest bit first, which is exactly the layout of the bitmap.

Contours

A contour is the outline of a mask as a polygon, ready to draw or to measure. A contour finder on a segmentation result adds contours to the object. For the diamond it is one polygon around its pixels:

Key
Type
Meaning

points

array of points

The polygon's corners, in order, in source pixels

cutouts

array of arrays of points

Holes in the polygon, each a polygon of its own

An object can have several contours, when its mask has separate parts. A cutout is a hole: the gap between an arm and the body, for instance, is a cutout of the person's contour.

Contour points are in the full frame, like every other position, so they draw directly on the image. With world coordinates asked for, each point also carries worldX, worldY and worldZ in meters.

Depth maps

A depth ability estimates the distance of every pixel of the frame. It returns one map for the whole frame, on the prediction:

The lobby image tinted by depth: the person and the floor in front of her in yellow, near the camera, the walls and plants in green and blue, and the doors at the back in purple, farthest away
This depth map from eyepop.depth.metric.large:latest, scaled to the image and laid over it: yellow is near, purple is far. The person is generated.
Key
Type
Meaning

width, height

integer

The map's size. Always the frame's aspect ratio, usually a lower resolution

semantic

string

What the values mean: metric, canonical_metric, relative or unknown

values

string

width × height little-endian 32-bit floats, row by row, base64-encoded

world

string

A point cloud of the whole scene, when the Pop asks for one

The map is smaller than the frame: here 518 × 291 for a 1280 × 720 image. To find the depth at a point of the frame, scale the point by the ratio of the sizes. Depth Maps explains semantic, how to decode the values and turn them into meters, and why sky pixels are infinite.

A depth map is large: this one is close to a megabyte of text, on every frame. A Pop that needs depth only to place its objects in meters can keep the map itself out of the response; see Depth and World Coordinates.

Next steps

Last updated