getBoundingBoxes method

List<BoundingBox> getBoundingBoxes(
  1. PageIteratorLevel level
)

Retrieves the bounding boxes of the detected text.

Implementation

List<BoundingBox> getBoundingBoxes(PageIteratorLevel level) {
  if (_needsInit) {
    _init();
  }

  final boxes = bindings.flusseract.GetBoundingBoxes(
    handle,
    level.index,
  );
  try {
    final count = boxes.ref.length;
    final data = boxes.ref.boxes.cast<generated.bounding_box>();
    final boundingBoxes = <BoundingBox>[];
    for (var i = 0; i < count; i++) {
      final box = data[i];
      boundingBoxes.add(BoundingBox._(box));
    }
    return boundingBoxes;
  } finally {
    calloc.free(boxes.ref.boxes);
    calloc.free(boxes);
  }
}