ImageManipConfig¶
This message can is used for cropping, warping, rotating, resizing, etc. an image in runtime. It is sent either from the host to ColorCamera or ImageManip.
Examples of functionality¶
Reference¶
-
class
depthai.
ImageManipConfig
ImageManipConfig message. Specifies image manipulation options like:
Crop
Resize
Warp
…
-
getCropConfig
(self: depthai.ImageManipConfig) → depthai.RawImageManipConfig.CropConfig - Returns
Crop configuration
-
getCropXMax
(self: depthai.ImageManipConfig) → float - Returns
Bottom right X coordinate of crop region
-
getCropXMin
(self: depthai.ImageManipConfig) → float - Returns
Top left X coordinate of crop region
-
getCropYMax
(self: depthai.ImageManipConfig) → float - Returns
Bottom right Y coordinate of crop region
-
getCropYMin
(self: depthai.ImageManipConfig) → float - Returns
Top left Y coordinate of crop region
-
getData
(self: object) → numpy.ndarray[numpy.uint8] - Returns
Reference to internal buffer
-
getFormatConfig
(self: depthai.ImageManipConfig) → depthai.RawImageManipConfig.FormatConfig - Returns
Format configuration
-
getRaw
(self: depthai.ADatatype) → depthai.RawBuffer
-
getResizeConfig
(self: depthai.ImageManipConfig) → depthai.RawImageManipConfig.ResizeConfig - Returns
Resize configuration
-
getResizeHeight
(self: depthai.ImageManipConfig) → int - Returns
Output image height
-
getResizeWidth
(self: depthai.ImageManipConfig) → int - Returns
Output image width
-
isResizeThumbnail
(self: depthai.ImageManipConfig) → bool - Returns
True if resize thumbnail mode is set, false otherwise
-
setCenterCrop
(self: depthai.ImageManipConfig, ratio: float, whRatio: float = 1.0) → None Specifies a centered crop.
- Parameter
ratio
: Ratio between input image and crop region (0..1)
- Parameter
whRatio
: Crop region aspect ratio - 1 equals to square, 1.7 equals to 16:9, …
- Parameter
-
setCropRect
(*args, **kwargs) Overloaded function.
setCropRect(self: depthai.ImageManipConfig, xmin: float, ymin: float, xmax: float, xmax: float) -> None
Specifies crop with rectangle with normalized values (0..1)
- Parameter
xmin
: Top left X coordinate of rectangle
- Parameter
ymin
: Top left Y coordinate of rectangle
- Parameter
xmax
: Bottom right X coordinate of rectangle
- Parameter
ymax
: Bottom right Y coordinate of rectangle
setCropRect(self: depthai.ImageManipConfig, coordinates: Tuple[float, float, float, float]) -> None
Specifies crop with rectangle with normalized values (0..1)
- Parameter
coordinates
: Coordinate of rectangle
-
setCropRotatedRect
(self: depthai.ImageManipConfig, rr: depthai.RotatedRect, normalizedCoords: bool = True) → None Specifies crop with rotated rectangle. Optionally as non normalized coordinates
- Parameter
rr
: Rotated rectangle which specifies crop
- Parameter
normalizedCoords
: If true coordinates are in normalized range (0..1) otherwise absolute
- Parameter
-
setData
(*args, **kwargs) Overloaded function.
setData(self: depthai.Buffer, arg0: List[int]) -> None
- Parameter
data
: Copies data to internal buffer
setData(self: depthai.Buffer, arg0: numpy.ndarray[numpy.uint8]) -> None
- Parameter
data
: Copies data to internal buffer
-
setFrameType
(self: depthai.ImageManipConfig, name: depthai.RawImgFrame.Type) → None Specify output frame type.
- Parameter
name
: Frame type
- Parameter
-
setHorizontalFlip
(self: depthai.ImageManipConfig, flip: bool) → None Specify horizontal flip
- Parameter
flip
: True to enable flip, false otherwise
- Parameter
-
setKeepAspectRatio
(self: depthai.ImageManipConfig, keep: bool) → None Specifies to whether to keep aspect ratio or not
-
setResize
(*args, **kwargs) Overloaded function.
setResize(self: depthai.ImageManipConfig, w: int, h: int) -> None
Specifies output image size. After crop stage the image will be stretched to fit.
- Parameter
w
: Width in pixels
- Parameter
h
: Height in pixels
setResize(self: depthai.ImageManipConfig, size: Tuple[int, int]) -> None
Specifies output image size. After crop stage the image will be stretched to fit.
- Parameter
size
: Size in pixels
-
setResizeThumbnail
(*args, **kwargs) Overloaded function.
setResizeThumbnail(self: depthai.ImageManipConfig, w: int, h: int, bgRed: int = 0, bgGreen: int = 0, bgBlue: int = 0) -> None
Specifies output image size. After crop stage the image will be resized by preserving aspect ration. Optionally background can be specified.
- Parameter
w
: Width in pixels
- Parameter
h
: Height in pixels
- Parameter
bgRed
: Red component
- Parameter
bgGreen
: Green component
- Parameter
bgBlue
: Blue component
setResizeThumbnail(self: depthai.ImageManipConfig, size: Tuple[int, int], bgRed: int = 0, bgGreen: int = 0, bgBlue: int = 0) -> None
Specifies output image size. After crop stage the image will be resized by preserving aspect ration. Optionally background can be specified.
- Parameter
size
: Size in pixels
- Parameter
bgRed
: Red component
- Parameter
bgGreen
: Green component
- Parameter
bgBlue
: Blue component
-
setReusePreviousImage
(self: depthai.ImageManipConfig, reuse: bool) → None Instruct ImageManip to not remove current image from its queue and use the same for next message.
- Parameter
reuse
: True to enable reuse, false otherwise
- Parameter
-
setRotationDegrees
(self: depthai.ImageManipConfig, deg: float) → None Specifies clockwise rotation in degrees
- Parameter
deg
: Rotation in degrees
- Parameter
-
setRotationRadians
(self: depthai.ImageManipConfig, rad: float) → None Specifies clockwise rotation in radians
- Parameter
rad
: Rotation in radians
- Parameter
-
setSkipCurrentImage
(self: depthai.ImageManipConfig, skip: bool) → None Instructs ImageManip to skip current image and wait for next in queue.
- Parameter
skip
: True to skip current image, false otherwise
- Parameter
-
setWarpBorderFillColor
(self: depthai.ImageManipConfig, red: int, green: int, blue: int) → None Specifies fill color for border pixels. Example:
setWarpBorderFillColor(255,255,255) -> white
setWarpBorderFillColor(0,0,255) -> blue
- Parameter
red
: Red component
- Parameter
green
: Green component
- Parameter
blue
: Blue component
-
setWarpBorderReplicatePixels
(self: depthai.ImageManipConfig) → None Specifies that warp replicates border pixels
-
setWarpTransformFourPoints
(self: depthai.ImageManipConfig, pt: List[depthai.Point2f], normalizedCoords: bool) → None Specifies warp by supplying 4 points in either absolute or normalized coordinates
- Parameter
pt
: 4 points specifying warp
- Parameter
normalizedCoords
: If true pt is interpreted as normalized, absolute otherwise
- Parameter
-
setWarpTransformMatrix3x3
(self: depthai.ImageManipConfig, mat: List[float]) → None Specifies warp with a 3x3 matrix
- Parameter
mat
: 3x3 matrix
- Parameter
-
class
dai
::
ImageManipConfig
: public dai::Buffer¶ ImageManipConfig message. Specifies image manipulation options like:
Crop
Resize
Warp
…
Public Types
-
using
CropConfig
= RawImageManipConfig::CropConfig¶
-
using
ResizeConfig
= RawImageManipConfig::ResizeConfig¶
-
using
FormatConfig
= RawImageManipConfig::FormatConfig¶
Public Functions
-
ImageManipConfig
()¶ Construct ImageManipConfig message.
-
~ImageManipConfig
() = default¶
-
void
setCropRect
(float xmin, float ymin, float xmax, float ymax)¶ Specifies crop with rectangle with normalized values (0..1)
- Parameters
xmin
: Top left X coordinate of rectangleymin
: Top left Y coordinate of rectanglexmax
: Bottom right X coordinate of rectangleymax
: Bottom right Y coordinate of rectangle
-
void
setCropRect
(std::tuple<float, float, float, float> coordinates)¶ Specifies crop with rectangle with normalized values (0..1)
- Parameters
coordinates
: Coordinate of rectangle
-
void
setCropRotatedRect
(RotatedRect rr, bool normalizedCoords = true)¶ Specifies crop with rotated rectangle. Optionally as non normalized coordinates
- Parameters
rr
: Rotated rectangle which specifies cropnormalizedCoords
: If true coordinates are in normalized range (0..1) otherwise absolute
-
void
setCenterCrop
(float ratio, float whRatio = 1.0f)¶ Specifies a centered crop.
- Parameters
ratio
: Ratio between input image and crop region (0..1)whRatio
: Crop region aspect ratio - 1 equals to square, 1.7 equals to 16:9, …
-
void
setWarpTransformFourPoints
(std::vector<Point2f> pt, bool normalizedCoords)¶ Specifies warp by supplying 4 points in either absolute or normalized coordinates
- Parameters
pt
: 4 points specifying warpnormalizedCoords
: If true pt is interpreted as normalized, absolute otherwise
-
void
setWarpTransformMatrix3x3
(std::vector<float> mat)¶ Specifies warp with a 3x3 matrix
- Parameters
mat
: 3x3 matrix
-
void
setWarpBorderReplicatePixels
()¶ Specifies that warp replicates border pixels
-
void
setWarpBorderFillColor
(int red, int green, int blue)¶ Specifies fill color for border pixels. Example:
setWarpBorderFillColor(255,255,255) -> white
setWarpBorderFillColor(0,0,255) -> blue
- Parameters
red
: Red componentgreen
: Green componentblue
: Blue component
-
void
setRotationDegrees
(float deg)¶ Specifies clockwise rotation in degrees
- Parameters
deg
: Rotation in degrees
-
void
setRotationRadians
(float rad)¶ Specifies clockwise rotation in radians
- Parameters
rad
: Rotation in radians
-
void
setResize
(int w, int h)¶ Specifies output image size. After crop stage the image will be stretched to fit.
- Parameters
w
: Width in pixelsh
: Height in pixels
-
void
setResize
(std::tuple<int, int> size)¶ Specifies output image size. After crop stage the image will be stretched to fit.
- Parameters
size
: Size in pixels
-
void
setResizeThumbnail
(int w, int h, int bgRed = 0, int bgGreen = 0, int bgBlue = 0)¶ Specifies output image size. After crop stage the image will be resized by preserving aspect ration. Optionally background can be specified.
- Parameters
w
: Width in pixelsh
: Height in pixelsbgRed
: Red componentbgGreen
: Green componentbgBlue
: Blue component
-
void
setResizeThumbnail
(std::tuple<int, int> size, int bgRed = 0, int bgGreen = 0, int bgBlue = 0)¶ Specifies output image size. After crop stage the image will be resized by preserving aspect ration. Optionally background can be specified.
- Parameters
size
: Size in pixelsbgRed
: Red componentbgGreen
: Green componentbgBlue
: Blue component
-
void
setHorizontalFlip
(bool flip)¶ Specify horizontal flip
- Parameters
flip
: True to enable flip, false otherwise
-
void
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
-
void
setSkipCurrentImage
(bool skip)¶ Instructs ImageManip to skip current image and wait for next in queue.
- Parameters
skip
: True to skip current image, false otherwise
-
void
setKeepAspectRatio
(bool keep)¶ Specifies to whether to keep aspect ratio or not
-
float
getCropXMin
() const¶ - Return
Top left X coordinate of crop region
-
float
getCropYMin
() const¶ - Return
Top left Y coordinate of crop region
-
float
getCropXMax
() const¶ - Return
Bottom right X coordinate of crop region
-
float
getCropYMax
() const¶ - Return
Bottom right Y coordinate of crop region
-
int
getResizeWidth
() const¶ - Return
Output image width
-
int
getResizeHeight
() const¶ - Return
Output image height
-
CropConfig
getCropConfig
() const¶ - Return
Crop configuration
-
ResizeConfig
getResizeConfig
() const¶ - Return
Resize configuration
-
FormatConfig
getFormatConfig
() const¶ - Return
Format configuration
-
bool
isResizeThumbnail
() const¶ - Return
True if resize thumbnail mode is set, false otherwise
Private Members
-
RawImageManipConfig &
cfg
¶
Got questions?
We’re always happy to help with code or other questions you might have.