Warp¶
Warp node is used for image warping and dewarping, which can be used to undistort images from wide FOV cameras. The node can also be used to apply a perspective transform to the image.
Compared to ImageManip node (the setWarpMesh() function):
Warp node uses underlyting warp HW block (additional docs here), with no extra resources (SHAVE/cmx cores). HW limitation: width must be divisible by 16.
ImageManip node combines the power of warp HW block together the efficiency of CMX memory to achieve higher throughput (e.g. 4k@30 fps). Scheduling of the HW block is done by SHAVE cores which also do color space conversion, type conversion (YUV420 to NV12), etc. The downside of using ImageManip node is extra RAM and SHAVE usage.
How to place it¶
pipeline = dai.Pipeline()
warp = pipeline.create(dai.node.Warp)
dai::Pipeline pipeline;
auto warp = pipeline.create<dai::node::Warp>();
Inputs and Outputs¶
┌────────────┐
inputImage │ │ out
──────────►│ Warp ├──────►
│ │
└────────────┘
Message types
Usage¶
pipeline = dai.Pipeline()
warp = pipeline.create(dai.node.Warp)
# Create a custom warp mesh
p1 = dai.Point2f(20, 20)
p2 = dai.Point2f(460, 20)
p3 = dai.Point2f(20, 460)
p4 = dai.Point2f(460, 460)
warp.setWarpMesh([p1,p2,p3,p4], 2, 2)
warp.setOutputSize((512,512))
warp.setMaxOutputFrameSize(512 * 512 * 3)
# Warp engines to be used (0,1,2)
warp.setHwIds([1])
# Warp interpolation mode, choose between BILINEAR, BICUBIC, BYPASS
warp.setInterpolation(dai.Interpolation.NEAREST_NEIGHBOR)
dai::Pipeline pipeline;
auto warp = pipeline.create<dai::node::Warp>();
// Create a custom warp mesh
dai::Point2f p1(20, 20);
dai::Point2f p2(460, 20);
dai::Point2f p3(20, 460);
dai::Point2f p4(460, 460);
warp->setWarpMesh({p1,p2,p3,p4}, 2, 2);
warp->setOutputSize({512, 512});
warp->setMaxOutputFrameSize(512 * 512 * 3);
// Warp engines to be used (0,1,2)
warp->setHwIds({1});
// Warp interpolation mode, choose between BILINEAR, BICUBIC, BYPASS
warp->setInterpolation(dai::node::Warp::Properties::Interpolation::BYPASS);
Examples of functionality¶
Reference¶
-
class
depthai.node.
Warp
-
class
Id
Node identificator. Unique for every node on a single Pipeline
-
getAssetManager
(*args, **kwargs) Overloaded function.
getAssetManager(self: depthai.Node) -> depthai.AssetManager
getAssetManager(self: depthai.Node) -> depthai.AssetManager
-
getHwIds
(self: depthai.node.Warp) → list[int]
-
getInputRefs
(*args, **kwargs) Overloaded function.
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
getInputRefs(self: depthai.Node) -> list[depthai.Node.Input]
-
getInputs
(self: depthai.Node) → list[depthai.Node.Input]
-
getInterpolation
(self: depthai.node.Warp) → depthai.Interpolation
-
getName
(self: depthai.Node) → str
-
getOutputRefs
(*args, **kwargs) Overloaded function.
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
getOutputRefs(self: depthai.Node) -> list[depthai.Node.Output]
-
getOutputs
(self: depthai.Node) → list[depthai.Node.Output]
-
getParentPipeline
(*args, **kwargs) Overloaded function.
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
-
setHwIds
(self: depthai.node.Warp, arg0: list[int]) → None
-
setInterpolation
(self: depthai.node.Warp, arg0: depthai.Interpolation) → None
-
setMaxOutputFrameSize
(self: depthai.node.Warp, arg0: int) → None
-
setNumFramesPool
(self: depthai.node.Warp, arg0: int) → None
-
setOutputSize
(*args, **kwargs) Overloaded function.
setOutputSize(self: depthai.node.Warp, arg0: int, arg1: int) -> None
setOutputSize(self: depthai.node.Warp, arg0: tuple[int, int]) -> None
-
setWarpMesh
(*args, **kwargs) Overloaded function.
setWarpMesh(self: depthai.node.Warp, arg0: list[depthai.Point2f], arg1: int, arg2: int) -> None
setWarpMesh(self: depthai.node.Warp, arg0: list[tuple[float, float]], arg1: int, arg2: int) -> None
-
class
-
class
dai::node
::
Warp
: public dai::NodeCRTP<Node, Warp, WarpProperties>¶ Warp node. Capability to crop, resize, warp, … incoming image frames.
Public Functions
-
void
setOutputSize
(std::tuple<int, int> size)¶ Sets output frame size in pixels
- Parameters
size
: width and height in pixels
-
void
setOutputSize
(int width, int height)¶
-
void
setWarpMesh
(const std::vector<Point2f> &meshData, int width, int height)¶ Set a custom warp mesh
- Parameters
meshData
: 2D plane of mesh points, starting from top left to bottom rightwidth
: Width of meshheight
: Height of mesh
-
void
setWarpMesh
(const std::vector<std::pair<float, float>> &meshData, int width, int height)¶
-
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
-
void
setHwIds
(std::vector<int> ids)¶ Specify which hardware warp engines to use
- Parameters
ids
: Which warp engines to use (0, 1, 2)
-
std::vector<int>
getHwIds
() const¶ Retrieve which hardware warp engines to use.
-
void
setInterpolation
(dai::Interpolation interpolation)¶ Specify which interpolation method to use
- Parameters
interpolation
: type of interpolation
-
dai::Interpolation
getInterpolation
() const¶ Retrieve which interpolation method to use.
Public Members
-
Input
inputImage
= {*this, "inputImage", Input::Type::SReceiver, true, 8, true, {{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 warped image.
Public Static Attributes
-
static constexpr const char *
NAME
= "Warp"¶
Private Functions
-
void
setWarpMesh
(const float *meshData, int numMeshPoints, int width, int height)¶
-
void