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 X and Y translation 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

  1. Provide a shape to the Shape socket (for example, the contour returned from a detector).

  2. Provide horizontal shift to the X socket (optional).

  3. Provide vertical shift to the Y socket (optional).

  4. Read the translated shape from the output Shape socket and use it for drawing, measurement or further processing.

πŸ’‘ Tips and Tricks

  • Combine with detection and ROI blocks:

    • Use Find Contour, Find Object, or Approximate Contour to obtain shapes, then feed them into this block to align or offset results.

    • Use Image ROI, Image ROI Select or Get ROI to 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, Debatch or Batch Concatenation to translate a list of shapes iteratively.

    • To draw translated results for visual verification, send the output to Draw Point, Draw Rectangle or Draw Result On Image.

  • For measurement workflows:

    • After translating shapes, use Measure Position Distance to compute distances between moved and reference positions.

    • Use Minimum Rectangle, Hull Convex or Contour to Image to convert and compare geometric summaries after translation.

  • Visualization and debugging:

    • To visualize translated contours or rectangles on images, route the translated shape into Draw Rectangle or Draw Result On Image and preview with Show Image.

πŸ› οΈ Troubleshooting

  • No change visible after translation:

    • Verify that non-zero values are provided to X or Y.

    • Ensure the drawing/display block (for example Show Image or Draw 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 / Debatch as 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?