DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.
此页面由 AI 自动翻译。查看英文原版

本页目录

  • 节点属性
  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 参考

Cast

Cast 节点 用于将 NNData 消息转换为 ImgFrame。这在应用程序需要使用 NeuralNetwork 节点的输出来馈送仅接受 ImgFrame 的节点时非常有用。

节点属性

  • outputFrameType - 输出帧的类型。类型应与 NN 输出帧类型相同。
  • offset - 要应用于输出帧的偏移量。默认为 0
  • scale - 要应用于输出帧的缩放因子。默认为 1
偏移量和缩放因子用于定义像素值的线性变换。公式为 output = input * scale + offset

如何放置

Python

Python
1pipeline = dai.Pipeline()
2cast = pipeline.create(dai.node.Cast)

C++

C++
1dai::Pipeline pipeline;
2auto cast = pipeline.create<dai::node::Cast>();

输入和输出

用法

Python

Python
1pipeline = dai.Pipeline()
2
3nn = pipeline.create(dai.node.NeuralNetwork)
4# 加载自定义 blob
5nn.setBlobPath("path_to_blob")
6
7cast = pipeline.create(dai.node.Cast)
8cast.setOutputFrameType(dai.ImgFrame.Type.BGR888p)
9cast.setScale(1)
10
11# 将 NN 的输出链接到 Cast 的输入
12nn.out.link(cast.input)
13
14# 通过 XLink 将转换后的输出发送到主机
15xout = pipeline.create(dai.node.XLinkOut)
16xout.setStreamName("castOut")
17cast.output.link(xout.input)

C++

C++
1dai::Pipeline pipeline;
2
3auto nn = pipeline.create<dai::node::NeuralNetwork>();
4// 加载自定义 blob
5nn->setBlobPath("path_to_blob");
6
7auto cast = pipeline.create<dai::node::Cast>();
8cast->setOutputFrameType(dai::ImgFrame::Type::BGR888p);
9cast->setScale(1);
10
11// 将 NN 的输出链接到 Cast 的输入
12nn->out.link(cast->input);
13
14// 通过 XLink 将转换后的输出发送到主机
15auto xout = pipeline.create<dai::node::XLinkOut>();
16xout->setStreamName("castOut");
17cast->output.link(xout->input);

功能示例

参考

class

depthai.node.Cast(depthai.Node)

method
setNumFramesPool(self, arg0: typing.SupportsInt) -> Cast: Cast
Set number of frames in pool  Parameter ``numFramesPool``:     Number of frames in pool
method
setOffset(self, arg0: typing.SupportsFloat) -> Cast: Cast
Set offset  Parameter ``offset``:     Offset
method
setOutputFrameType(self, arg0: depthai.RawImgFrame.Type) -> Cast: Cast
Set output frame type  Parameter ``outputType``:     Output frame type
method
property
input
Input NNData or ImgFrame message.
property
output
Output ImgFrame message.
property
passthroughInput
Passthrough input message.

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。