detect method

AztecDetectorResult detect([
  1. bool isMirror = false
])

Detects an Aztec Code in an image.

@param isMirror if true, image is a mirror-image of original @return AztecDetectorResult encapsulating results of detecting an Aztec Code @throws NotFoundException if no Aztec Code can be found

Implementation

AztecDetectorResult detect([bool isMirror = false]) {
  // 1. Get the center of the aztec matrix
  final Point pCenter = _getMatrixCenter();

  // 2. Get the center points of the four diagonal points just outside the bull's eye
  //  [topRight, bottomRight, bottomLeft, topLeft]
  final List<ResultPoint> bullsEyeCorners = _getBullsEyeCorners(pCenter);

  if (isMirror) {
    final ResultPoint temp = bullsEyeCorners[0];
    bullsEyeCorners[0] = bullsEyeCorners[2];
    bullsEyeCorners[2] = temp;
  }

  // 3. Get the size of the matrix and other parameters from the bull's eye
  final errorsCorrected = _extractParameters(bullsEyeCorners);

  // 4. Sample the grid
  final BitMatrix bits = _sampleGrid(
    _image,
    bullsEyeCorners[_shift % 4],
    bullsEyeCorners[(_shift + 1) % 4],
    bullsEyeCorners[(_shift + 2) % 4],
    bullsEyeCorners[(_shift + 3) % 4],
  );

  // 5. Get the corners of the matrix.
  final List<ResultPoint> corners = _getMatrixCornerPoints(bullsEyeCorners);

  return AztecDetectorResult(
    bits,
    corners,
    _compact,
    _nbDataBlocks,
    _nbLayers,
    errorsCorrected,
  );
}