Skip to main content
Version: Next

Function: selectByBox()

selectByBox<L>(instances, box): SegmentedInstance<L> | null

Defined in: utils/segmentAnythingPrompts.ts:53

Selects the best matching instance for a given box prompt.

Finds all instances that overlap with the prompt box, then returns the one with the highest IoU with that box (ties broken by highest confidence).

Type Parameters

L

L extends Readonly<Record<string, string | number>>

Parameters

instances

SegmentedInstance<L>[]

Array of segmented instances returned by forward().

box

Bbox

The prompt bounding box in image coordinates.

Returns

SegmentedInstance<L> | null

The best matching instance, or null if no instance overlaps.