# Detect Reference

This function block is used to automatically identify objects in an input image based on a reference image. It supports various options for fine-tuning the detection process.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Image` The main image in which the reference object needs to be detected.

`Reference` The reference image of the object that should be matched.

`Mask` An optional mask image that can isolate areas to consider during the detection process.

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

`Image Any` The output image showing the detected objects with matching regions highlighted.

`Rectangle Coordinates` The coordinates of rectangles that bound the detected references, supporting multiple detections.

`Match Percentage` The percentage of match for each detected object.

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

`Match Threshold %` A slider that sets the threshold for acceptance of matches. By tweaking this value, you can minimize false positives.

`Down-size` A slider that reduces the size of the reference image to improve processing speed, allowing for faster detection.

`Rotations` A slider to set the number of rotation slices for detection of objects in various orientations.

`Sweep Angle` A slider range that defines the angle sweep for rotations during object detection.

`Horizontal Flip Search` A checkbox that includes consideration for flipped versions of the reference image, which can aid in detection under certain conditions.

`Estimation Method` A dropdown menu to select the method of estimation for object matching.

`Color Mode` A dropdown menu to select whether to process images in grayscale or color (BGR), with color processing typically increasing accuracy.

## 🎨 Features <a href="#features" id="features"></a>

`Rotational Detection` Effectively detects objects from multiple rotational angles, enhancing detection capabilities.

`Mask Support` The option to use a mask helps concentrate detection on vital areas of the input image, improving efficiency.

`Visual Feedback` The resulting image output clearly displays matched areas, providing real-time feedback on detection results.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. **Connect Input Images**: Link the input image to the `Image` input, and the reference image to the `Reference` input. Optionally, connect a mask to the `Mask` input.
2. **Set Parameters**: Use the sliders and dropdowns to define the desired match threshold, size reduction, rotations, and color mode.
3. **Evaluate**: Run the block to perform object detection. The resulting output will display the matches found in the image.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When executed, this function block effectively analyzes the input image based on the reference provided and outputs the matched image, coordinates, and match percentages.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

<details>

<summary>Improving Detection</summary>

When using the detection, ensure that the reference image is clear and well-lit. Adjusting the `Match Threshold %` can also help in increasing the accuracy of detections.

</details>

<details>

<summary>Using Masks</summary>

If only specific parts of the input image are of interest, utilize the `Mask` input to limit the areas considered by the detection process, enhancing both speed and accuracy.

</details>

<details>

<summary>Rotation Adjustments</summary>

Experiment with the `Rotations` and `Sweep Angle` controls to find optimal settings for detecting objects that may appear in various orientations.

</details>

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>No Matches Found</summary>

If you receive no matches, verify that the reference image accurately represents the object in the input image and adjust the `Match Threshold %` to a lower value for a more lenient match.

</details>

<details>

<summary>Performance Issues</summary>

If performance is lagging, consider reducing the `Down-size` setting, which will allow the detection process to operate on a smaller image, speeding up computation.

</details>

<details>

<summary>None Detected Areas</summary>

If certain regions of the input image do not yield results, check the `Mask` input for any potential blockages or enhance the reference image against the specific instances you expect to detect.

</details>
