detectFromMatBytes method
Detects hands 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 (typically BGR format, 3 bytes per pixel)width: Image width in pixelsheight: Image height in pixelsmatType: OpenCV MatType value (default: CV_8UC3 = 16 for BGR)
Returns a list of Hand objects, one per detected hand.
Throws StateError if called before initialize.
Implementation
Future<List<Hand>> detectFromMatBytes(
Uint8List bytes, {
required int width,
required int height,
int matType = 16,
}) async {
if (!isReady) {
throw StateError(
'HandDetector not initialized. Call initialize() first.');
}
final List<dynamic> result = await _worker!.sendRequest<List<dynamic>>(
'detectMat',
{
'bytes': TransferableTypedData.fromList([bytes]),
'width': width,
'height': height,
'matType': matType,
},
);
return _deserializeHands(result);
}