# Face Detection

This function block detects human faces in an input image and returns visual and numeric results for downstream processing.

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

`Image Any` The image to analyze for faces (color or grayscale). Provide frames from cameras or loaded images.

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

`Image Any` Annotated image with detected face boxes drawn.

`Face Area Coordinates` List of rectangle coordinates for each detected face.

`Face Count` Number of faces detected in the input image.

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

`Confidence Threshold %` A slider to set minimum detection confidence. Increase to reduce false positives, decrease to be more permissive.

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

* Real-time face detection suitable for live camera frames or static images.
* Returns both visual feedback (annotated image) and structured data (coordinates and count) for downstream logic.
* Adjustable confidence level to control detection strictness.

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

1. Connect an image-producing block (camera or file loader) to the `Image Any` input.
2. Adjust the `Confidence Threshold %` slider to the desired sensitivity.
3. Use the outputs as needed:
   * Preview the annotated image via a display block.
   * Read `Face Area Coordinates` for ROI processing or tracking.
   * Use `Face Count` for alerts, logging or simple analytics.

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

When the block runs, it scans the incoming image for faces above the configured confidence and produces the annotated image, a list of face rectangles, and the detected face count.

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

* For visual inspection, connect this block output to the `Show Image` block to open the image viewer and inspect detections.
* If you only need to monitor one area (e.g., doorway), crop first with `Image ROI Select` to reduce false positives and speed up processing.
* To reduce CPU usage or increase processing speed, insert `Image Resize` before this block to lower frame size.
* Use `Draw Detections` to combine detection rectangles with custom overlays or status text for clearer on-screen results.
* Save examples of successful or failed detections with `Image Logger` for offline review and tuning.
* Preprocess noisy inputs with `Blur` or a thresholding block (like `Image Threshold`) to improve detection stability in low-quality images.

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

* No faces detected: Lower the `Confidence Threshold %` and ensure the image contains clear frontal or slightly angled faces. Try increasing image contrast or use `Image Resize` to a sensible working size.
* Too many false positives: Increase `Confidence Threshold %` and crop the scene with `Image ROI Select` to exclude irrelevant areas.
* Performance issues: Reduce input resolution with `Image Resize` or run detection only on selected frames using a control signal or batching strategy.


---

# 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/ai-blocks/face-detection.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.
