# scrfd

Python API: `depthai_nodes.node.parsers.utils.scrfd`

## Functions

### compute_anchor_centers

```python
def compute_anchor_centers(strides: list[int], input_size: tuple[int, int], num_anchors: int) -> dict[int, np.ndarray]:
```

Compute the anchor centers for a given list of strides, input size, and number of anchors.

Parameters

 * `strides` (`list[int]`): List of strides.
 * `input_size` (`tuple[int, int]`): Input size.
 * `num_anchors` (`int`): Number of anchors.

Returns

 * `dict[int, np.ndarray]`: Dictionary of anchor centers.

### compute_scrfd_detections

```python
def compute_scrfd_detections(*, bboxes_concatenated: list[np.ndarray], scores_concatenated: list[np.ndarray], kps_concatenated: list[np.ndarray], feat_stride_fpn: tuple[int, ...] | list[int], input_size: tuple[int, int], num_anchors: int, score_threshold: float, nms_threshold: float, anchors: dict[int, np.ndarray], label_names: list[str] | None = None) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[str] | None]:
```

Decode SCRFD heads into normalized face detections.

Parameters

 * `bboxes_concatenated` (`list[np.ndarray]`): Box-distance tensors ordered by feature-pyramid stride.
 * `scores_concatenated` (`list[np.ndarray]`): Confidence tensors ordered by feature-pyramid stride.
 * `kps_concatenated` (`list[np.ndarray]`): Keypoint-offset tensors ordered by feature-pyramid stride.
 * `feat_stride_fpn` (`tuple[int, ...] | list[int]`): Feature-pyramid strides corresponding to the tensor lists.
 * `input_size` (`tuple[int, int]`): Model input size as `(width, height)`.
 * `num_anchors` (`int`): Number of anchors per feature-map location.
 * `score_threshold` (`float`): Minimum face confidence.
 * `nms_threshold` (`float`): Intersection-over-union threshold for suppression.
 * `anchors` (`dict[int, np.ndarray]`): Mapping from each feature stride to its precomputed anchor centers.
 * `label_names` (`list[str] | None`): Optional class-name lookup indexed by predicted class ID.

Returns

 * `tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[str] | None]`: Normalized center-XY/width/height boxes, scores,
   keypoints, zero-valued face class IDs, and optional mapped class names.

### decode_scrfd

```python
def decode_scrfd(bboxes_concatenated, scores_concatenated, kps_concatenated, feat_stride_fpn, input_size, num_anchors, score_threshold, nms_threshold, anchors):
```

Decode the detection results of SCRFD.

Parameters

 * `bboxes_concatenated` (`list[np.ndarray]`): List of bounding box predictions for each scale.
 * `scores_concatenated` (`list[np.ndarray]`): List of confidence score predictions for each scale.
 * `kps_concatenated` (`list[np.ndarray]`): List of keypoint predictions for each scale.
 * `feat_stride_fpn` (`list[int]`): List of feature strides for each scale.
 * `input_size` (`tuple[int]`): Input size of the model.
 * `num_anchors` (`int`): Number of anchors.
 * `score_threshold` (`float`): Confidence score threshold.
 * `nms_threshold` (`float`): Non-maximum suppression threshold.
 * `anchors` (`dict[int, np.ndarray]`): Dictionary of anchors.

Returns

 * `tuple[np.ndarray, np.ndarray, np.ndarray]`: * `Bounding boxes, confidence`: scores, and keypoints of detected objects.

### distance2bbox

```python
def distance2bbox(points, distance, max_shape=None):
```

Decode distance prediction to bounding box.

Parameters

 * `points` (`np.ndarray`): Shape (n, 2), [x, y].
 * `distance` (`np.ndarray`): Distance from the given point to 4 boundaries (left, top, right, bottom).
 * `max_shape` (`tuple[int, int]`): Shape of the image.

Returns

 * `np.ndarray`: Decoded bboxes.

### distance2kps

```python
def distance2kps(points, distance, max_shape=None):
```

Decode distance prediction to keypoints.

Parameters

 * `points` (`np.ndarray`): Shape (n, 2), [x, y].
 * `distance` (`np.ndarray`): Distance from the given point to 4 boundaries (left, top, right, bottom).
 * `max_shape` (`tuple[int, int]`): Shape of the image.

Returns

 * `np.ndarray`: Decoded keypoints.
