Perspective Transform
This function block lets you define a quadrilateral region on an image and generate a corrected, top-down (perspectiveβtransformed) view of that region. It is interactive β select four points on the image, drag them to refine, and use keyboard shortcuts to edit your selection.
π₯ Inputs
Imageβ Source image shown inside the block for point selection.
π€ Outputs
Imageβ The perspective-transformed (warped) image of the selected quadrilateral.Transform Matrixβ The perspective transform matrix (useful to feed other blocks that require a perspective or homography matrix).
πΉοΈ Controls
Interactive Image Areaβ Click on the image to add points. Points are shown as an overlay polygon as you add them.Drag Pointsβ Click and drag a point to adjust its position.Cβ Clear all selected points.Uβ Undo the last added point.Help Textβ Small on-block instructions reminding you how to add, drag, clear, and undo points.
Note: The overlay will indicate whether the polygon is complete and highlights the vertex under the mouse for easier adjustment.
βοΈ Running Mechanism
The block displays the connected image so you can interactively pick four points.
If fewer than four points are defined the block returns empty outputs so downstream blocks know the transform is not ready.
Once four points are provided the block orders them, computes the output rectangle size from the selected points, builds a perspective transform, and outputs the warped image together with the transform matrix.
The block caches the last computed transform for the same image and point set to avoid unnecessary recomputation while adjusting other parts of the scenario.
β¨ Features
Interactive, visual ROI selection with click-and-drag editing.
Keyboard shortcuts for fast editing.
Visual overlay shows polygon, vertex highlight, and completion state.
Outputs both the corrected image and the transform matrix for reuse.
Automatic sizing chooses an appropriate output rectangle based on the selected points.
π Usage Instructions
Connect an image-producing block to
Imageinput.Click on the image area inside the block to set up to four corner points (any order).
Drag points to fine-tune their locations.
Use
Uto undo the last point andCto clear all points.When four points are present the block will provide a corrected image and the
Transform Matrixoutput.
π‘ Tips and Tricks
Use
Show Imageto preview the source or transformed image in a larger viewer window while you fine-tune the points.If you need to crop the area first, add
Image ROI SelectorImage ROIbefore this block so you work on a smaller region.If your source image is very large, add
Image Resizerbefore this block to speed up interaction and reduce memory use.The produced
Transform Matrixcan be fed into theSocial Distance Detectorblock as the requiredPerspective Matrixinput to enable real-world distance measurements from the warped view.Save transformed results with
Image Writeif you want to keep a copy of the corrected images.
π οΈ Troubleshooting
If no output appears, ensure four points are defined β the block will not produce a transform until the quadrilateral is complete.
If the warped image looks skewed, adjust the corner points by dragging them; using
Show Imagehelps to inspect details while tuning.If interaction feels slow on large images, insert
Image Resizerbefore this block or work on a cropped region withImage ROI Select.If you accidentally add a point in the wrong place, press
Uto remove the last point orCto start over.
Last updated