initialize method
Initialize the native virtual background engine.
This loads the segmentation model and prepares the processing pipeline.
useGpu - Whether to use GPU acceleration (recommended on supported devices)
Returns true if initialization was successful.
Implementation
Future<bool> initialize({bool useGpu = true}) async {
if (!isSupported) {
return false;
}
if (_isInitialized) {
return true;
}
try {
final result = await _channel.invokeMethod<Map>('initialize', {
'useGpu': useGpu,
});
final success = result?['success'] as bool? ?? false;
if (success) {
_isInitialized = true;
}
return success;
} catch (e) {
return false;
}
}