detection
最后更新
depthai_nodes.node.parsers.detectionClasses
DetectionParser
(N, 4) 的边界框,格式为 [xmin, ymin, xmax, ymax],以及形状为 (N,) 的分数。输出是一个 dai.ImgDetections 消息,其中包含检测到的对象及其置信度分数。Methods
init
Python
1def __init__(conf_threshold: float = 0.5, iou_threshold: float = 0.5, max_det: int = 100, label_names: list[str] | None = None):conf_threshold(float): 检测到的边界框的置信度分数阈值。iou_threshold(float): 非极大值抑制阈值。max_det(int): 要保留的最大检测数量。label_names(list[str] | None): 检测到的对象的可选类名。
build
Python
1def build(head_config) -> DetectionParser:head_config(dict[str, Any]): 解析器的头部配置。
DetectionParser: 设置了头部配置的解析器对象。
compute
Python
1def compute(bboxes: np.ndarray, scores: np.ndarray, *, conf_threshold: float, iou_threshold: float, max_det: int) -> tuple[np.ndarray, np.ndarray]:Note
使用 depthai_nodes.node.parsers.utils.detection.compute_detection_outputs;有关张量布局和验证的详细信息,请参阅该帮助程序。
bboxes(np.ndarray): 形状为(N, 4)的边界框,格式为[xmin, ymin, xmax, ymax]。scores(np.ndarray): 形状为(N,)的置信度分数。conf_threshold(float): 用于过滤候选的最小检测置信度。iou_threshold(float): 用于非极大值抑制的交并比阈值。max_det(int): 在抑制期间保留或考虑的最大检测候选数量。
tuple[np.ndarray, np.ndarray]: 保留的中心-XY/宽度/高度框和相应的分数。坐标保留其输入单位。如果没有任何框存活,则两个数组都为空。
emit
Python
1def emit(output: dai.NNData, bboxes: np.ndarray, scores: np.ndarray):dai.ImgDetections 消息并将其发送到 out。复制源时间戳和序列号,并在存在时携带源图像转换。Parametersoutput(dai.NNData): 携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。bboxes(np.ndarray):compute()返回的归一化中心-XY/宽度/高度框。scores(np.ndarray): 与计算负载对应的置信度分数。
extract
Python
1def extract(output: dai.NNData) -> tuple[np.ndarray, np.ndarray]:output(dai.NNData): 携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。
tuple[np.ndarray, np.ndarray]: 一对重塑为(N, 4)的框和展平的分数。框张量由其最终维度(四个)标识。
ValueError: 如果没有正好两个张量可用,或者无法识别框和分数。
run
Python
1def run(self):setConfidenceThreshold
Python
1def setConfidenceThreshold(threshold: float):threshold(float): 检测到的对象的置信度分数阈值。
setIouThreshold
Python
1def setIouThreshold(threshold: float):threshold(float): 非极大值抑制阈值。
setLabelNames
Python
1def setLabelNames(label_names: list[str]):label_names(list[str]): 检测到的对象的标签名称列表。
setMaxDetections
Python
1def setMaxDetections(max_det: int):max_det(int): 要保留的最大检测数量。