YOLO constructor
Creates a new YOLO instance with the specified model path and task.
The modelPath
can refer to a model in assets, internal storage, or absolute path.
The task
specifies what type of inference will be performed.
If useMultiInstance
is true, each YOLO instance gets a unique ID and its own channel.
If false, uses the default channel for backward compatibility.
Implementation
YOLO({
required this.modelPath,
required this.task,
bool useMultiInstance = false,
}) {
if (useMultiInstance) {
// Generate unique instance ID
_instanceId = 'yolo_${DateTime.now().millisecondsSinceEpoch}_$hashCode';
// Create instance-specific channel
final channelName = 'yolo_single_image_channel_$_instanceId';
_channel = MethodChannel(channelName);
// Register this instance with the manager
YOLOInstanceManager.registerInstance(_instanceId, this);
} else {
// Use default values for backward compatibility
_instanceId = 'default';
_channel = _defaultChannel;
_isInitialized = true; // Skip initialization for default mode
}
}