# Object Detection

This function block is designed to detect specific objects in an image using a YOLOv4-based object detection model. Users can select the object class they wish to detect and set a confidence threshold for the detection process.

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

`Image Any` The input image in which objects will be detected.

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

`Image Any` The output shows the modified image with detected objects highlighted by rectangles.

`Object Count` This output returns the total number of detected objects in the input image.

`Object Center Locations` Returns the center points of the detected objects, with the ability to track multiple detections.

`Object Sizes (w, h)` The sizes of detected objects represented by their widths and heights.

`Rectangles` Coordinates of rectangles that bound the detected objects, allowing for multiple detections.

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

`Confidence Threshold %` A slider to adjust the confidence threshold for detections. Adjusting this value helps filter out less certain detections.

`Select Detection Class` A dropdown menu to choose the specific object classes to be detected from the available options.

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

`Multiple Detection Classes` Users can select from predefined classes, such as "All", "Human", "Animals", "Indoor", and "Outdoor".

`Dynamic Confidence Adjustment` The threshold slider allows for real-time adjustments to the sensitivity of the detection algorithm.

`Comprehensive Outputs` Multiple outputs giving detailed feedback about detected objects, including image modifications, counts, and bounding rectangle information.

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

1. **Connect Input**: Attach an image containing potential objects to the input.
2. **Select Class**: Choose a desired class from the `Select Detection Class` dropdown to specify what the object detection algorithm should search for.
3. **Set Confidence**: Adjust the `Confidence Threshold %` slider to set how confident the model should be to consider an object detected.
4. **Evaluate**: Run the block to perform object detection. The modified image and detection results will be provided as outputs.

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

When executed, this function block analyzes the input image for the presence of the selected objects, returning modifications of the original image along with quantitative detection data.

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

<details>

<summary>Choosing Detection Class</summary>

Selecting a specific class (like "Animals" or "Human") can significantly reduce false positives, making the detection process more reliable.

</details>

<details>

<summary>Adjusting Confidence Threshold</summary>

Lowering the confidence threshold allows for detecting more objects but may introduce false detections. It's a good idea to find a balance based on your specific use case.

</details>

<details>

<summary>Using with Other Blocks</summary>

This function block works well in combination with other image processing blocks such as `Image ROI` or `Image Threshold` to prepare the image before detection.

</details>

<details>

<summary>Performance Optimization</summary>

If running detection in real-time, consider reducing input image size before connecting to this block for faster processing.

</details>

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

<details>

<summary>No Detections</summary>

If no objects are detected, ensure valid input images are used and adjust the confidence threshold. You may also want to check if the selected detection class has overlaps with the objects in the image.

</details>

<details>

<summary>Slow Processing Speed</summary>

When detecting objects in larger images, consider resizing the image or using a lower-resolution input, which can significantly speed up detection times.

</details>
