Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FinderPatternFinder

This class attempts to find finder patterns in a QR Code. Finder patterns are the square markers at three corners of a QR Code.

This class is thread-safe but not reentrant. Each thread must allocate its own object.

author

Sean Owen

Hierarchy

  • FinderPatternFinder

Index

Constructors

constructor

Properties

Private crossCheckStateCount

crossCheckStateCount: Int32Array

Private hasSkipped

hasSkipped: boolean

Private image

image: BitMatrix

image to search

Private possibleCenters

possibleCenters: FinderPattern[]

Private resultPointCallback

resultPointCallback: ResultPointCallback

Static Private CENTER_QUORUM

CENTER_QUORUM: number = 2

Static Protected MAX_MODULES

MAX_MODULES: number = 57

Static Protected MIN_SKIP

MIN_SKIP: number = 3

Methods

Private crossCheckDiagonal

  • crossCheckDiagonal(startI: number, centerJ: number, maxCount: number, originalStateCountTotal: number): boolean
  • After a vertical and horizontal scan finds a potential finder pattern, this method "cross-cross-cross-checks" by scanning down diagonally through the center of the possible finder pattern to see if the same proportion is detected.

    Parameters

    • startI: number

      row where a finder pattern was detected

    • centerJ: number

      center of the section that appears to cross a finder pattern

    • maxCount: number

      maximum reasonable number of modules that should be observed in any reading state, based on the results of the horizontal scan

    • originalStateCountTotal: number

      The original state count total.

    Returns boolean

    true if proportions are withing expected limits

Private crossCheckHorizontal

  • crossCheckHorizontal(startJ: number, centerI: number, maxCount: number, originalStateCountTotal: number): number
  • Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, except it reads horizontally instead of vertically. This is used to cross-cross check a vertical cross check and locate the real center of the alignment pattern.

    Parameters

    • startJ: number
    • centerI: number
    • maxCount: number
    • originalStateCountTotal: number

    Returns number

Private crossCheckVertical

  • crossCheckVertical(startI: number, centerJ: number, maxCount: number, originalStateCountTotal: number): number
  • After a horizontal scan finds a potential finder pattern, this method "cross-checks" by scanning down vertically through the center of the possible finder pattern to see if the same proportion is detected.

    Parameters

    • startI: number

      row where a finder pattern was detected

    • centerJ: number

      center of the section that appears to cross a finder pattern

    • maxCount: number

      maximum reasonable number of modules that should be observed in any reading state, based on the results of the horizontal scan

    • originalStateCountTotal: number

    Returns number

    vertical center of finder pattern, or {@link Float#NaN} if not found

find

Private findRowSkip

  • findRowSkip(): number
  • Returns number

    number of rows we could safely skip during scanning, based on the first two finder patterns that have been located. In some cases their position will allow us to infer that the third pattern must lie below a certain point farther down in the image.

Private getCrossCheckStateCount

  • getCrossCheckStateCount(): Int32Array

Protected getImage

Protected getPossibleCenters

Protected handlePossibleCenter

  • handlePossibleCenter(stateCount: Int32Array, i: number, j: number, pureBarcode: boolean): boolean
  • This is called when a horizontal scan finds a possible alignment pattern. It will cross check with a vertical scan, and if successful, will, ah, cross-cross-check with another horizontal scan. This is needed primarily to locate the real horizontal center of the pattern in cases of extreme skew. And then we cross-cross-cross check with another diagonal scan.

    If that succeeds the finder pattern location is added to a list that tracks the number of times each location has been nearly-matched as a finder pattern. Each additional find is more evidence that the location is in fact a finder pattern center

    Parameters

    • stateCount: Int32Array

      reading state module counts from horizontal scan

    • i: number

      row where finder pattern may be found

    • j: number

      end of possible finder pattern in row

    • pureBarcode: boolean

      true if in "pure barcode" mode

    Returns boolean

    true if a finder pattern candidate was found this time

Private haveMultiplyConfirmedCenters

  • haveMultiplyConfirmedCenters(): boolean
  • Returns boolean

    true iff we have found at least 3 finder patterns that have been detected at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the candidates is "pretty similar"

Private selectBestPatterns

Static Private centerFromEnd

  • centerFromEnd(stateCount: Int32Array, end: number): number
  • Given a count of black/white/black/white/black pixels just seen and an end position, figures the location of the center of this run.

    Parameters

    • stateCount: Int32Array
    • end: number

    Returns number

Static Protected foundPatternCross

  • foundPatternCross(stateCount: Int32Array): boolean
  • Parameters

    • stateCount: Int32Array

      count of black/white/black/white/black pixels just read

    Returns boolean

    true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios used by finder patterns to be considered a match

Generated using TypeDoc