getSegmentationMaskFromMat method
Future<SegmentationMask>
getSegmentationMaskFromMat(
- Mat image, {
- IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
- double binaryThreshold = 0.5,
Segments a pre-decoded cv.Mat image to separate foreground from background.
The Mat is NOT disposed by this method - caller is responsible for disposal.
Throws StateError if initializeSegmentation hasn't been called. Throws SegmentationException on inference failure.
Implementation
Future<SegmentationMask> getSegmentationMaskFromMat(
cv.Mat image, {
IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
double binaryThreshold = 0.5,
}) async {
_requireReady();
_requireSegmentationReady();
final f = _extractMatFields(image);
final Map<String, dynamic> result =
await _sendSegmentationRequest<Map<String, dynamic>>('segmentMat', {
'bytes': TransferableTypedData.fromList([f.data]),
'width': f.width,
'height': f.height,
'matType': f.matType,
'outputFormat': outputFormat.index,
'binaryThreshold': binaryThreshold,
});
return _deserializeMask(result);
}