> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datamarkin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Anchors

> Draw anchor points on detected objects based on trigger strategies.

## Overview

Visualizes the anchor points used by the trigger strategy system to determine if detections are within zones or crossing lines. Each anchor point is drawn as a small filled circle at the calculated position on the bounding box. Supports drawing individual anchor points or multiple points simultaneously.

## Function Signature

```python theme={null}
anchors(
    image: np.ndarray,
    detections: Detections,
    strategy: Union[str, List[str]], optional = None,
    radius: Optional[int] = None,
    thickness: Optional[int] = None,
    colors: Optional[List[tuple]] = None
) -> np.ndarray
```

## Parameters

**image** `np.ndarray` *required*

Input image to draw anchor points on in BGR format. Image is modified in-place.

**detections** `Detections` *required*

Detection results containing bounding boxes. Each detection must have a 'bbox' attribute with (x1, y1, x2, y2) coordinates.

**strategy** `Union[str, List[str]], optional` (default: None)

Strategy for determining anchor points to draw. Single string: "center", "bottom\_center", "top\_left", etc. List of strings: Multiple anchor points. None draws all 9 main anchor points (center, corners, edge centers).

**radius** `Optional[int]` (default: None)

Radius of anchor point circles in pixels. If None, automatically scaled based on image size (minimum 2 pixels).

**thickness** `Optional[int]` (default: None)

Thickness of circle outline in pixels. Use -1 for filled circles. If None, defaults to -1 (filled).

**colors** `Optional[List[tuple]]` (default: None)

List of BGR color tuples for custom colors. Colors mapped to unique class\_ids in order of appearance. If None, uses default ColorManager colors.

## Returns

**result** `np.ndarray`

Image with anchor points drawn. The input image is modified in-place.

## Examples

```python Example theme={null}
import cv2
import pixelflow as pf
from ultralytics import YOLO

# Load image and get detections
image = cv2.imread("path/to/image.jpg")
model = YOLO("yolo11n.pt")
outputs = model.predict(image)
detections = pf.results.from_ultralytics(outputs)

# Draw all main anchor points (default)
annotated = pf.annotators.anchors(image, detections)

# Draw bottom center points (useful for ground-based tracking)
annotated = pf.annotators.anchors(image, detections, strategy="bottom_center")

# Draw multiple specific anchor points
corners = ["top_left", "top_right", "bottom_left", "bottom_right"]
annotated = pf.annotators.anchors(image, detections, strategy=corners)

# Custom styling with larger green circles
annotated = pf.annotators.anchors(
```

## Error Handling

> [!WARNING]
>
> This function may raise the following exceptions:
>
> * **AttributeError**: If detections don't have required 'bbox' attribute.
> * **ValueError**: If invalid strategy string is provided.

## Notes

> [!NOTE]
>
> * Anchor points are calculated using the get\_anchor\_position function from strategies module
> * Invalid anchor strategies are skipped gracefully to prevent errors
> * Radius is automatically scaled with image size if not specified
> * All 9 anchor points include: center, 4 corners, and 4 edge centers
> * Colors are applied consistently across detections with the same class\_id


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.