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

本页目录

  • 如何放置它
  • 输入和输出
  • 用法
  • 功能示例
  • 参考

Warp

Supported on:RVC2RVC4
Warp 节点用于图像的扭曲和反扭曲,可用于校正宽视场摄像头图像的畸变。 该节点还可以用于对图像应用透视变换。

RVC2

Warp 节点使用底层的 warp 硬件块(更多文档请点击这里), 无需额外资源(SHAVE/cmx 核心)。硬件限制:宽度必须是 16 的倍数。

RVC4

Warp 节点也在 Warp 引擎(RVC4 芯片上的硬件块)上运行(请参阅 RVC4)。注意:目前,RVC4 尚不支持色度平面扭曲,因此只能扭曲灰度图像(正确地)。 我们正在与我们的芯片供应商合作以启用此功能。

如何放置它

Python

Python
1with dai.Pipeline() as pipeline:
2    warp = pipeline.create(dai.node.Warp)

C++

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

输入和输出

用法

Python

Python
1with dai.Pipeline() as pipeline:
2    warp = pipeline.create(dai.node.Warp)
3    # 创建自定义扭曲网格
4    p1 = dai.Point2f(20, 20)
5    p2 = dai.Point2f(460, 20)
6    p3 = dai.Point2f(20, 460)
7    p4 = dai.Point2f(460, 460)
8    warp.setWarpMesh([p1,p2,p3,p4], 2, 2)
9    warp.setOutputSize((512,512))
10    warp.setMaxOutputFrameSize(512 * 512 * 3)
11
12    # 扭曲插值模式,可在 BILINEAR、BICUBIC、BYPASS 中选择
13    warp.setInterpolation(dai.Interpolation.BILINEAR)

C++

C++
1dai::Pipeline pipeline;
2
3auto warp = pipeline.create<dai::node::Warp>();
4// 创建自定义扭曲网格
5dai::Point2f p1(20, 20);
6dai::Point2f p2(460, 20);
7dai::Point2f p3(20, 460);
8dai::Point2f p4(460, 460);
9warp->setWarpMesh({p1,p2,p3,p4}, 2, 2);
10warp->setOutputSize({512, 512});
11warp->setMaxOutputFrameSize(512 * 512 * 3);
12
13// 扭曲插值模式,可在 BILINEAR、BICUBIC、BYPASS 中选择
14warp->setInterpolation(dai::node::Warp::Properties::Interpolation::BILINEAR);

功能示例

参考

class

dai::node::Warp

#include Warp.hpp
variable
Input inputImage
Input image to be modified Default queue is blocking with size 8
variable
Output out
Outputs ImgFrame message that carries warped image.
function
void setOutputSize(std::tuple< int, int > size)
Sets output frame size in pixels
Parameters
  • size: width and height in pixels
function
void setOutputSize(int width, int height)
function
void setWarpMesh(const std::vector< Point2f > & meshData, int width, int height)
Set a custom warp mesh
Parameters
  • meshData: 2D plane of mesh points, starting from top left to bottom right
  • width: Width of mesh
  • height: Height of mesh
function
void setWarpMesh(const std::vector< std::pair< float, float >> & meshData, int width, int height)
function
void setNumFramesPool(int numFramesPool)
Specify number of frames in pool.
Parameters
  • numFramesPool: How many frames should the pool have
function
void setMaxOutputFrameSize(int maxFrameSize)
Specify maximum size of output image.
Parameters
  • maxFrameSize: Maximum frame size in bytes
function
void setHwIds(std::vector< int > ids)
Specify which hardware warp engines to use
Parameters
  • ids: Which warp engines to use (0, 1, 2)
function
std::vector< int > getHwIds()
function
void setInterpolation(dai::Interpolation interpolation)
Specify which interpolation method to use
Parameters
  • interpolation: type of interpolation
function
dai::Interpolation getInterpolation()
inline function
DeviceNodeCRTP()
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

需要帮助?

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