Class ImageManipConfig

Inheritance Relationships

Base Type

Class Documentation

class ImageManipConfig : public dai::Buffer

ImageManipConfig message. Specifies image manipulation options like:

Public Types

using ResizeMode = ImageManipOpsBase<Container>::ResizeMode

Public Functions

ImageManipConfig() = default
virtual ~ImageManipConfig()
ImageManipConfig &clearOps()

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)

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 = false)

Crops the image to the specified rectangle

Parameters:
  • rectRect 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 = false)

Crops the image to the specified (rotated) rectangle

Parameters:
  • rectRotatedRect 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 = 0)

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)

Rotates the image around its center by the specified angle in degrees

Parameters:

angle – Angle in radians

ImageManipConfig &addRotateDeg(float angle, Point2f center)

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()

Flips the image horizontally

ImageManipConfig &addFlipVertical()

Flips the image vertically

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

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)

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 = false)

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 = ResizeMode::NONE)

Sets the output size of the image

Parameters:
  • w – Width of the output image

  • h – Height of the output image

  • modeResize 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 = true)

Centers the content in the output image without resizing

Parameters:

c – True to center the content, false otherwise

ImageManipConfig &setColormap(Colormap colormap)

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)

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)

Sets the grayscale background color of the output image

Parameters:

val – Grayscale value of the background color

ImageManipConfig &setFrameType(ImgFrame::Type frameType)

Sets the frame type of the output image

Parameters:

frameType – Frame type of the output image

ImageManipConfig &setUndistort(bool undistort)

Sets the undistort flag

bool getUndistort() const

Gets the undistort flag

Returns:

True if undistort is enabled, false otherwise

ImageManipConfig &setReusePreviousImage(bool reuse)

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)

Instructs ImageManip to skip current image and wait for next in queue.

Parameters:

skip – True to skip current image, false otherwise

bool getReusePreviousImage() const

Instruct ImageManip to not remove current image from its queue and use the same for next message.

Returns:

True to enable reuse, false otherwise

bool getSkipCurrentImage() const

Instructs ImageManip to skip current image and wait for next in queue.

Returns:

True to skip current image, false otherwise

DEPTHAI_SERIALIZE(ImageManipConfig, base, outputFrameType, reusePreviousImage, skipCurrentImage)
virtual void serialize(std::vector<std::uint8_t> &metadata, DatatypeEnum &datatype) const override

Public Members

ImageManipOpsBase<Container> base
ImgFrame::Type outputFrameType = ImgFrame::Type::NONE
bool reusePreviousImage = false
bool skipCurrentImage = false