detectFacesFromMatBytes method
Future<List<Face> >
detectFacesFromMatBytes(
- Uint8List bytes, {
- required int width,
- required int height,
- int matType = 16,
- FaceDetectionMode mode = FaceDetectionMode.full,
Detects faces from raw pixel bytes without constructing a cv.Mat first.
This avoids the overhead of building a Mat on the calling thread - the bytes are transferred via zero-copy TransferableTypedData and the Mat is reconstructed inside the background isolate.
Parameters:
bytes: Raw pixel data (e.g. BGR, BGRA)width: Image width in pixelsheight: Image height in pixelsmatType: OpenCV MatType value (default: CV_8UC3 = 16 for BGR)mode: Detection mode controlling which features to compute
Throws StateError if initialize has not been called successfully.
Implementation
Future<List<Face>> detectFacesFromMatBytes(
Uint8List bytes, {
required int width,
required int height,
int matType = 16,
FaceDetectionMode mode = FaceDetectionMode.full,
}) async {
_requireReady();
final List<dynamic> result = await _sendDetectionRequest<List<dynamic>>(
'detectMat',
{
'bytes': TransferableTypedData.fromList([bytes]),
'width': width,
'height': height,
'matType': matType,
'mode': mode.name,
},
);
return _applyGates(_deserializeFacesFast(result));
}