Match Shapes

This function block compares two shapes (contours) and returns a resemblance score between 0 and 1. It is useful when you want a single numeric measure of how similar two contours are β€” where values closer to 1 mean the shapes are more similar.

πŸ“₯ Inputs

Contour β€” First contour to compare (reference).

Contour β€” Second contour to compare (query).

πŸ“€ Outputs

Resemblence β€” A number between 0 and 1 expressing how similar the two contours are (higher = more similar).

πŸ•ΉοΈ Controls

Resemblence β€” A read-only label that displays the current resemblance value for quick feedback in the UI.

βš™οΈ Running mechanism

When the block runs it accepts two contour inputs, converts them into comparable representations, and computes a single resemblance score. The score is presented both as the output value and on the block's Resemblence label so you can see results immediately.

🎯 Features

  • Quick numeric similarity score for two contours.

  • UI feedback via a live resemblance label.

  • Works with contours produced by other shape analysis and detection blocks.

πŸ“ How to use

  1. Provide two contours to the inputs. Contours can come from detector or contour-processing blocks.

  2. Run the flow; the block returns Resemblence and updates the label for instant inspection.

  3. Use the numeric output for decisions, logging, or further processing.

πŸ’‘ Tips and Tricks

  • If you only have an image, extract contours first using the Find Contour block, then feed the resulting contours into this block.

  • To simplify complex contours (reduce noise or number of points) try Approximate Contour before matching; simpler contours often yield more stable resemblance values.

  • If you need the contour cropped into an image for visual comparison, use Contour to Image and preview the result with Show Image.

  • To compare multiple candidate contours against a reference, combine this block with Most Similar Shape to automatically pick the best match.

  • When matching shapes in specific regions, crop the image first using Image ROI Select so contours come from the expected area.

  • If contours originate from images with different scales, normalize sizes with Image Resize or convert contours to cropped images of the same dimensions using Contour to Image.

πŸ› οΈ Troubleshooting

  • If the resemblance seems unexpectedly low: ensure both contours are similarly scaled and oriented. Try simplifying the contours with Approximate Contour or normalizing their image sizes.

  • If the output is unstable across frames, check the contour extraction step (e.g., Find Contour) for noisy detections and consider preprocessing with Blur or Image Threshold.

  • No output or invalid contour input: verify the contour-producing block actually returns contour data (use Debug Input or preview intermediate images with Show Image).

Last updated

Was this helpful?