findStartGuardPattern static method

List<int> findStartGuardPattern(
  1. BitArray row
)

Implementation

static List<int> findStartGuardPattern(BitArray row) {
  bool foundStart = false;
  late List<int> startRange;
  int nextStart = 0;
  final counters = List.filled(startEndPattern.length, 0);
  while (!foundStart) {
    counters.fillRange(0, startEndPattern.length, 0);

    startRange =
        _findGuardPattern(row, nextStart, false, startEndPattern, counters);
    final start = startRange[0];
    nextStart = startRange[1];
    // Make sure there is a quiet zone at least as big as the start pattern before the barcode.
    // If this check would run off the left edge of the image, do not accept this barcode,
    // as it is very likely to be a false positive.
    final quietStart = start - (nextStart - start);
    if (quietStart >= 0) {
      foundStart = row.isRange(quietStart, start, false);
    }
  }
  return startRange;
}