Detector (ZXing 3.5.0 API)

com.google.zxing.qrcode.detector

## Class Detector

- java.lang.Object
- - com.google.zxing.qrcode.detector.Detector

- Direct Known Subclasses:
    MultiDetector

      public class Detector
      extends Object

  Encapsulates logic that can detect a QR Code in an image, even if the QR Code is rotated or skewed, or partially obscured.

  Author:
    Sean Owen

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Detector(BitMatrix image)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected float` | `calculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft)` Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.
    `DetectorResult` | `detect()` Detects a QR Code in an image.
    `DetectorResult` | `detect(Map<DecodeHintType,?> hints)` Detects a QR Code in an image.
    `protected AlignmentPattern` | `findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor)` Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it.
    `protected BitMatrix` | `getImage()`
    `protected ResultPointCallback` | `getResultPointCallback()`
    `protected DetectorResult` | `processFinderPatternInfo(FinderPatternInfo info)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Detector

          public Detector(BitMatrix image)

  - ### Method Detail

    - #### getImage

          protected final BitMatrix getImage()

    - #### getResultPointCallback

          protected final ResultPointCallback getResultPointCallback()

    - #### detect

          public DetectorResult detect()
                                throws NotFoundException,
                                       FormatException

      Detects a QR Code in an image.

      Returns:
        `DetectorResult` encapsulating results of detecting a QR Code
      Throws:
        `NotFoundException` - if QR Code cannot be found
        `FormatException` - if a QR Code cannot be decoded

    - #### detect

          public final DetectorResult detect(Map<DecodeHintType,?> hints)
                                      throws NotFoundException,
                                             FormatException

      Detects a QR Code in an image.

      Parameters:
        `hints` - optional hints to detector
      Returns:
        `DetectorResult` encapsulating results of detecting a QR Code
      Throws:
        `NotFoundException` - if QR Code cannot be found
        `FormatException` - if a QR Code cannot be decoded

    - #### processFinderPatternInfo

          protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
                                                           throws NotFoundException,
                                                                  FormatException

      Throws:
        `NotFoundException`
        `FormatException`

    - #### calculateModuleSize

          protected final float calculateModuleSize(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft)

      Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.

      Parameters:
        `topLeft` - detected top-left finder pattern center
        `topRight` - detected top-right finder pattern center
        `bottomLeft` - detected bottom-left finder pattern center
      Returns:
        estimated module size

    - #### findAlignmentInRegion

          protected final AlignmentPattern findAlignmentInRegion(float overallEstModuleSize,
                                                                 int estAlignmentX,
                                                                 int estAlignmentY,
                                                                 float allowanceFactor)
                                                          throws NotFoundException

      Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it. This method uses `AlignmentPattern`.

      Parameters:
        `overallEstModuleSize` - estimated module size so far
        `estAlignmentX` - x coordinate of center of area probably containing alignment pattern
        `estAlignmentY` - y coordinate of above
        `allowanceFactor` - number of pixels in all directions to search from the center
      Returns:
        `AlignmentPattern` if found, or null otherwise
      Throws:
        `NotFoundException` - if an unexpected error occurs during detection

Copyright © 2007–2022. All rights reserved.