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.node.Warp.Properties.Interpolation.BYPASS)
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
Warp 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
-
Properties
alias of
depthai.WarpProperties
-
getAssetManager
(*args, **kwargs) Overloaded function.
getAssetManager(self: depthai.Node) -> depthai.AssetManager
Get node AssetManager as a const reference
getAssetManager(self: depthai.Node) -> depthai.AssetManager
Get node AssetManager as a const reference
-
getHwIds
(self: depthai.node.Warp) → List[int] Retrieve which hardware warp engines to use
-
getInputRefs
(*args, **kwargs) Overloaded function.
getInputRefs(self: depthai.Node) -> List[depthai.Node.Input]
Retrieves reference to node inputs
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
-
getInterpolation
(self: depthai.node.Warp) → depthai.WarpProperties.Interpolation Retrieve which interpolation method to use
-
getName
(self: depthai.Node) → str Retrieves nodes name
-
getOutputRefs
(*args, **kwargs) Overloaded function.
getOutputRefs(self: depthai.Node) -> List[depthai.Node.Output]
Retrieves reference to node outputs
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.
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
getParentPipeline(self: depthai.Node) -> depthai.Pipeline
-
property
id
Id of node
-
property
inputImage
Input image to be modified Default queue is blocking with size 8
-
property
out
Outputs ImgFrame message that carries warped image.
-
setHwIds
(self: depthai.node.Warp, arg0: List[int]) → None Specify which hardware warp engines to use
- Parameter
ids
: Maximum frame size in bytes
- Parameter
-
setInterpolation
(self: depthai.node.Warp, arg0: depthai.WarpProperties.Interpolation) → None Specify which interpolation method to use
- Parameter
interpolation
: type of interpolation
- Parameter
-
setMaxOutputFrameSize
(self: depthai.node.Warp, arg0: int) → None Specify maximum size of output image.
- Parameter
maxFrameSize
: Maximum frame size in bytes
- Parameter
-
setNumFramesPool
(self: depthai.node.Warp, arg0: int) → None Specify number of frames in pool.
- Parameter
numFramesPool
: How many frames should the pool have
- Parameter
-
setOutputSize
(*args, **kwargs) Overloaded function.
setOutputSize(self: depthai.node.Warp, arg0: int, arg1: int) -> None
Sets output frame size in pixels
- Parameter
size
: width and height in pixels
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
: Maximum frame size in bytes
-
std::vector<int>
getHwIds
() const¶ Retrieve which hardware warp engines to use.
-
void
setInterpolation
(Properties::Interpolation interpolation)¶ Specify which interpolation method to use
- Parameters
interpolation
: type of interpolation
-
Properties::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
Got questions?
We’re always happy to help with code or other questions you might have.