# ImageManip all operations

Showcases all available [ImageManip](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/image_manip.md)
operations:

 * Resize (conf.setOutputSize())
 * Crop (conf.addCrop())
 * Flip vertical (conf.addFlipVertical())
 * Flip horizontal (conf.addFlipHorizontal())
 * Scale (conf.addScale())
 * Rotate (conf.addRotateDeg())
 * Transform (conf.addTransformAffine() and conf.addTransformPerspective())

Each operation is done on a separate ImageManip node, so you can see the effect of each operation separately.

## Demo

This example requires the DepthAI v3 API, see [installation instructions](https://docs.luxonis.com/software-v3/depthai.md).

## Pipeline

### examples/image_manip_all_ops.pipeline.json

```json
{"pipeline": {"connections": [{"node1Id": 12, "node1Output": "out", "node1OutputGroup": "", "node2Id": 36, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 11, "node1Output": "out", "node1OutputGroup": "", "node2Id": 34, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 10, "node1Output": "out", "node1OutputGroup": "", "node2Id": 32, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 9, "node1Output": "out", "node1OutputGroup": "", "node2Id": 30, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 8, "node1Output": "out", "node1OutputGroup": "", "node2Id": 28, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 7, "node1Output": "out", "node1OutputGroup": "", "node2Id": 26, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 6, "node1Output": "out", "node1OutputGroup": "", "node2Id": 24, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 5, "node1Output": "out", "node1OutputGroup": "", "node2Id": 22, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 4, "node1Output": "out", "node1OutputGroup": "", "node2Id": 20, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 3, "node1Output": "out", "node1OutputGroup": "", "node2Id": 18, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 2, "node1Output": "out", "node1OutputGroup": "", "node2Id": 16, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 13, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 11, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 8, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 7, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 9, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 6, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 12, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 10, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 5, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 4, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 3, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 0, "node1Output": "out", "node1OutputGroup": "", "node2Id": 2, "node2Input": "inputImage", "node2InputGroup": ""}, {"node1Id": 13, "node1Output": "out", "node1OutputGroup": "", "node2Id": 38, "node2Input": "in", "node2InputGroup": ""}, {"node1Id": 15, "node1Output": "out", "node1OutputGroup": "", "node2Id": 0, "node2Input": "inputImage", "node2InputGroup": ""}], "globalProperties": {"calibData": null, "cameraTuningBlobSize": null, "cameraTuningBlobUri": "", "leonCssFrequencyHz": 700000000.0, "leonMssFrequencyHz": 700000000.0, "pipelineName": null, "pipelineVersion": null, "sippBufferSize": 18432, "sippDmaBufferSize": 16384, "xlinkChunkSize": -1}, "nodes": [[30, {"alias": "", "id": 30, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 47, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_9_out"}}], [28, {"alias": "", "id": 28, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 46, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_8_out"}}], [26, {"alias": "", "id": 26, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 45, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_7_out"}}], [24, {"alias": "", "id": 24, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 44, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_6_out"}}], [22, {"alias": "", "id": 22, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 43, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_5_out"}}], [20, {"alias": "", "id": 20, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 42, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_4_out"}}], [18, {"alias": "", "id": 18, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 41, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_3_out"}}], [16, {"alias": "", "id": 16, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 40, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_2_out"}}], [15, {"alias": "", "id": 15, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 39, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkIn", "parentId": -1, "properties": {"maxDataSize": 5242880, "numFrames": 8, "streamName": "__x_0__inputImage"}}], [0, {"alias": "", "id": 0, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 2, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 1, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 0, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 8, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [13, {"alias": "", "id": 13, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 38, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 37, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 36, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 18, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [2, {"alias": "", "id": 2, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 5, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 4, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 3, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [], "outputHeight": 200, "outputWidth": 256, "resizeMode": 1, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [32, {"alias": "", "id": 32, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 48, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_10_out"}}], [3, {"alias": "", "id": 3, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 8, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 7, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 6, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [], "outputHeight": 200, "outputWidth": 256, "resizeMode": 2, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [4, {"alias": "", "id": 4, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 11, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 10, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 9, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [], "outputHeight": 200, "outputWidth": 256, "resizeMode": 3, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [34, {"alias": "", "id": 34, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 49, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_11_out"}}], [5, {"alias": "", "id": 5, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 14, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 13, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 12, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 0, "value": {"normalized": false, "offsetX": -50.0, "offsetY": -50.0}}}, {"op": {"index": 7, "value": {"center": false, "height": 200.0, "normalized": false, "width": 150.0}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [6, {"alias": "", "id": 6, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 17, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 16, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 15, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 3, "value": {"center": true, "direction": 1}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [36, {"alias": "", "id": 36, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 50, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_12_out"}}], [7, {"alias": "", "id": 7, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 20, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 19, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 18, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 3, "value": {"center": true, "direction": 0}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [8, {"alias": "", "id": 8, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 23, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 22, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 21, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 2, "value": {"height": 0.5, "mode": 0, "normalized": true, "width": 0.699999988079071}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [38, {"alias": "", "id": 38, "ioInfo": [[["", "in"], {"blocking": true, "group": "", "id": 51, "name": "in", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "XLinkOut", "parentId": -1, "properties": {"maxFpsLimit": -1.0, "metadataOnly": false, "streamName": "__x_13_out"}}], [9, {"alias": "", "id": 9, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 26, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 25, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 24, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 1, "value": {"angle": 1.5707963705062866, "center": true, "normalized": false, "offsetX": 0.0, "offsetY": 0.0}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [10, {"alias": "", "id": 10, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 29, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 28, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 27, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": false, "colormap": 0, "operations": [{"op": {"index": 1, "value": {"angle": 1.5707963705062866, "center": true, "normalized": true, "offsetX": 0.20000000298023224, "offsetY": 0.30000001192092896}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [11, {"alias": "", "id": 11, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 32, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 31, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 30, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 4, "value": {"matrix": [1.0, 0.5, 0.20000000298023224, 1.0]}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}], [12, {"alias": "", "id": 12, "ioInfo": [[["", "out"], {"blocking": false, "group": "", "id": 35, "name": "out", "queueSize": 8, "type": 0, "waitForMessage": false}], [["", "inputImage"], {"blocking": true, "group": "", "id": 34, "name": "inputImage", "queueSize": 3, "type": 3, "waitForMessage": false}], [["", "inputConfig"], {"blocking": true, "group": "", "id": 33, "name": "inputConfig", "queueSize": 3, "type": 3, "waitForMessage": false}]], "logLevel": 3, "name": "ImageManip", "parentId": -1, "properties": {"backend": 0, "initialConfig": {"base": {"background": 0, "backgroundB": 0, "backgroundG": 0, "backgroundR": 0, "center": true, "colormap": 0, "operations": [{"op": {"index": 5, "value": {"matrix": [1.0, 0.20000000298023224, 0.0, 0.10000000149011612, 1.0, 0.0, 0.0010000000474974513, 0.0020000000949949026, 1.0]}}}], "outputHeight": 0, "outputWidth": 0, "resizeMode": 0, "undistort": false}, "outputFrameType": 33, "reusePreviousImage": false, "skipCurrentImage": false}, "numFramesPool": 4, "outputFrameSize": 1048576, "performanceMode": 0}}]]}}
```

## Source code

#### Python

```python
import depthai as dai
import cv2

pipeline = dai.Pipeline()

manip_input = pipeline.create(dai.node.ImageManip)
manip_input.initialConfig.setFrameType(dai.ImgFrame.Type.BGR888p)
inputQueue = manip_input.inputImage.createInputQueue()

manip_ops = [
    # Resize operations. If aspect ratio isn't the same, the image will be stretched/cropped/letterboxed (depending on resize mode)
    # Docs here: https://docs.luxonis.com/software/depthai/resolution-techniques/
    ('resize_stretch', lambda conf: conf.setOutputSize(256, 200, dai.ImageManipConfig.ResizeMode.STRETCH)),
    ('resize_letterbox', lambda conf: conf.setOutputSize(256, 200, dai.ImageManipConfig.ResizeMode.LETTERBOX)),
    ('resize_center_crop', lambda conf: conf.setOutputSize(256, 200, dai.ImageManipConfig.ResizeMode.CENTER_CROP)),
    # Crop the image topLeft (10,40) to bottomRight (310,110)
    ('crop', lambda conf: conf.addCrop(x=50, y=50, w=150, h=200)),
    # Flip the frame vertically/horizontally
    ('flip_vertical', lambda conf: conf.addFlipVertical()),
    ('flip_horizontal', lambda conf: conf.addFlipHorizontal()),
    # Scale the image by 0.7x in x and 0.5x in y
    ('scale', lambda conf: conf.addScale(0.7, 0.5)),
    # Rotate. If center isn't specified, it will rotate around center (0.5, 0.5)
    ('rotate_90_deg', lambda conf: conf.addRotateDeg(90)),
    ('rotate_90_deg_center', lambda conf: conf.addRotateDeg(90, center=dai.Point2f(0.2, 0.3)).setOutputCenter(False)),
    ('transform_affine', lambda conf: conf.addTransformAffine( # Shearing
        [1, 0.5,
         0.2, 1])),
    ('transform_perspective', lambda conf: conf.addTransformPerspective(
        [1.0, 0.2, 0.0,  # First row
        0.1, 1.0, 0.0,  # Second row
        0.001, 0.002, 1.0])),  # Third row
    ('frame_type', lambda conf: conf.setFrameType(dai.ImgFrame.Type.RAW8)), # to Grayscale
]

# Dynamically create ImageManip nodes, apply configurations, and set up queues
queues = {}
for name, config in manip_ops:
    print(name, config)
    manip = pipeline.create(dai.node.ImageManip)
    config(manip.initialConfig)
    manip_input.out.link(manip.inputImage)
    queues[name] = manip.out.createOutputQueue(maxSize=4, blocking=False)

imgFrame = dai.ImgFrame()

input_frame = cv2.imread('../models/lenna.png') # 512x512
# Send 256x256 image to the device
imgFrame.setCvFrame(cv2.pyrDown(input_frame), dai.ImgFrame.Type.BGR888i)
inputQueue.send(imgFrame)

cv2.imshow('input_image', input_frame)

pipeline.start()

for name, queue in queues.items():
    inFrame = queue.get()
    cv2.imshow(name, inFrame.getCvFrame())

key = cv2.waitKey(0)
```

#### C++

```cpp
#include <atomic>
#include <csignal>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <opencv2/opencv.hpp>

#include "depthai/depthai.hpp"

std::atomic<bool> quitEvent(false);

void signalHandler(int) {
    quitEvent = true;
}

int main() {
    signal(SIGTERM, signalHandler);
    signal(SIGINT, signalHandler);

    try {
        // Create pipeline
        dai::Pipeline pipeline;

        // Create input manipulator
        auto manipInput = pipeline.create<dai::node::ImageManip>();
        manipInput->initialConfig->setFrameType(dai::ImgFrame::Type::BGR888p);
        auto inputQueue = manipInput->inputImage.createInputQueue();

        // Define manipulation operations
        std::vector<std::pair<std::string, std::function<void(dai::ImageManipConfig&)>>> manipOps = {
            // Resize operations
            {"resize_stretch", [](dai::ImageManipConfig& conf) { conf.setOutputSize(256, 200, dai::ImageManipConfig::ResizeMode::STRETCH); }},
            {"resize_letterbox", [](dai::ImageManipConfig& conf) { conf.setOutputSize(256, 200, dai::ImageManipConfig::ResizeMode::LETTERBOX); }},
            {"resize_center_crop", [](dai::ImageManipConfig& conf) { conf.setOutputSize(256, 200, dai::ImageManipConfig::ResizeMode::CENTER_CROP); }},
            // Crop operation
            {"crop", [](dai::ImageManipConfig& conf) { conf.addCrop(50, 50, 150, 200); }},
            // Flip operations
            {"flip_vertical", [](dai::ImageManipConfig& conf) { conf.addFlipVertical(); }},
            {"flip_horizontal", [](dai::ImageManipConfig& conf) { conf.addFlipHorizontal(); }},
            // Scale operation
            {"scale", [](dai::ImageManipConfig& conf) { conf.addScale(0.7f, 0.5f); }},
            // Rotate operations
            {"rotate_90_deg", [](dai::ImageManipConfig& conf) { conf.addRotateDeg(90); }},
            {"rotate_90_deg_center",
             [](dai::ImageManipConfig& conf) {
                 conf.addRotateDeg(90, dai::Point2f(0.2f, 0.3f));
                 conf.setOutputCenter(false);
             }},
            // Transform operations
            {"transform_affine",
             [](dai::ImageManipConfig& conf) {
                 std::array<float, 4> matrix = {1.0f, 0.5f, 0.2f, 1.0f};
                 conf.addTransformAffine(matrix);
             }},
            {"transform_perspective",
             [](dai::ImageManipConfig& conf) {
                 std::array<float, 9> matrix = {
                     1.0f,
                     0.2f,
                     0.0f,  // First row
                     0.1f,
                     1.0f,
                     0.0f,  // Second row
                     0.001f,
                     0.002f,
                     1.0f  // Third row
                 };
                 conf.addTransformPerspective(matrix);
             }},
            // Frame type conversion
            {"frame_type", [](dai::ImageManipConfig& conf) { conf.setFrameType(dai::ImgFrame::Type::RAW8); }}};

        // Create manipulator nodes and queues
        std::map<std::string, std::shared_ptr<dai::MessageQueue>> queues;
        for(const auto& [name, config] : manipOps) {
            std::cout << "Creating manipulator: " << name << std::endl;
            auto manip = pipeline.create<dai::node::ImageManip>();
            config(*manip->initialConfig);
            manipInput->out.link(manip->inputImage);
            queues[name] = manip->out.createOutputQueue(4, false);
        }

        // Load and prepare input image
        cv::Mat inputFrame = cv::imread(LENNA_PATH);  // 512x512
        if(inputFrame.empty()) {
            throw std::runtime_error("Could not read input image");
        }

        // Create and send input frame
        auto imgFrame = std::make_shared<dai::ImgFrame>();
        cv::Mat downscaled;
        cv::pyrDown(inputFrame, downscaled);
        imgFrame->setCvFrame(downscaled, dai::ImgFrame::Type::BGR888i);
        inputQueue->send(imgFrame);

        // Display input image
        cv::imshow("input_image", inputFrame);

        // Start pipeline
        pipeline.start();

        // Process and display results
        for(const auto& [name, queue] : queues) {
            auto inFrame = queue->get<dai::ImgFrame>();
            cv::imshow(name, inFrame->getCvFrame());
        }

        // Wait for key press or signal
        while(!quitEvent) {
            if(cv::waitKey(50) >= 0) break;
        }

        // Cleanup
        pipeline.stop();
        pipeline.wait();

    } catch(const std::exception& e) {
        std::cerr << "Error: " << e.what() << std::endl;
        return 1;
    }

    return 0;
}
```

### Need assistance?

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