find method

List<UQrFinderInfo> find({
  1. bool tryHarder = true,
  2. int maxSymbols = 8,
})

Implementation

List<UQrFinderInfo> find({bool tryHarder = true, int maxSymbols = 8}) {
  final int maxI = image.height;
  final int maxJ = image.width;
  int iSkip = (3 * maxI) ~/ (4 * _maxModules);
  if (iSkip < _minSkip || tryHarder) iSkip = _minSkip;

  bool done = false;
  final Int32List stateCount = Int32List(5);
  for (int i = iSkip - 1; i < maxI && !done; i += iSkip) {
    _clear(stateCount);
    int currentState = 0;
    for (int j = 0; j < maxJ; j++) {
      if (image.get(j, i)) {
        if ((currentState & 1) == 1) currentState++;
        stateCount[currentState]++;
      } else {
        if ((currentState & 1) == 0) {
          if (currentState == 4) {
            if (_foundPatternCross(stateCount)) {
              final bool confirmed = _handlePossibleCenter(stateCount, i, j);
              if (confirmed) {
                iSkip = 2;
                if (_hasSkipped) {
                  done = _haveMultiplyConfirmedCenters();
                } else {
                  final int rowSkip = _findRowSkip();
                  if (rowSkip > stateCount[2]) {
                    i += rowSkip - stateCount[2] - iSkip;
                    j = maxJ - 1;
                  }
                }
                _clear(stateCount);
                currentState = 0;
                continue;
              }
            }
            stateCount[0] = stateCount[2];
            stateCount[1] = stateCount[3];
            stateCount[2] = stateCount[4];
            stateCount[3] = 1;
            stateCount[4] = 0;
            currentState = 3;
            continue;
          }
          currentState++;
          stateCount[currentState]++;
        } else {
          stateCount[currentState]++;
        }
      }
    }
    if (_foundPatternCross(stateCount)) {
      final bool confirmed = _handlePossibleCenter(stateCount, i, maxJ);
      if (confirmed) {
        iSkip = stateCount[0];
        if (_hasSkipped) done = _haveMultiplyConfirmedCenters();
      }
    }
  }
  return _selectBestPatterns(maxSymbols);
}