hrnet
最后更新
depthai_nodes.node.parsers.hrnetClasses
HRNetParser
Note
发出
dai.beta.Keypoints 消息。输出包含检测到的身体关键点。Methods
init
Python
1def __init__(output_layer_name: str = '', score_threshold: float = 0.5, label_names: list[str] | None = None, edges: list[tuple[int, int]] | None = None):output_layer_name(str): 与解析器相关的输出层的名称。score_threshold(float): 检测到的关键点的置信度分数阈值。label_names(list[str] | None): 关键点的标签名称。edges(list[tuple[int, int]] | None): 定义骨架边缘的关键点索引对。例如,[(0, 1), (1, 2)]将关键点 0 连接到 1,将 1 连接到 2。
build
Python
1def build(head_config: dict[str, Any]) -> HRNetParser:head_config(dict[str, Any]): 解析器的头部配置。
HRNetParser: 设置了头部配置的解析器对象。
compute
Python
1def compute(heatmaps: np.ndarray) -> tuple[np.ndarray, np.ndarray]:Note
使用 depthai_nodes.node.parsers.utils.hrnet.compute_hrnet_keypoints;有关张量布局和验证详细信息,请参阅该辅助函数。
heatmaps(np.ndarray): 形状为(1, keypoints, height, width)或(keypoints, height, width)的热图。当第一个轴的大小为 1 时,该轴将被移除。
tuple[np.ndarray, np.ndarray]: 一对归一化的(N, 2)XY 坐标和裁剪到 [0, 1] 的(N,)峰值分数。
emit
Python
1def emit(output: dai.NNData, keypoints: np.ndarray, scores: np.ndarray):dai.beta.Keypoints 消息并将其发送到 out。复制源时间戳和序列号,并在存在时携带源图像变换。Parametersoutput(dai.NNData): 携带张量、源时间戳、序列号和可选图像变换的神经网络输出。keypoints(np.ndarray):compute()返回的归一化关键点坐标。scores(np.ndarray): 与计算出的有效载荷对应的置信度分数。
extract
Python
1def extract(output: dai.NNData) -> np.ndarray:output(dai.NNData): 携带张量、源时间戳、序列号和可选图像变换的神经网络输出。
np.ndarray: 以 NCHW 存储顺序请求的反量化热图。
ValueError: 如果未配置输出名称且消息不包含恰好一个层,或者未满足配置的类要求。
run
Python
1def run(self):setOutputLayerName
Python
1def setOutputLayerName(output_layer_name: str):output_layer_name(str): 输出层的名称。
Attributes
edges
[(0, 1), (1, 2)] 将关键点 0 连接到 1,将 1 连接到 2。