# Object Detection - Custom

This function block detects objects in images using custom model files you provide. It lets you load a detector (weights, config, and class list), choose which classes to detect, and control detection sensitivity with a simple slider. The block outputs an annotated image plus structured detection data for further processing.

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

`Image Any` The image to be analyzed for object detections.

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

`Image Any` Annotated image with detection boxes and labels.

`Object Count` Number of detected objects.

`Object Locations` List of detected object center positions (multiple outputs allowed).

`Object Sizes (w, h)` Width and height for each detected object (multiple outputs allowed).

`Object Class` Class name for each detected object (multiple outputs allowed).

`Rectangles` Bounding rectangle coordinates for each detection (multiple outputs allowed).

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

`Open Weight File` Button to choose the model weights file.

`Open Config File` Button to choose the model configuration file.

`Open Class File` Button to choose a text file listing class names.

`Class Names` Table where available classes are listed and you can enable/disable each class.

`Confidence Threshold %` Slider to set detection confidence sensitivity (higher = stricter).

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* The block requires three resources to run: a weight file, a config file, and a class list file. Load them using the three file buttons.
* After the files are provided, the detector is initialized and remains ready until you change the files.
* When an image is provided to the input, the block runs the detector on the image and outputs:
  * an annotated image with boxes/labels,
  * count and positions,
  * sizes, classes, and rectangle coordinates for each detection.
* Changing weight or config files triggers reloading of the detector so new models are used for subsequent evaluations.

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

* Load-your-own model support (weights, config, and class list).
* Select which classes to detect via an easy checklist.
* Adjustable confidence threshold with immediate effect.
* Outputs both visual results and structured data (counts, positions, sizes, rectangles).
* Works with multiple detected objects and returns results in list form for downstream blocks.

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

1. Click `Open Weight File` and select the model weight file.
2. Click `Open Config File` and select the model configuration file.
3. Click `Open Class File` and select the class names file. The class list will populate automatically.
4. Enable only the classes you want to detect in the `Class Names` table.
5. Adjust `Confidence Threshold %` to balance sensitivity vs false positives.
6. Provide the image to the `Image Any` input and run the scenario to get annotated image and detection data.

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

* To preview results interactively, connect the `Image Any` output to the `Show Image` block.
* If input images are very large and detection is slow, insert `Image Resizer` before this block to lower resolution and increase processing speed.
* Limit analysis to a specific area by using `Image ROI` or `Image ROI Select` upstream so the detector focuses only on regions of interest.
* For tracking detections across frames, link this block’s detection outputs to `Object_Detection_Tracker`.
* If you need custom drawing or overlays beyond the built-in annotations, use `Draw Detections` with the detection rectangles and counts provided by this block.
* Save interesting frames with detections using `Image Logger` or `Image Write` / `Record Video` for later review.
* Monitor performance and GPU usage with `GPU Statistics` when running heavier models.

(hint: enable only required classes and increase the confidence threshold to reduce false positives and speed up post-processing)

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

* Missing model files: Ensure all three files (weight, config, class list) are selected. The block cannot run without them.
* No detections: Try lowering `Confidence Threshold %` or enable more classes in the class table. Also verify the class names file matches the model.
* Too many false detections: Increase `Confidence Threshold %` and enable only the relevant classes to reduce noise.
* Slow performance: Reduce input image size with `Image Resizer` or use smaller models; consider offloading to a GPU if available and monitor with `GPU Statistics`.
* Incorrect class names or mismatched files: Verify the class file corresponds to the loaded model (class order and names must match the model training).

## 🔗 Recommended block combinations <a href="#recommended-combinations" id="recommended-combinations"></a>

* `Show Image` — Preview annotation output.
* `Image Resizer` — Speed up detection on large images.
* `Image ROI` / `Image ROI Select` — Focus detection on specific areas.
* `Object_Detection_Tracker` — Track detected objects over time.
* `Draw Detections` — Custom visualization using detection rectangles and counts.
* `Image Logger` / `Image Write` / `Record Video` — Save annotated results for audit or later analysis.


---

# 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-custom.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.
