Translate Shape
This function block moves geometric shapes by the specified horizontal and vertical offsets. Use it when you need to shift points, rectangles, circles or contours within your image coordinate space.
π₯ Inputs
Shape A shape to translate. Accepted types:
Single point (x, y)
Rectangle defined by two corner points
Circle defined by center_x, center_y, radius
Contour (an ordered list/array of (x,y) points)
X Horizontal translation value (optional). Integer pixels to move the shape along X. Default is 0 if not provided.
Y Vertical translation value (optional). Integer pixels to move the shape along Y. Default is 0 if not provided.
(All above are input sockets.)
π€ Outputs
Shape The translated shape returned in the same format as the input (point, rectangle, circle, or contour).
(This is an output socket.)
πΉοΈ Controls
This function block has no additional controls or widgets. Provide translations through the input sockets.
βοΈ Running mechanism
When executed, the block reads the provided shape and the optional
XandYtranslation values.Translations are applied as integer pixel offsets. Positive values move the shape right/down, negative values move it left/up.
The block returns the same shape type shifted by the given offsets. For contours, each vertex is shifted by the same (X, Y) offset.
If an unsupported shape type or invalid data is supplied, the block will indicate a configuration error β ensure the shape input matches one of the accepted formats.
β¨ Features
Supports common shape types: point, rectangle, circle and contour.
Keeps output format identical to input format for seamless chaining.
Simple integer-based translation for deterministic positioning.
Works with single shapes or contour arrays for batch geometry transforms.
π Usage instructions
Provide a shape to the
Shapesocket (for example, the contour returned from a detector).Provide horizontal shift to the
Xsocket (optional).Provide vertical shift to the
Ysocket (optional).Read the translated shape from the output
Shapesocket and use it for drawing, measurement or further processing.
π‘ Tips and Tricks
Combine with detection and ROI blocks:
Use
Find Contour,Find Object, orApproximate Contourto obtain shapes, then feed them into this block to align or offset results.Use
Image ROI,Image ROI SelectorGet ROIto crop or focus on a region before translating shapes so coordinates remain consistent within a working region.
Working with multiple shapes or lists:
Use
Batch Processing,DebatchorBatch Concatenationto translate a list of shapes iteratively.To draw translated results for visual verification, send the output to
Draw Point,Draw RectangleorDraw Result On Image.
For measurement workflows:
After translating shapes, use
Measure Position Distanceto compute distances between moved and reference positions.Use
Minimum Rectangle,Hull ConvexorContour to Imageto convert and compare geometric summaries after translation.
Visualization and debugging:
To visualize translated contours or rectangles on images, route the translated shape into
Draw RectangleorDraw Result On Imageand preview withShow Image.
π οΈ Troubleshooting
No change visible after translation:
Verify that non-zero values are provided to
XorY.Ensure the drawing/display block (for example
Show ImageorDraw Rectangle) is receiving the translated shape and the same coordinate system is used.
Unexpected shape format errors:
Confirm that the input shape conforms to one of the supported formats (point, rectangle, circle, or contour).
If working with lists, ensure they are provided through batch or list-compatible flow (use
Batch Processing/Debatchas needed).
Out-of-bounds shapes:
Translations can move shapes outside the image area. If that is a concern, clamp coordinates using downstream checks or crop the ROI before translation.
Last updated
Was this helpful?