> ## 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

<ParamField path="image" type="np.ndarray" required>
  Input image to draw anchor points on in BGR format. Image is modified in-place.
</ParamField>

<ParamField path="detections" type="Detections" required>
  Detection results containing bounding boxes. Each detection must have a 'bbox' attribute with (x1, y1, x2, y2) coordinates.
</ParamField>

<ParamField path="strategy" type="Union[str, List[str]], optional" 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).
</ParamField>

<ParamField path="radius" type="Optional[int]" optional default="None">
  Radius of anchor point circles in pixels. If None, automatically scaled based on image size (minimum 2 pixels).
</ParamField>

<ParamField path="thickness" type="Optional[int]" optional default="None">
  Thickness of circle outline in pixels. Use -1 for filled circles. If None, defaults to -1 (filled).
</ParamField>

<ParamField path="colors" type="Optional[List[tuple]]" optional 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.
</ParamField>

## Returns

<ResponseField name="result" type="np.ndarray">
  Image with anchor points drawn. The input image is modified in-place.
</ResponseField>

## Examples

<CodeGroup>
  ```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(
  ```
</CodeGroup>

## 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.
</Warning>

## 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
</Note>
