# keypoints

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

## Functions

### compute_keypoints

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

重塑并归一化关键点张量。

参数

 * `keypoints` (`np.ndarray`): 模型关键点张量。
 * `n_keypoints` (`int`): 每个预测编码的关键点数量。
 * `scale_factor` (`float`): 用于将模型坐标转换为归一化坐标的非零除数。

返回

 * `np.ndarray`: 形状为 `(n_keypoints, 2)` 或 `(n_keypoints, 3)` 的 Float32 坐标，除以 `scale_factor` 并裁剪到 [0, 1]。

抛出

 * `ValueError`: 如果张量不包含每个关键点的两个或三个坐标。

### normalize_keypoints

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

将关键点坐标归一化到 (0, 1)。

参数

 * `keypoints` (`np.ndarray`): 形状为 (N, 2) 或 (N, K, 2) 的 numpy 数组，其中 N 是关键点集的数量，K 是每个集中的关键点数量。
 * `height` (`int`): 图像的高度。
 * `width` (`int`): 图像的宽度。

返回

 * `np.ndarray`
