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=" }
}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
stridebytes:widthbits, rounded up to whole bytes.Within a byte, the highest bit is the leftmost pixel. A
1is 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:
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:

eyepop.depth.metric.large:latest, scaled to the image and laid over it: yellow is near, purple is far. The person is generated.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
Depth and World Coordinates — positions in meters from masks, contours and depth maps
Raw Output and Details — the remaining kinds of result
Last updated
