setIoUThreshold method
Sets the Intersection over Union (IoU) threshold.
This threshold is used for non-maximum suppression to filter overlapping detections. Lower values result in fewer overlapping boxes. The value is automatically clamped between 0.0 and 1.0.
Example:
// Use stricter overlap filtering
await controller.setIoUThreshold(0.3);
Implementation
Future<void> setIoUThreshold(double threshold) async {
final clampedThreshold = threshold.clamp(0.0, 1.0);
_iouThreshold = clampedThreshold;
if (_methodChannel == null) {
logInfo(
'YOLOViewController: Warning - Cannot apply IoU threshold, view not yet created',
);
return;
}
try {
await _methodChannel!.invokeMethod('setIoUThreshold', {
'threshold': clampedThreshold,
});
logInfo('YOLOViewController: Applied IoU threshold: $_iouThreshold');
} catch (e) {
logInfo('YOLOViewController: Error applying IoU threshold: $e');
return _applyThresholds();
}
}