compose method
Compose a processed frame with a virtual background
This is the main compositing function that blends:
- The person (from original frame, masked by segmentation)
- The background (image, color, or blurred version of original)
Returns a new ui.Image with the composed result
Implementation
Future<ui.Image> compose({
required ProcessedFrame frame,
required VirtualBackground background,
}) async {
switch (background.type) {
case BackgroundType.image:
return _composeWithImage(frame, background);
case BackgroundType.blur:
return _composeWithBlur(frame, background.blurIntensity);
case BackgroundType.color:
return _composeWithColor(frame, background.color ?? Colors.green);
case BackgroundType.video:
// Video backgrounds would need frame-by-frame video processing
// For now, treat as no background
return _createImageFromBytes(
frame.originalBytes, frame.width, frame.height);
case BackgroundType.none:
// No processing needed - return original frame
return _createImageFromBytes(
frame.originalBytes, frame.width, frame.height);
}
}