Draw Line
This function block lets you interactively mark lines directly on an image using the mouse and simple keyboard shortcuts. Use it to draw single or multiple connected lines, extract coordinates, and get angle information for each segment.
π₯ Inputs
Image Any The image where lines will be drawn. Connect any image-producing block here.
Calculate All Points When set to true, the block returns every pixel coordinate along each drawn segment instead of only end points.
π€ Outputs
Image Any The annotated image showing drawn lines or calculated points.
Line Coordinates A list of line shapes representing each drawn segment.
Angles Rotation or angle values for each line segment.
πΉοΈ Controls
Image Area Click with the left mouse button on the image area to add points and build lines.
Press U Undo the last added point or segment.
Press C Clear all drawn points and lines.
(hint) The image area shows real-time visual feedback as you add, undo, or clear marks.
π¨ Features
Interactive drawing directly on the image with immediate visual feedback.
Keyboard shortcuts for fast editing: undo (
Press U) and clear (Press C).Option to return dense coordinate lists along each line when
Calculate All Pointsis enabled.Angle estimation per segment, useful for orientation or alignment tasks.
π Usage Instructions
Connect an image-producing block to the
Image Anyinput (for example, a camera or an image loader).Click on the image area to place points. Consecutive clicks form line segments.
To get every pixel coordinate along segments, provide a TRUE value to the
Calculate All Pointsinput.Use
Press Uto undo the last point orPress Cto clear all marks.Read the outputs to obtain the annotated image, the
Line Coordinateslist, andAngles.
π Evaluation
When run, this function block updates the interactive image preview with drawn lines and computes outputs based on the current points. If Calculate All Points is enabled, the block expands each segment into its constituent pixel coordinates before returning the results.
π‘ Tips and Tricks
For live camera input, connect
Camera USBorStream Readerto theImage Anyinput to draw directly on live frames.To inspect results visually in a larger window, pair this block with
Show Imageafter the outputs.If you need to restrict drawing to a specific area, crop first with
Image ROI SelectorImage ROI, then feed the cropped image into this block.For fine-grained analysis along a drawn line, enable
Calculate All Pointsand useMeasure Position DistanceorHistogram On Lineon the resulting coordinates or image.Reduce noise before drawing by preprocessing the input with
BlurorDenoisingwhen edges are noisy.When working with very large images, use
Image Resizerto lower resolution for faster interactive performance, then map coordinates back if needed.
π οΈ Troubleshooting
No drawing response: ensure a valid image is connected to the
Image Anyinput and the scenario is running.Points not aligned as expected: zoom or resize the image source consistently between preview and downstream usage, or crop with
Image ROI Selectbefore drawing.Too many coordinates returned: disable
Calculate All Pointsif you only need segment endpoints, or resize the image to reduce point density.
Last updated
Was this helpful?