Menu

## Detector
in package

Detector.php : 26

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

##### Tags

author

  Sean Owen

### Table of Contents

$matrix : BitMatrix
__construct() : mixed
  Detector constructor.
detect() : BitMatrix
  Detects a QR Code in an image.
calculateModuleSize() : float
  Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.
calculateModuleSizeOneWay() : float
  Estimates module size based on two finder patterns -- it uses #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int) to figure the width of each, measuring along the axis between their centers.
computeDimension() : int
  Computes the dimension (number of modules on a size) of the QR Code based on the position of the finder patterns and estimated module size.
createTransform() : PerspectiveTransform
findAlignmentInRegion() : AlignmentPattern|null
  Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it.
sizeOfBlackWhiteBlackRun() : float
  This method traces a line from a po$in the image, in the direction towards another point.
sizeOfBlackWhiteBlackRunBothWays() : float
  See #sizeOfBlackWhiteBlackRun(int, int, int, int); computes the total width of a finder pattern by looking for a black-white-black run from the center in the direction of another po$(another finder pattern center), and in the opposite direction too.

### Properties

#### $matrix

Detector.php : 28
`private BitMatrix $matrix`

### Methods

#### __construct()

Detector.php : 33

Detector constructor.

`public __construct(LuminanceSourceInterface $source) : mixed`

##### Parameters

$source : LuminanceSourceInterface

##### Return values

mixed —

#### detect()

Detector.php : 40

Detects a QR Code in an image.

`public detect() : BitMatrix`

##### Return values

BitMatrix —

#### calculateModuleSize()

Detector.php : 82

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

`private calculateModuleSize(FinderPattern $topLeft, FinderPattern $topRight, FinderPattern $bottomLeft) : float`

##### Parameters

$topLeft : FinderPattern
$topRight : FinderPattern
$bottomLeft : FinderPattern

##### Tags

throws
  QRCodeDetectorException

##### Return values

float —

#### calculateModuleSizeOneWay()

Detector.php : 101

Estimates module size based on two finder patterns -- it uses #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int) to figure the width of each, measuring along the axis between their centers.

`private calculateModuleSizeOneWay(FinderPattern $a, FinderPattern $b) : float`

##### Parameters

$a : FinderPattern
$b : FinderPattern

##### Return values

float —

#### computeDimension()

Detector.php : 239

Computes the dimension (number of modules on a size) of the QR Code based on the position of the finder patterns and estimated module size.

`private computeDimension(FinderPattern $nw, FinderPattern $ne, FinderPattern $sw, float $size) : int`

##### Parameters

$nw : FinderPattern
$ne : FinderPattern
$sw : FinderPattern
$size : float

##### Tags

throws
  QRCodeDetectorException

##### Return values

int —

#### createTransform()

Detector.php : 308
`private createTransform(FinderPattern $nw, FinderPattern $ne, FinderPattern $sw, int $size[, AlignmentPattern $ap = null ]) : PerspectiveTransform`

##### Parameters

$nw : FinderPattern
$ne : FinderPattern
$sw : FinderPattern
$size : int
$ap : AlignmentPattern = null

##### Return values

PerspectiveTransform —

#### findAlignmentInRegion()

Detector.php : 274

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

`private findAlignmentInRegion(float $overallEstModuleSize, int $estAlignmentX, int $estAlignmentY, float $allowanceFactor) : AlignmentPattern|null`

##### Parameters

$overallEstModuleSize : float

  estimated module size so far

$estAlignmentX : int

  x coordinate of center of area probably containing alignment pattern

$estAlignmentY : int

  y coordinate of above

$allowanceFactor : float

  number of pixels in all directions to search from the center

##### Return values

AlignmentPattern|null —

if found, or null otherwise

#### sizeOfBlackWhiteBlackRun()

Detector.php : 168

This method traces a line from a po$in the image, in the direction towards another point.

`private sizeOfBlackWhiteBlackRun(int $fromX, int $fromY, int $toX, int $toY) : float`

It begins in a black region, and keeps going until it finds white, then black, then white again. It reports the distance from the start to this point.

This is used when figuring out how wide a finder pattern is, when the finder pattern may be skewed or rotated.

##### Parameters

$fromX : int
$fromY : int
$toX : int
$toY : int

##### Return values

float —

#### sizeOfBlackWhiteBlackRunBothWays()

Detector.php : 125

See #sizeOfBlackWhiteBlackRun(int, int, int, int); computes the total width of a finder pattern by looking for a black-white-black run from the center in the direction of another po$(another finder pattern center), and in the opposite direction too.

`private sizeOfBlackWhiteBlackRunBothWays(float $fromX, float $fromY, float $toX, float $toY) : float`

##### Parameters

$fromX : float
$fromY : float
$toX : float
$toY : float

##### Tags

noinspection

  DuplicatedCode

##### Return values

float —

## Search results