# Object Detection

This function block detects common objects in an image and returns both visual and structured detection results. Use it to locate and count items such as people, vehicles, and many COCO classes. It offers quick configuration for confidence and class selection so you can tailor detection to your scenario.

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

* `Image Any` This input accepts the image you want to analyze.

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

* `Image Any` Image annotated with detection boxes and labels.
* `Object Count` Number of detected objects.
* `Object Center Locations` Locations (centers) of detected objects (can be multiple).
* `Object Sizes (w, h)` Width/height pairs for each detected object (can be multiple).
* `Object Class` Class names for each detected object (can be multiple).
* `Rectangles` Bounding rectangle coordinates for each detection (can be multiple).

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

* `Confidence Threshold %` Slider to set minimum confidence for accepting detections. Raising this will reduce false positives; lowering it may detect more objects but include less certain results.
* `Select Detection Class` Dropdown to choose a predefined group of classes (for example: All, Human, Animals, Indoor, Outdoor). Selecting a narrower class group speeds up and focuses detection.

## ⚙️ How it runs <a href="#how-it-works" id="how-it-works"></a>

* When the block runs it processes the incoming image with the internal detector and applies the selected confidence and class filter.
* The annotated image is returned together with structured outputs: count, center positions, sizes, class names, and rectangle coordinates.
* If the detector is still loading, the block provides an informative message and waits until the detector is ready before producing results.

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

* Ready-to-use object detection for many common classes.
* Class-group presets to quickly focus on humans, animals, indoor objects, outdoor objects, or all classes.
* Annotated visual output plus detailed numeric/structured outputs for automation or logging.
* Simple controls to balance detection sensitivity and select desired classes.

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

1. Connect a camera or image source to the `Image Any` input.
2. Choose a suitable `Select Detection Class` preset to limit detection to relevant classes.
3. Adjust `Confidence Threshold %` to get the right balance between missing objects and false positives.
4. Use outputs to drive downstream logic, tracking, visualization, or storage.

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

* For live camera input use one of the image input blocks such as Camera sources or stream readers to feed the detector: Camera options include `Camera USB`, `Camera IP (ONVIF)`, `Stream Reader`, or `Load Image` for offline testing.
* To visualize detections in the UI or a dashboard, connect the annotated image output to `Show Image` or draw overlays with `Draw Detections`.
* For tracking objects across frames, feed detection outputs into `Object_Detection_Tracker` to get stable IDs and trajectories.
* If you only care about a specific area, crop the input first with `Image ROI` or `Image ROI Select` to reduce false detections and improve performance.
* When working with very large images, use `Image Resize` or `Image Resizer` before detection to speed up processing.
* Save interesting frames or records by piping the annotated image into `Image Logger`, `Multi Image Write`, or `Record Video` when a detection count or specific class appears. Combine with logic blocks (for example, manual `Logic Input` or threshold checks) to trigger saving only on events.
* Combine with analysis blocks such as `Measure Position Distance` or ROI checks like `Check Area` to build alerts or analytics (for example, count people in a zone or measure spacing).

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

* If you see too many false positives: increase `Confidence Threshold %` or narrow `Select Detection Class`.
* If detection is slow: resize the input with `Image Resize` or reduce the number of classes searched by selecting a narrower class group.
* If the annotated image looks empty but other outputs show detections: verify the display block (for example `Show Image`) is connected and receiving the annotated image.


---

# 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/object-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.
