segmentation
最后更新
depthai_nodes.node.parsers.utils.segmentation函数
compute_segmentation_class_map
Python
1def compute_segmentation_class_map(segmentation_mask: np.ndarray, *, classes_in_one_layer: bool = False, background_class: bool = False) -> np.ndarray:segmentation_mask(np.ndarray): CHW 或 HWC 张量,可选批处理。4D 张量使用其第一个批处理项;最小轴被视为类轴。classes_in_one_layer(bool): 单个通道是否已编码类 ID 而不是前景分数。background_class(bool): 对于多类分数张量,将获胜的类 0 替换为 255。
np.ndarray: HW uint8 标签映射。未分配的像素为 255。单个前景分数通道与零进行比较,并为正像素发出类 0。
ValueError: 如果未批处理的张量不是 3D 或结果值超出 [0, 255]。