detectBuffer method

Future<List<DocumentResult>> detectBuffer(
  1. Uint8List bytes,
  2. int width,
  3. int height,
  4. int stride,
  5. int format,
)

Document edge detection bytes - bytes of the image. width - width of the image. height - height of the image. stride - stride of the image. format - format of the image. Returns a List of DocumentResult.

Implementation

Future<List<DocumentResult>> detectBuffer(
    Uint8List bytes, int width, int height, int stride, int format) async {
  if (_normalizer != null) {
    String pixelFormat = 'rgba';
    if (format == ImagePixelFormat.IPF_GRAYSCALED.index) {
      pixelFormat = 'grey';
    } else if (format == ImagePixelFormat.IPF_RGB_888.index) {
      pixelFormat = 'rgb';
    } else if (format == ImagePixelFormat.IPF_BGR_888.index) {
      pixelFormat = 'bgr';
    } else if (format == ImagePixelFormat.IPF_ARGB_8888.index) {
      pixelFormat = 'rgba';
    } else if (format == ImagePixelFormat.IPF_ABGR_8888.index) {
      pixelFormat = 'bgra';
    }
    // log(parse(jsonEncode({
    //   'data': bytes,
    //   'width': width,
    //   'height': height,
    //   'pixelFormat': pixelFormat,
    // })));

    List<dynamic> results = await handleThenable(_normalizer!.detectQuad(
        parse(jsonEncode({
          'data': bytes,
          'width': width,
          'height': height,
          'pixelFormat': pixelFormat,
        })),
        true));
    return _resultWrapper(results);
  }

  return [];
}