# Object\_Detection\_Tracker

This function block tracks objects across frames using detection results you provide. It assigns consistent IDs to moving objects, maintains a short history for each track (including a stable class label when available), and outputs an annotated image plus lists you can use for counting, logging, or higher-level analytics.

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

`Input Image` The current image frame used for visualization and tracking context.

`Detected Rectangles` A list of detected bounding boxes. Provide the detection rectangles generated by an object detection function block.

`Detected Classes` A list of class names corresponding to the provided detections. Used to build a stable class label per tracked object.

Note: These are input sockets. Feed detections from an object detection block into these sockets.

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

`Result Image` An image annotated with bounding boxes, IDs and class labels for each active track.

`Position - ID List` A list of tracked object center positions with their assigned IDs and stable class names.

`Rectangle - ID List` A list of bounding rectangles paired with assigned IDs and stable class names.

Note: These are output sockets. Use them to visualize, count, or forward tracking data to other blocks.

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

This function block has no user-facing controls on the block itself. Behavior is driven by the detection inputs you provide and by how upstream blocks configure detection sensitivity and frequency.

## ⚙️ Running mechanism <a href="#how-it-works" id="how-it-works"></a>

* The block receives per-frame detections (rectangles and classes) together with the current frame image.
* It associates new detections with existing tracks to keep identities consistent across frames.
* For each track the block maintains a short history of class detections so that the displayed class becomes stable (it avoids quick class flipping due to momentary misclassifications).
* The block also tolerates short misses (temporary frames without detections) so tracks do not disappear immediately, and it removes tracks that remain inactive for a longer time.
* Outputs include an annotated image for visualization and structured lists (positions and rectangles paired with IDs and class names) for downstream processing.

This behavior is automatic; you control tracking result quality mainly by the quality and frequency of incoming detections.

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

* Stable ID assignment across frames for each detected object.
* Per-track class stabilization so displayed labels become consistent over time.
* Outputs both visualized results and structured lists for analytics or logging.
* Robust to short detection dropouts (temporary missed detections).
* Creates new tracks for unmatched detections and retires stale tracks automatically.

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

1. Connect an image source to the `Input Image` socket (examples: USB camera, IP camera, stream or preloaded frames).
2. Connect a detection block to supply rectangles and class names into `Detected Rectangles` and `Detected Classes` sockets.
3. Use the `Result Image` to preview the tracking output.
4. Use the `Position - ID List` and `Rectangle - ID List` outputs to feed downstream blocks for counting, logging or analytics.

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

* For best results, feed this block with reliable detections from an object detection block such as `Object Detection`, `Object Detection - Custom`, or `Object Detection (D-FINE)`.
* To visualize detections before/after tracking, connect `Result Image` to a `Show Image` or `Draw Detections` block.
* To record visual results, send `Result Image` to `Image Logger` or `Record Video`.
* To focus tracking on a specific area, crop the input first with `Image ROI`, `Image ROI Select` or `Image ROI Polygon` before feeding detections.
* To filter false detections or to count only objects inside a region, combine this block's `Rectangle - ID List` with `Rectangles in Rectangle` or `Check Area (Polygon)`.
* Use the `Rectangle - ID List` output to feed higher-level applications such as `Traffic Intersection Analysis` for traffic counting or area-crossing events.
* If detections are noisy, try adding preprocessing like `Blur`, `Image Threshold` or `HSV Filter` upstream to improve detection quality before tracking.

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

* No tracks appear: Verify that the `Detected Rectangles` and `Detected Classes` sockets receive valid detection data from an object detection block.
* IDs change rapidly or labels flip often: Improve detection stability (better detector, preprocessing) or reduce detection noise so the block can build a stable class history.
* Tracks disappear too quickly: Ensure detections are provided for consecutive frames; if you have intermittent detections, consider smoothing or increasing detection frequency upstream.
* Lots of short-lived tracks: Try filtering small or low-confidence detections before sending them in, or use region cropping (e.g., `Image ROI Select`) to reduce false positives.

If you need a quick example setup: USB camera (`Camera USB`) -> an object detection block (for example `Object Detection (D-FINE)`) -> `Object_Detection_Tracker` -> `Show Image` / `Image Logger` / `Traffic Intersection 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-tracker.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.
