# Circle Detector

Detect circle patterns in an image and get visual and numeric details about found circles. This block is tuned for circular features (e.g., circular parts, holes, round markers) and exposes intuitive sliders to adapt detection sensitivity and size ranges.

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

* `Image Any` The image to be analyzed for circular shapes.

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

* `Result` Annotated image with detected circles drawn.
* `Positions` List of circle center coordinates (x, y) found in the image.
* `Number of Circles` Count of detected circles.
* `Circles` Detailed circle shapes (center and radius) for downstream processing.

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

* `dp` Inverse ratio of the accumulator resolution to the image resolution (affects detection sensitivity and scale handling).
* `Edge Detection` Controls the internal edge detection sensitivity used for circle finding.
* `Threshold` Controls the accumulator threshold that decides whether a candidate circle is accepted.
* `Min Distance` Minimum distance between circle centers (helps avoid duplicate detections).
* `Min Radius (% width)` Minimum radius to consider, defined as a percentage of image width.
* `Max Radius (% width)` Maximum radius to consider, defined as a percentage of image width.

Adjust these controls interactively to tune detection for your specific camera, lighting and object sizes.

## ⚙️ How it runs <a href="#running-mechanism" id="running-mechanism"></a>

When the block receives an image, it converts the image to grayscale (visual preprocessing) and searches for circular patterns based on the current slider settings. Detected circles are drawn onto a copy of the image and the block outputs the annotated image, the list of center positions, the total count, and the circle shapes (center + radius) for further processing.

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

* Real-time adjustable sliders for quick parameter tuning.
* Outputs both visual results and structured data (positions, counts, circle shapes).
* Radius parameters expressed as percentages make it easy to adapt across different image sizes.
* Avoids duplicate detections using a configurable minimum center distance.

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

1. Feed an image into the `Image Any` input.
2. Use `Min Radius (% width)` and `Max Radius (% width)` to limit detections to the expected object size range.
3. Adjust `Edge Detection` and `Threshold` to reduce false positives or recover missed circles.
4. Inspect results visually via the `Result` output and use `Positions` or `Circles` for automation or counting.

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

* Preprocess noisy images with `Blur` or `Denoising` to reduce spurious detections and smooth edges.
* If objects of interest occupy only part of the scene, crop with `Image ROI Select` before detection to speed up processing and reduce false positives.
* Use `Image Resize` to speed up detection during parameter tuning, then switch back to full resolution for final runs.
* Combine with `Image Threshold` or `Morphological Transformations` to enhance clear circular edges when contrast is low.
* Validate or filter detections by combining outputs with `Blob Detector` or `Find Contour` to confirm shape or area properties.
* Overlay results for presentation using `Draw Detections` and inspect them with `Show Image` for a larger preview window.

Recommended common pipelines:

* For small circular markers: `Image ROI Select` → `Blur` → this block → `Draw Detections` → `Show Image`.
* For low-contrast rings: `Adjust Colors` → `Image Threshold` → `Morphological Transformations` → this block.

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

* No circles detected: increase `Edge Detection` or lower `Threshold`; ensure `Min Radius` and `Max Radius` include the true object size.
* Many false positives: raise `Threshold` or increase `Min Distance` to prevent duplicate/close detections; try `Image Threshold` or `Morphological Transformations` to clean the image.
* Overlapping/duplicate detections: increase `Min Distance` so candidate centers must be farther apart.
* Slow processing: reduce image size with `Image Resize` or limit the search area with `Image ROI Select`.
* Inconsistent results under different lighting: try `Adjust Colors` or use `Blur`/`Denoising` to stabilize input before detection.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/detections-shapes/detectors/circle-detector.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
