# 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 <a href="#inputs" id="inputs"></a>

`Contour` — First contour to compare (reference).

`Contour` — Second contour to compare (query).

## 📤 Outputs <a href="#outputs" id="outputs"></a>

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

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Resemblence` — A read-only label that displays the current resemblance value for quick feedback in the UI.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

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 <a href="#features" id="features"></a>

* 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 <a href="#usage" id="usage"></a>

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 <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* 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 <a href="#troubleshooting" id="troubleshooting"></a>

* 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`).
