Strategies

Contains 3 functions for strategies.

Functions

validate_strategy

Validate that strategy string(s) are valid.

Function Signature

validate_strategy(
) -> Any

Returns

result
Any
The validated strategy (unchanged if valid)

Example

Example
validate_strategy("center")  # Returns "center"
validate_strategy(["center", "bottom_center"])  # Returns ["center", "bottom_center"]
validate_strategy("invalid")  # Raises ValueError

get_anchor_position

Get the position of a specific anchor point on the bounding box.

Function Signature

get_anchor_position(
) -> Any

Returns

result
Any
Tuple of (x, y) coordinates for the anchor point

Example

Example
bbox = [10, 20, 50, 80]
get_anchor_position(bbox, "center")

check_detection_in_region

Check if a detection is within a region based on the trigger strategy.

Function Signature

check_detection_in_region(
) -> Any

Returns

result
Any
True if detection is in region according to strategy, False otherwise

Example

Example
from shapely.geometry import box
bbox = [10, 10, 50, 50]
region = box(0, 0, 100, 100)
check_detection_in_region(bbox, "center", region)