detect method

Future<List<Hand>> detect(
  1. Uint8List imageBytes
)

Detects hands in an image from raw bytes.

Decodes the image bytes using OpenCV and performs hand detection in a background isolate.

Parameters:

  • imageBytes: Raw image data in a supported format (JPEG, PNG, etc.)

Returns a list of Hand objects, one per detected hand.

Throws StateError if called before initialize. Throws FormatException if the image bytes cannot be decoded.

Implementation

Future<List<Hand>> detect(Uint8List imageBytes) async {
  if (!isReady) {
    throw StateError(
        'HandDetector not initialized. Call initialize() first.');
  }
  final List<dynamic> result;
  try {
    result = await _worker!.sendRequest<List<dynamic>>(
      'detect',
      {
        'bytes': TransferableTypedData.fromList([imageBytes]),
      },
    );
  } catch (e) {
    rethrowOrFormatException(e, imageBytes);
  }
  return _deserializeHands(result);
}