SegmentationMask

A read-only instance mask returned as match.mask by a YOLO segmentation model. Coordinates are current-screen pixels, including when inference uses a region. The mask is a snapshot at prototype resolution, not a guarantee that a location is safe to interact with.

Syntax

SegmentationMask

This class cannot be constructed directly.

Returns

—

Example

# Choose an interior point in a segmented region
model = TfliteModel("water")
for hit in model.inference():
    if hit.mask is not None:
        point = hit.mask.find_point(margin=12)
        if point is not None:
            print(point)

Fields

NameDescription
widthInt
Mask grid width in cells.
heightInt
Mask grid height in cells.
boundsRegion
Screen-pixel bounds of the visible mask cells, clipped to the inference region.
areaNumber
Approximate covered area in square screen pixels, at mask-grid resolution.

Methods

2 methods

SegmentationMask.contains

Return whether a current-screen pixel Point lies in the snapshot mask. Points outside its inference region return False. This does not capture a new frame.

Syntax

mask.contains(point)

Parameters

NameDescription
pointPoint
Point in current-screen pixels; use fixed scale and no anchor.
Required · Positional or named
No default

Returns

Boolean

Example

# Check a point against a segmented region
for hit in TfliteModel("water").inference():
    if hit.mask is not None:
        print(hit.mask.contains(Point(200, 300)))

SegmentationMask.find_point

Find a mask-cell center inside the mask with the largest conservative clearance from its edge. margin is a finite non-negative screen-pixel distance; return None when no cell has that clearance. Grid resolution limits precision. This does not check game range, obstacles or frame freshness.

Syntax

mask.find_point(margin=0)

Parameters

NameDescription
marginNumber
Minimum clearance in current-screen pixels.
Optional · Positional or named
Default: 0

Returns

Point | None

Example

# Choose an interior point in a segmented region
for hit in TfliteModel("water").inference():
    if hit.mask is not None:
        point = hit.mask.find_point(margin=12)
        if point is not None:
            print(point)