initialize method

Future<void> initialize([
  1. SegmenterConfig? config
])

Initialize the processor.

This must be called before processing frames. Automatically creates the appropriate platform-specific segmenter.

If you have a custom legacySegmenter, set it before calling initialize.

Implementation

Future<void> initialize([SegmenterConfig? config]) async {
  // Create platform-specific segmenter via conditional import factory
  _platformSegmenter = createSegmenter();

  // Initialize the platform segmenter
  await _platformSegmenter.initialize(config ?? const SegmenterConfig());

  // Also initialize legacy segmenter if provided
  if (legacySegmenter != null) {
    await legacySegmenter!.initialize();
  }

  _isInitialized = true;
  debugPrint(
      'VirtualBackgroundProcessor: Initialized with ${_platformSegmenter.platformName}');
}