此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 类
  • ApplyColormap
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

apply_colormap

最后更新
Python API: depthai_nodes.node.apply_colormap

类

ApplyColormap

一个主机节点,用于将颜色映射应用于二维数组(例如深度图、分割掩码、热图等)。此节点是通用的,并使用每帧最大值归一化。对于深度可视化,请优先使用“ApplyDepthColormap”,以避免因归一化范围变化而引起的闪烁。输入:
  • frame : dai.ImgFrame | dai.beta.Map2D | dai.ImgDetections | dai.SegmentationMask:包含要着色的二维数组的输入消息。
输出:
  • output : dai.ImgFrame:着色后的输出帧(3 通道 BGR)。
参数
  • colormapValue:OpenCV 颜色映射枚举(例如 cv2.COLORMAP_JET)或自定义的 OpenCV 兼容颜色映射 LUT。默认为 cv2.COLORMAP_JET。
  • maxValue:用于归一化的最大值。如果设置为 0,则每帧确定最大值。默认为 0。

方法

init
Python
1def __init__(colormapValue: int | np.ndarray = cv2.COLORMAP_JET, maxValue: int = 0):
初始化图像处理节点。参数
  • colormapValue (int | np.ndarray):OpenCV 颜色映射枚举(例如 cv2.COLORMAP_JET)或自定义的 OpenCV 兼容颜色映射 LUT。默认为 cv2.COLORMAP_JET。
  • maxValue (int):用于归一化的最大值。如果设置为 0,则每帧确定最大值。默认为 0。
build
Python
1def build(frame: dai.Node.Output) -> ApplyColormap:
将输入流连接到节点。参数
  • frame (dai.Node.Output):生成要着色的类地图消息的上游输出。
返回
  • ApplyColormap:已配置的节点实例。
process
Python
1def process(frame: dai.Buffer):
对数字地图进行着色,并发出带有源元数据的图像。参数
  • frame (dai.Buffer):RAW ImgFrame、beta Map2D、SegmentationMask 或带有实例掩码的 ImgDetections。掩码标签 255 为背景。
引发
  • TypeError:如果 ImgFrame 未使用 RAW 像素格式。
  • ValueError:如果消息类型不受支持。
setColormap
Python
1def setColormap(colormapValue: int | np.ndarray):
设置应用于传入地图的颜色映射。参数
  • colormapValue (int | np.ndarray):OpenCV 颜色映射枚举值或自定义的 OpenCV 兼容 LUT。
引发
  • ValueError:如果自定义颜色映射不是形状为 (256, 1, 3) 的 uint8 数组。
setMaxValue
Python
1def setMaxValue(maxValue: int):
设置着色过程中使用的归一化上限。参数
  • maxValue (int):用于归一化的最大输入值。0 表示保持每帧归一化。
引发
  • ValueError:如果上限不是非负整数。