# keypoints

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

## Functions

| Name | Description |
| --- | --- |
| [`compute_keypoints`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/keypoints.md#keypoints-Functions-compute_keypoints) | Reshape and normalize a keypoint tensor. |
| [`normalize_keypoints`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/keypoints.md#keypoints-Functions-normalize_keypoints) | Normalize keypoint coordinates to (0, 1). |

### function `compute_keypoints`

```python
def compute_keypoints(
    keypoints: np.ndarray,
    *,
    n_keypoints: int,
    scale_factor: float = 1.0,
) -> np.ndarray
```

Reshape and normalize a keypoint tensor.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `keypoints` | `np.ndarray` | Model keypoint tensor. | required |
| `n_keypoints` | `int` | Number of keypoints encoded per prediction. | required |
| `scale_factor` | `float` | Nonzero divisor used to convert model coordinates to normalized coordinates. | `1.0` |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` | Float32 coordinates of shape `(n_keypoints, 2)` or `(n_keypoints, 3)`, divided by `scale_factor` and clipped to [0, 1]. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the tensor does not contain two or three coordinates per keypoint. |

### function `normalize_keypoints`

```python
def normalize_keypoints(keypoints: np.ndarray, height: int, width: int) -> np.ndarray
```

Normalize keypoint coordinates to (0, 1).

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `keypoints` | `np.ndarray` | A numpy array of shape (N, 2) or (N, K, 2) where N is the number of keypoint sets and K is the number of keypoint in each set. | required |
| `height` | `int` | The height of the image. | required |
| `width` | `int` | The width of the image. | required |

Returns

| Type | Description |
| --- | --- |
| `np.ndarray` |  |
