Measure Object Distance
This block measures the distance between two occurrences of a target object found in a source image. It provides a visual preview with markers and numeric outputs for X, Y and Euclidean distances. Use it when you need quick spatial measurements between two similar objects in an image.
π₯ Inputs
Main ImageThe image where the two objects will be located and measured.1st Object ImageA template image (example) of the first object to find.2nd Object ImageA template image (example) of the second object to find.
π€ Outputs
Image AnyVisual result showing the measured objects and markers.DistanceThe computed Euclidean distance between the two detected object centers (displayed with chosen measure factor).X DistanceHorizontal distance between the two detected centers.Y DistanceVertical distance between the two detected centers.
πΉοΈ Controls
Measure FactorEnter a numeric factor to convert pixel distance to real-world units (e.g., mm per pixel).Measured distanceReadout label showing the computed distance for quick reference.Image PreviewVisual area that displays the input image and measurement markers.
βοΈ Running mechanism
When the block runs it searches the Main Image for matches to the two provided object examples, determines the center positions for each found object, and then calculates the X, Y and Euclidean distances between those centers. The measured distance is multiplied by the Measure Factor to provide results in the desired unit. A preview image is updated to show the detected positions and the measurement.
β¨ Features
Visual feedback with markers and annotated preview image for easy verification.
Numeric outputs for precise measurement reporting and further processing.
Lightweight control via a single
Measure Factorinput to convert pixels to real units.Resizable preview area for clearer inspection of results.
π Usage
Provide the scene image to
Main Image.Provide example images for the two objects to
1st Object Imageand2nd Object Image(these should represent what you expect to find).Set
Measure Factorto convert pixel distances to real units (leave as 1 if you want pixel units).Run the flow and check the
Image Anypreview and theDistance,X Distance,Y Distanceoutputs.
π‘ Tips and Tricks
If templates are hard to match in the full scene, crop the area first with
Image ROI Selectto limit the search region and speed up matching.Use
Image ResizerorImage Resizeto standardize image sizes if templates were captured at a different resolution than the main image.Improve matching reliability by preprocessing with
Adjust Colors,Contrast Optimization, orBlurto reduce noise and enhance features.To verify results visually, connect the
Image Anyoutput toShow Imageso you can open the preview in a larger viewer.When measuring across multiple found pairs or tracking over time, save frames with
Image Loggeror export measurements viaCSV Exportfor later analysis.If you already have detected rectangles from an object detector, you can combine this block with detection blocks (for example
Find Objector object detection outputs) to localize templates more robustly before measuring.
π οΈ Troubleshooting
No objects found: make sure the example images closely resemble how the objects appear in the
Main Image(similar scale, orientation and lighting). Consider usingImage ResizeorAdjust Colors.Incorrect distance scale: double-check the
Measure Factorvalue. If you need an accurate real-world scale, measure a known reference object in pixels and derive the factor.Multiple or incorrect matches: crop the search area with
Image ROI Selector increase contrast withContrast Optimizationto reduce false matches.Preview not updating: ensure a valid image is provided to
Main Imageand reopen the preview (for larger view useShow Image).
Last updated
Was this helpful?