# Warp

Warp 节点用于图像扭曲和去扭曲，可用于矫正宽视场相机拍摄的图像。该节点也可用于对图像应用透视变换。

与 [ImageManip](https://docs.luxonis.com/software/depthai-components/nodes/image_manip.md) 节点（setWarpMesh() 函数）相比：

Warp 节点 使用底层的扭曲硬件模块（额外资源请参阅 [此处文档](https://docs.luxonis.com/hardware/platform/rvc/rvc2.md)），无需额外资源（SHAVE/CMX 核心）。硬件限制：宽度必须能被 16
整除。

ImageManip 节点 结合了扭曲硬件模块的能力和 CMX 内存的效率，以实现更高的吞吐量（例如 4k@30 fps）。硬件模块的调度由 SHAVE 核心完成，同时它们还负责色彩空间转换、类型转换（如 YUV420 转 NV12）等。使用
ImageManip 节点的缺点是额外占用 RAM 和 SHAVE 资源。

## 如何放置

#### Python

```python
pipeline = dai.Pipeline()
warp = pipeline.create(dai.node.Warp)
```

#### C++

```cpp
dai::Pipeline pipeline;
auto warp = pipeline.create<dai::node::Warp>();
```

## 输入和输出

## 用法

#### Python

```python
pipeline = dai.Pipeline()

warp = pipeline.create(dai.node.Warp)
# 创建自定义扭曲网格
p1 = dai.Point2f(20, 20)
p2 = dai.Point2f(460, 20)
p3 = dai.Point2f(20, 460)
p4 = dai.Point2f(460, 460)
warp.setWarpMesh([p1,p2,p3,p4], 2, 2)
warp.setOutputSize((512,512))
warp.setMaxOutputFrameSize(512 * 512 * 3)
# 要使用的扭曲引擎（0,1,2）
warp.setHwIds([1])
# 扭曲插值模式，可选 BILINEAR、BICUBIC、BYPASS
warp.setInterpolation(dai.Interpolation.NEAREST_NEIGHBOR)
```

#### C++

```cpp
dai::Pipeline pipeline;

auto warp = pipeline.create<dai::node::Warp>();
// 创建自定义扭曲网格
dai::Point2f p1(20, 20);
dai::Point2f p2(460, 20);
dai::Point2f p3(20, 460);
dai::Point2f p4(460, 460);
warp->setWarpMesh({p1,p2,p3,p4}, 2, 2);
warp->setOutputSize({512, 512});
warp->setMaxOutputFrameSize(512 * 512 * 3);
// 要使用的扭曲引擎（0,1,2）
warp->setHwIds({1});
// 扭曲插值模式，可选 BILINEAR、BICUBIC、BYPASS
warp->setInterpolation(dai::node::Warp::Properties::Interpolation::BYPASS);
```

## 功能示例

 * [网格扭曲](https://docs.luxonis.com/software/depthai/examples/warp_mesh.md)
 * [交互式网格扭曲](https://docs.luxonis.com/software/depthai/examples/warp_mesh_interactive.md)

## 参考

### depthai.node.Warp(depthai.Node)

Kind: Class

Warp node. Capability to crop, resize, warp, ... incoming image frames

#### getHwIds(self) -> list[int]: list[int]

Kind: Method

Retrieve which hardware warp engines to use

#### getInterpolation(self) -> depthai.Interpolation: depthai.Interpolation

Kind: Method

Retrieve which interpolation method to use

#### setHwIds(self, arg0: collections.abc.Sequence [ typing.SupportsInt ])

Kind: Method

Specify which hardware warp engines to use

Parameter ``ids``:
Which warp engines to use (0, 1, 2)

#### setInterpolation(self, arg0: depthai.Interpolation)

Kind: Method

Specify which interpolation method to use

Parameter ``interpolation``:
type of interpolation

#### setMaxOutputFrameSize(self, arg0: typing.SupportsInt)

Kind: Method

Specify maximum size of output image.

Parameter ``maxFrameSize``:
Maximum frame size in bytes

#### setNumFramesPool(self, arg0: typing.SupportsInt)

Kind: Method

Specify number of frames in pool.

Parameter ``numFramesPool``:
How many frames should the pool have

#### setOutputSize()

Kind: Method

#### setWarpMesh()

Kind: Method

#### inputImage

Kind: Property

Input image to be modified Default queue is blocking with size 8

#### out

Kind: Property

Outputs ImgFrame message that carries warped image.

### 需要帮助？

请前往 [OAKChina 官网](https://www.oakchina.cn/) 获取技术支持或解答您的任何疑问。
