processFile method
Future<SegmentationResult>
processFile(
- String filePath,
- Uint8List frameData,
- SegmenterInputMetadata metadata
override
Process an image file and return segmentation result.
This is more reliable than processFrame as ML Kit can decode the image directly from the file path.
Parameters:
filePath: Path to image file (JPEG, PNG, etc.)frameData: Original RGBA frame data for compositingmetadata: Image dimensions for mask scaling
Implementation
@override
Future<SegmentationResult> processFile(
String filePath,
Uint8List frameData,
SegmenterInputMetadata metadata,
) async {
// On iOS/macOS with native initialized, use real segmentation with the file
if (_supportsNativeSegmentation && _nativeInitialized) {
try {
// Read file as bytes and send to native
final file = File(filePath);
if (await file.exists()) {
final imageBytes = await file.readAsBytes();
return _processWithNativeBytes(imageBytes, frameData, metadata);
}
} catch (e) {
// Fall through to stub
}
}
// Fallback: Return all-white mask
return _createStubResult(frameData, metadata);
}