ImageManip

ImageManip node can be used to crop, rotate rectangle area or perform various image transforms: rotate, mirror, flip, perspective transform.

How to place it

pipeline = dai.Pipeline()
manip = pipeline.create(dai.node.ImageManip)
dai::Pipeline pipeline;
auto manip = pipeline.create<dai::node::ImageManip>();

Inputs and Outputs

               ┌───────────────────┐
inputImage     │                   │
──────────────►│                   │
               │                   │        out
               │    ImageManip     ├───────────►
inputConfig    │                   │
──────────────►│                   │
               │                   │
               └───────────────────┘

Message types

Usage

pipeline = dai.Pipeline()
manip = pipeline.create(dai.node.ImageManip)

manip.initialConfig.setResize(300, 300)
manip.initialConfig.setFrameType(dai.ImgFrame.Type.BGR888p)
dai::Pipeline pipeline;
auto manip = pipeline.create<dai::node::ImageManip>();

manip->initialConfig.setResize(300, 300);
manip->initialConfig.setFrameType(dai::ImgFrame::Type::BGR888p);

Image formats supported

ImageManip node supports the following image formats:

  • for RGB input/output types only RGB888p / BGR888p (planar, not interleaved)

  • RAW16 input, but can only for cropping (use-case: depth map), outputting same format

  • can output GRAY8 (either as single plane, or 3-plane RGB as set with setFrameType()), but only from these inputs: RAW8, :code:`GRAY8, YUV420p (ColorCamera isp), NV12 (ColorCamera video / still)

Limitations

Besides limitations mentioned above (unsupported frame formats), there are other limitations:

  • Due to HW warp constraint, rotating/warping can be done only on frames whose width values are multiples of 16.

Examples of functionality

Reference

class depthai.node.ImageManip

ImageManip node. Capability to crop, resize, warp, … incoming image frames

class Connection

Connection between an Input and Output

class Id

Node identificator. Unique for every node on a single Pipeline

getAssetManager(*args, **kwargs)

Overloaded function.

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

  1. getAssetManager(self: depthai.Node) -> depthai.AssetManager

Get node AssetManager as a const reference

getInputRefs(*args, **kwargs)

Overloaded function.

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

  1. getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]

Retrieves reference to node inputs

getInputs(self: depthai.Node) → List[depthai.Node.Input]

Retrieves all nodes inputs

getName(self: depthai.Node)str

Retrieves nodes name

getOutputRefs(*args, **kwargs)

Overloaded function.

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

  1. getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]

Retrieves reference to node outputs

getOutputs(self: depthai.Node) → List[depthai.Node.Output]

Retrieves all nodes outputs

getParentPipeline(*args, **kwargs)

Overloaded function.

  1. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

  2. getParentPipeline(self: depthai.Node) -> depthai.Pipeline

property id

Id of node

property initialConfig

Initial config to use when manipulating frames

property inputConfig

Input ImageManipConfig message with ability to modify parameters in runtime Default queue is blocking with size 8

property inputImage

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

property out

Outputs ImgFrame message that carries modified image.

setCenterCrop(self: depthai.node.ImageManip, arg0: float, arg1: float)None
setCropRect(self: depthai.node.ImageManip, arg0: float, arg1: float, arg2: float, arg3: float)None
setFrameType(self: depthai.node.ImageManip, arg0: depthai.RawImgFrame.Type)None
setHorizontalFlip(self: depthai.node.ImageManip, arg0: bool)None
setKeepAspectRatio(self: depthai.node.ImageManip, arg0: bool)None
setMaxOutputFrameSize(self: depthai.node.ImageManip, arg0: int)None

Specify maximum size of output image.

Parameter maxFrameSize:

Maximum frame size in bytes

setNumFramesPool(self: depthai.node.ImageManip, arg0: int)None

Specify number of frames in pool.

Parameter numFramesPool:

How many frames should the pool have

setResize(self: depthai.node.ImageManip, arg0: int, arg1: int)None
setResizeThumbnail(self: depthai.node.ImageManip, arg0: int, arg1: int, arg2: int, arg3: int, arg4: int)None
setWaitForConfigInput(self: depthai.node.ImageManip, arg0: bool)None

Specify whether or not wait until configuration message arrives to inputConfig Input.

Parameter wait:

True to wait for configuration message, false otherwise

class dai::node::ImageManip : public dai::Node

ImageManip node. Capability to crop, resize, warp, … incoming image frames.

Public Types

using Properties = dai::ImageManipProperties

Public Functions

std::string getName() const override

Retrieves nodes name.

ImageManip(const std::shared_ptr<PipelineImpl> &par, int64_t nodeId)
void setCropRect(float xmin, float ymin, float xmax, float ymax)
void setCenterCrop(float ratio, float whRatio = 1.0f)
void setResize(int w, int h)
void setResizeThumbnail(int w, int h, int bgRed = 0, int bgGreen = 0, int bgBlue = 0)
void setFrameType(dai::RawImgFrame::Type name)
void setHorizontalFlip(bool flip)
void setKeepAspectRatio(bool keep)
void setWaitForConfigInput(bool wait)

Specify whether or not wait until configuration message arrives to inputConfig Input.

Parameters
  • wait: True to wait for configuration message, false otherwise

void setNumFramesPool(int numFramesPool)

Specify number of frames in pool.

Parameters
  • numFramesPool: How many frames should the pool have

void setMaxOutputFrameSize(int maxFrameSize)

Specify maximum size of output image.

Parameters
  • maxFrameSize: Maximum frame size in bytes

Public Members

ImageManipConfig initialConfig

Initial config to use when manipulating frames

Input inputConfig = {*this, "inputConfig", Input::Type::SReceiver, true, 8, {{DatatypeEnum::ImageManipConfig, true}}}

Input ImageManipConfig message with ability to modify parameters in runtime Default queue is blocking with size 8

Input inputImage = {*this, "inputImage", Input::Type::SReceiver, true, 8, {{DatatypeEnum::ImgFrame, true}}}

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

Output out = {*this, "out", Output::Type::MSender, {{DatatypeEnum::ImgFrame, true}}}

Outputs ImgFrame message that carries modified image.

Private Functions

nlohmann::json getProperties() override
std::shared_ptr<Node> clone() override

Private Members

Properties properties
std::shared_ptr<RawImageManipConfig> rawConfig

Got questions?

We’re always happy to help with code or other questions you might have.