# Warp

Warp node is used for image warping and dewarping, which can be used to undistort images from wide FOV cameras. The node can also
be used to apply a perspective transform to the image.

Compared to [ImageManip](https://docs.luxonis.com/software/depthai-components/nodes/image_manip.md) node (the setWarpMesh()
function):

Warp node uses underlyting warp HW block (additional [docs here](https://docs.luxonis.com/hardware/platform/rvc/rvc2.md)), with no
extra resources (SHAVE/cmx cores). HW limitation: width must be divisible by 16.

ImageManip node combines the power of warp HW block together the efficiency of CMX memory to achieve higher throughput (e.g. 4k@30
fps). Scheduling of the HW block is done by SHAVE cores which also do color space conversion, type conversion (YUV420 to NV12),
etc. The downside of using ImageManip node is extra RAM and SHAVE usage.

## How to place it

#### Python

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

#### C++

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

## Inputs and Outputs

## Usage

#### Python

```python
pipeline = dai.Pipeline()

warp = pipeline.create(dai.node.Warp)
# Create a custom warp mesh
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)
# Warp engines to be used (0,1,2)
warp.setHwIds([1])
# Warp interpolation mode, choose between BILINEAR, BICUBIC, BYPASS
warp.setInterpolation(dai.Interpolation.NEAREST_NEIGHBOR)
```

#### C++

```cpp
dai::Pipeline pipeline;

auto warp = pipeline.create<dai::node::Warp>();
// Create a custom warp mesh
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);
// Warp engines to be used (0,1,2)
warp->setHwIds({1});
// Warp interpolation mode, choose between BILINEAR, BICUBIC, BYPASS
warp->setInterpolation(dai::node::Warp::Properties::Interpolation::BYPASS);
```

## Examples of functionality

 * [Warp Mesh](https://docs.luxonis.com/software/depthai/examples/warp_mesh.md)
 * [Interactive Warp Mesh](https://docs.luxonis.com/software/depthai/examples/warp_mesh_interactive.md)

## Reference

### 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.

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
