setNumItemsThreshold method
Sets the maximum number of items to detect per frame.
Limits the number of detections returned to improve performance. The value is automatically clamped between 1 and 100.
Example:
// Limit to 10 detections per frame
await controller.setNumItemsThreshold(10);
Implementation
Future<void> setNumItemsThreshold(int numItems) async {
final clampedNumItems = numItems.clamp(1, 100);
_numItemsThreshold = clampedNumItems;
if (_methodChannel == null) {
logInfo(
'YOLOViewController: Warning - Cannot apply numItems threshold, view not yet created',
);
return;
}
try {
await _methodChannel!.invokeMethod('setNumItemsThreshold', {
'numItems': clampedNumItems,
});
logInfo(
'YOLOViewController: Applied numItems threshold: $_numItemsThreshold',
);
} catch (e) {
logInfo('YOLOViewController: Error applying numItems threshold: $e');
return _applyThresholds();
}
}