# ImageManipConfig

This message can is used for cropping, warping, rotating, resizing, etc. an image in runtime. It can be sent from
host/[Script](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/script.md) node to either
[Camera](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/camera.md) or
[ImageManip](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/image_manip.md).

> This message will reconfigure the whole config of the node, meaning you need to set all settings, not just the setting you want
to change.

## Reference

### dai::ImageManipConfig

Kind: class

ImageManipConfig message. Specifies image manipulation options like: Crop; Resize; Warp; ...

#### ImageManipOpsBase < Container >::ResizeMode ResizeMode

Kind: enum

#### ImageManipOpsBase < Container > base

Kind: variable

#### ImgFrame::Type outputFrameType

Kind: variable

#### bool reusePreviousImage

Kind: variable

#### bool skipCurrentImage

Kind: variable

#### ImageManipConfig()

Kind: function

#### ~ImageManipConfig()

Kind: function

#### ImageManipConfig & clearOps()

Kind: function

Removes all operations from the list (does not affect output configuration)

#### ImageManipConfig & addCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)

Kind: function

Crops the image to the specified rectangle parameters: x: X coordinate of the top-left corner; y: Y coordinate of the top-left
corner; w: Width of the rectangle; h: Height of the rectangle

#### ImageManipConfig & addCrop(dai::Rect rect, bool normalizedCoords)

Kind: function

Crops the image to the specified rectangle parameters: rect: Rect to crop; normalizedCoords: If true, the coordinates are
normalized to range [0, 1] where 1 maps to the width/height of the image

#### ImageManipConfig & addCropRotatedRect(dai::RotatedRect rotatedRect, bool normalizedCoords)

Kind: function

Crops the image to the specified (rotated) rectangle parameters: rect: RotatedRect to crop; normalizedCoords: If true, the
coordinates are normalized to range [0, 1] where 1 maps to the width/height of the image

#### ImageManipConfig & addScale(float scaleX, float scaleY)

Kind: function

Rescales the image using the specified factors parameters: scaleX: Scale factor for the X axis; scaleY: Scale factor for the Y
axis. If not specified, scaleY is set to the same value as scaleX

#### ImageManipConfig & addRotateDeg(float angle)

Kind: function

Rotates the image around its center by the specified angle in degrees parameters: angle: Angle in radians

#### ImageManipConfig & addRotateDeg(float angle, Point2f center)

Kind: function

Rotates the image around the specified point by the specified angle in degrees parameters: angle: Angle in radians; center: Center
of the rotation using normalized coordinates

#### ImageManipConfig & addFlipHorizontal()

Kind: function

Flips the image horizontally

#### ImageManipConfig & addFlipVertical()

Kind: function

Flips the image vertically

#### ImageManipConfig & addTransformAffine(std::array< float, 4 > matrix)

Kind: function

Applies an affine transformation to the image parameters: matrix: an array containing a 2x2 matrix representing the affine
transformation

#### ImageManipConfig & addTransformPerspective(std::array< float, 9 > matrix)

Kind: function

Applies a perspective transformation to the image parameters: matrix: an array containing a 3x3 matrix representing the
perspective transformation

#### ImageManipConfig & addTransformFourPoints(std::array< dai::Point2f , 4 > src, std::array< dai::Point2f , 4 > dst, bool
normalizedCoords)

Kind: function

Applies a perspective transformation to the image parameters: src: Source points; dst: Destination points; normalizedCoords: If
true, the coordinates are normalized to range [0, 1] where 1 maps to the width/height of the image

#### ImageManipConfig & setOutputSize(uint32_t w, uint32_t h, ResizeMode mode)

Kind: function

Sets the output size of the image parameters: w: Width of the output image; h: Height of the output image; mode: Resize mode. NONE
- no resize, STRETCH - stretch to fit, LETTERBOX - keep aspect ratio and pad with background color, CENTER_CROP - keep aspect
ratio and crop

#### ImageManipConfig & setOutputCenter(bool c)

Kind: function

Centers the content in the output image without resizing parameters: c: True to center the content, false otherwise

#### ImageManipConfig & setColormap(Colormap colormap)

Kind: function

Sets the colormap to be applied to a grayscale image parameters: colormap: Colormap type to be applied

#### ImageManipConfig & setBackgroundColor(uint32_t red, uint32_t green, uint32_t blue)

Kind: function

Sets the rgb background color of the output image parameters: red: Red component of the background color; green: Green component
of the background color; blue: Blue component of the background color

#### ImageManipConfig & setBackgroundColor(uint32_t val)

Kind: function

Sets the grayscale background color of the output image parameters: val: Grayscale value of the background color

#### ImageManipConfig & setFrameType(ImgFrame::Type frameType)

Kind: function

Sets the frame type of the output image parameters: frameType: Frame type of the output image

#### ImageManipConfig & setUndistort(bool undistort)

Kind: function

Sets the undistort flag

#### bool getUndistort()

Kind: function

Gets the undistort flag return: True if undistort is enabled, false otherwise

#### ImageManipConfig & setReusePreviousImage(bool reuse)

Kind: function

Instruct ImageManip to not remove current image from its queue and use the same for next message. parameters: reuse: True to
enable reuse, false otherwise

#### ImageManipConfig & setSkipCurrentImage(bool skip)

Kind: function

Instructs ImageManip to skip current image and wait for next in queue. parameters: skip: True to skip current image, false
otherwise

#### bool getReusePreviousImage()

Kind: function

Instruct ImageManip to not remove current image from its queue and use the same for next message. return: True to enable reuse,
false otherwise

#### bool getSkipCurrentImage()

Kind: function

Instructs ImageManip to skip current image and wait for next in queue. return: True to skip current image, false otherwise

#### DEPTHAI_SERIALIZE(ImageManipConfig, base, outputFrameType, reusePreviousImage, skipCurrentImage)

Kind: function

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

### Need assistance?

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