`.object_detection_count` in `model_variables.h` did not work

Question/Issue:
In the object detection project, I want to detect only one object at a time. Therefore, I changed the .object_detection_count in model_variables.h from 10 to 1. However, after making this change, the detection results occasionally still show two objects.

Project ID:
499558

Expected Outcome:
In each frame detection, there should always be only one bounding box with the highest detection probability in the image.

Actual Outcome:
The detection results occasionally still show two objects.

Reproducibility:

  • [ ] Always

Environment:

  • Platform: [Seeed Studio XIAO ESP32S3 Sense]
  • Build Environment Details: [Arduino IDE 2.3.2 ]
  • OS Version: [ Windows 10]

Logs/Attachments:
IMG_9812

Additional Information:
I also tried modifying the ei_object_detection_nms = {} in model_variables.h
Both the confidence threshold and the IOU threshold had been changed to 0.7f and 0.1f
However, it seems that these two variables did not have any effect or impact on my detection results.

Hi @nienpingchen

Have you tried adjusting the confidence threshold to a higher value to filter out low-confidence detections?

Best

Eoin

Thanks for your response.
I have set the confidence threshold to 0.7f.

However, the problem is that
most of the time only one object is detected
like:
Object detection bounding boxes:
3 (0.722656) [ x: 56, y: 56, width: 8, height: 8 ]

When two objects are detected, the result looks like:
Object detection bounding boxes:
3 (0.937500) [ x: 56, y: 32, width: 8, height: 8 ]
3 (0.871094) [ x: 56, y: 56, width: 8, height: 8 ]

This means that if I increase the confidence threshold further, for example to 0.8.
Not only will it fail to detect any objects, but also the issue of detecting two objects will not be solved.

My goal is to count the number of patterns passing through the camera, so repeated detections will lead to incorrect counts.
I would like to know if there is a parameter to set a detection limit, or if I need to write a program myself to filter out the extra detection results?

Best Regards,

Hi @nienpingchen

The .object_detection_count parameter is intended to limit the number of objects returned, but setting it to 1 doesn’t guarantee that only one object will be detected in every frame. This is because the model might still find multiple objects, and then non-maximum suppression (NMS) is applied to filter overlapping boxes.

NMS helps in reducing multiple detections of the same object by keeping the detection with the highest confidence score. If your settings are too lenient (e.g., a low IoU threshold), multiple detections of the same object might still be retained, which is what you’re seeing.

Try to tweak the IoU score here to see if you can get better results, in combination with the higher confidence score.

Best

Eoin

1 Like

Hi @nienpingchen,

Would you like to set some time up to discuss this with our Sales/Solutions team in more depth?

Best

Eoin