# Object Detection (D-FINE)

This function block performs real-time object detection with configurable model size, class filtering, confidence threshold and optional visualization. Use it to detect and localize common objects in images and feed detection results to downstream blocks for tracking, logging or visualization.

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

`Image` The input image to be analyzed. Accepts color or grayscale images.

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

`Result` Annotated image with color-coded bounding boxes. Appears when `Draw Boxes` is enabled.\
`Boxes` List of bounding box coordinates for each detection.\
`Labels` List of detected class names as text strings.\
`Scores` Confidence scores for each detection.

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

`Model Size` Choose model size to trade off speed and accuracy (examples: Nano / Small / Medium / Large / XLarge). Smaller models run faster; larger models give better localization.\
`Select Classes` Choose which object classes to detect. If no classes are selected, all available classes are considered.\
`Draw Boxes` Toggle whether the output image should show drawn bounding boxes and labels.\
`Threshold` Adjust the confidence threshold (0–100%) used to filter detections. Higher values produce fewer, more confident detections.

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

* Multiple model sizes to balance latency and detection quality.
* Class-level filtering to focus on only the objects you care about.
* Confidence thresholding for precision control.
* Built-in, easy-to-read visualization with colored boxes and text labels.
* Uses available hardware acceleration when possible for faster inference.

## 📝 How to Use <a href="#usage" id="usage"></a>

1. Provide an image to the `Image` input.
2. Select a `Model Size` appropriate for your environment (fast vs accurate).
3. Optionally pick specific classes via `Select Classes` to reduce false positives and speed up processing.
4. Set `Threshold` to control detection sensitivity. Start around 30 and adjust up or down.
5. Toggle `Draw Boxes` to preview detections on the `Result` output.

## 📊 What the Block Does <a href="#evaluation" id="evaluation"></a>

When run, the block analyzes the incoming image, returns detected bounding boxes, their labels and confidence scores, and optionally produces a visualization image with boxes and label text.

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

* If your input images are very large and processing is slow, add the `Image Resize` block before this block to reduce image size and increase throughput.
* For small, low-resolution images, try the `Super Resolution` block before detection to improve recognition rates.
* To visualize results in the UI, connect this block to the `Show Image` block or enable `Draw Boxes` and view the `Result` output.
* For multi-frame workflows where you want to track detections over time, feed `Boxes` and `Labels` outputs into the `Object_Detection_Tracker` block.
* Save detection images or examples using `Image Logger` or `Image Write` to build datasets or for debugging.
* Export detection metadata (labels, scores, positions) using `Data to JSON` or `CSV Export` for reporting or downstream systems.
* If you only care about specific areas, crop with `Image ROI` or `Image ROI Select` before detection to reduce false positives and speed up processing.

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

* No detections: try lowering the `Threshold` and/or selecting fewer classes to broaden matching. Also check input image quality; consider `Super Resolution` or better lighting.
* Too many false positives: increase the `Threshold` and restrict `Select Classes` to relevant classes only.
* Slow performance: choose a smaller `Model Size` or add `Image Resize` to reduce input resolution. If a GPU is available, ensure it is enabled in your environment for faster processing.
* Visuals missing: ensure `Draw Boxes` is enabled to get the `Result` annotated image, or connect outputs to `Show Image` to preview.


---

# 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-d-fine.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.
