Documentation

Detector
in package

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

Tags
author

Sean Owen

Table of Contents

$bitMatrix  : BitMatrix
__construct()  : mixed
Detector constructor.
detect()  : BitMatrix
<p>Detects a QR Code in an image.</p>
calculateModuleSize()  : float
<p>Computes an average estimated module size based on estimated derived from the positions of the three finder patterns.</p>
calculateModuleSizeOneWay()  : float
<p>Estimates module size based on two finder patterns -- it uses {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the width of each, measuring along the axis between their centers.</p>
computeDimension()  : int
<p>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.</p>
createTransform()  : PerspectiveTransform
findAlignmentInRegion()  : AlignmentPattern|null
<p>Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it.</p>
sizeOfBlackWhiteBlackRun()  : float
<p>This method traces a line from a po$in the image, in the direction towards another point.
sizeOfBlackWhiteBlackRunBothWays()  : float
See {@link #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.</p>

Properties

Methods

__construct()

Detector constructor.

public __construct(BitMatrix $image) : mixed
Parameters
$image : BitMatrix
Return values
mixed

calculateModuleSizeOneWay()

<p>Estimates module size based on two finder patterns -- it uses {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the width of each, measuring along the axis between their centers.</p>

private calculateModuleSizeOneWay(FinderPattern $pattern, FinderPattern $otherPattern) : float
Parameters
$pattern : FinderPattern
$otherPattern : FinderPattern
Return values
float

computeDimension()

<p>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.</p>

private computeDimension(FinderPattern $topLeft, FinderPattern $topRight, FinderPattern $bottomLeft, float $moduleSize) : int
Parameters
$topLeft : FinderPattern
$topRight : FinderPattern
$bottomLeft : FinderPattern
$moduleSize : float
Tags
throws
RuntimeException
Return values
int

findAlignmentInRegion()

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

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()

<p>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()

See {@link #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.</p>

private sizeOfBlackWhiteBlackRunBothWays(float $fromX, float $fromY, float $toX, float $toY) : float
Parameters
$fromX : float
$fromY : float
$toX : float
$toY : float
Return values
float

Search results