setThresholds method

Future<void> setThresholds({
  1. double? confidenceThreshold,
  2. double? iouThreshold,
  3. int? numItemsThreshold,
})

Sets all thresholds at once.

This is more efficient than setting each threshold individually as it only makes one platform channel call.

Example:

// Set all thresholds at once
await controller.setThresholds(
  confidenceThreshold: 0.7,
  iouThreshold: 0.3,
  numItemsThreshold: 10,
);

Implementation

Future<void> setThresholds({
  double? confidenceThreshold,
  double? iouThreshold,
  int? numItemsThreshold,
}) async {
  if (confidenceThreshold != null) {
    _confidenceThreshold = confidenceThreshold.clamp(0.0, 1.0);
  }
  if (iouThreshold != null) {
    _iouThreshold = iouThreshold.clamp(0.0, 1.0);
  }
  if (numItemsThreshold != null) {
    _numItemsThreshold = numItemsThreshold.clamp(1, 100);
  }
  return _applyThresholds();
}