From 05917f7286a9b050c60ff8a60685c329db4cda27 Mon Sep 17 00:00:00 2001
From: codemasher This class contains utility methods for performing mathematical operations over
- * the Galois Fields. Operations use a given primitive polynomial in calculations. Throughout this package, elements of the GF are represented as an {@code int}
+ * Throughout this package, elements of the GF are represented as an int
* for convenience and speed (but at the cost of memory).
- * Implements Reed-Solomon decoding, as the name implies. The algorithm will not be explained here, but the following references were helpful
- * in creating this implementation: Much credit is due to William Rucklidge since portions of this code are an indirect
- * port of his C++ Reed-Solomon implementation. Decodes given set of received codewords, which include both data and error-correction
+ * Decodes given set of received codewords, which include both data and error-correction
* codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
- * in the input. Sets the given bit to true. Flips the given bit. 1 << (0xf9 & 0x1f) Sets a square region of the bit matrix to true. Gets the requested bit, where true means black. Reads the bits in the {@link BitMatrix} representing the finder pattern in the
+ * Reads the bits in the BitMatrix representing the finder pattern in the
* correct order in order to reconstruct the codewords bytes contained within the
- * QR Code. Reads format information from one of its two locations within the QR Code. Reads version information from one of its two locations within the QR Code. The main class which implements QR Code decoding -- as opposed to locating and extracting
- * the QR Code from an image. Decodes a QR Code represented as a {@link \chillerlan\QRCode\Decoder\BitMatrix}.
- * A 1 or "true" is taken to mean a black module. When QR Codes use multiple data blocks, they are actually interleaved.
+ * When QR Codes use multiple data blocks, they are actually interleaved.
* That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This
- * method will separate the data into original blocks. Given data and error-correction codewords received, possibly corrupted by errors, attempts to
- * correct the errors in-place using Reed-Solomon error correction. Encapsulates an alignment pattern, which are the smaller square patterns found in
- * all but the simplest QR Codes. This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder
- * patterns but are smaller and appear at regular intervals throughout the image. At the moment this only looks for the bottom-right alignment pattern. This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied,
+ * This is mostly a simplified copy of FinderPatternFinder. It is copied,
* pasted and stripped down here for maximum performance but does unfortunately duplicate
- * some code. This class is thread-safe but not reentrant. Each thread must allocate its own object. Creates a finder that will look in a portion of the whole image. This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since
- * it's pretty performance-critical and so is written to be fast foremost. This is called when a horizontal scan finds a possible alignment pattern. It will
+ * This is called when a horizontal scan finds a possible alignment pattern. It will
* cross check with a vertical scan, and if successful, will see if this pattern had been
* found on a previous horizontal scan. If so, we consider it confirmed and conclude we have
- * found the alignment pattern. After a horizontal scan finds a potential alignment pattern, this method
+ * After a horizontal scan finds a potential alignment pattern, this method
* "cross-checks" by scanning down vertically through the center of the possible
- * alignment pattern to see if the same proportion is detected. Encapsulates logic that can detect a QR Code in an image, even if the QR Code
- * is rotated or skewed, or partially obscured. Detects a QR Code in an image. Computes an average estimated module size based on estimated derived from the positions
- * of the three finder patterns. 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.
*
*
- *
This method traces a line from a po$in the image, in the direction towards another point. + * This method traces a line from a po$in the image, in the direction towards another point. * 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.
+ * 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.
+ * This is used when figuring out how wide a finder pattern is, when the finder pattern + * may be skewed or rotated. */ private function sizeOfBlackWhiteBlackRun(int $fromX, int $fromY, int $toX, int $toY):float{ // Mild variant of Bresenham's algorithm; @@ -241,8 +241,8 @@ final class Detector{ } /** - *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.
+ * 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. * * @throws \RuntimeException */ @@ -276,8 +276,8 @@ final class Detector{ } /** - *Attempts to locate an alignment pattern in a limited region of the image, which is - * guessed to contain it.
+ * Attempts to locate an alignment pattern in a limited region of the image, which is + * guessed to contain it. * * @param float $overallEstModuleSize estimated module size so far * @param int $estAlignmentX x coordinate of center of area probably containing alignment pattern diff --git a/src/Detector/FinderPattern.php b/src/Detector/FinderPattern.php index 89339ce10..56e156cac 100644 --- a/src/Detector/FinderPattern.php +++ b/src/Detector/FinderPattern.php @@ -14,9 +14,9 @@ namespace chillerlan\QRCode\Detector; use function sqrt; /** - *Encapsulates a finder pattern, which are the three square patterns found in + * Encapsulates a finder pattern, which are the three square patterns found in * the corners of QR Codes. It also encapsulates a count of similar finder patterns, - * as a convenience to the finder's bookkeeping.
+ * as a convenience to the finder's bookkeeping. * * @author Sean Owen */ @@ -58,7 +58,7 @@ final class FinderPattern extends ResultPoint{ /** * Combines this object's current estimate of a finder pattern position and module size - * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average + * with a new estimate. It returns a new FinderPattern containing a weighted average * based on count. */ public function combineEstimate(float $i, float $j, float $newModuleSize):self{ diff --git a/src/Detector/FinderPatternFinder.php b/src/Detector/FinderPatternFinder.php index 251868647..0b6cf6df6 100644 --- a/src/Detector/FinderPatternFinder.php +++ b/src/Detector/FinderPatternFinder.php @@ -19,10 +19,10 @@ use function abs, count, usort; use const PHP_FLOAT_MAX; /** - *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 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. + * This class is thread-safe but not reentrant. Each thread must allocate its own object. * * @author Sean Owen */ @@ -37,7 +37,7 @@ final class FinderPatternFinder{ private bool $hasSkipped = false; /** - *
Creates a finder that will search the image for three finder patterns.
+ * Creates a finder that will search the image for three finder patterns. * * @param BitMatrix $bitMatrix image to search */ @@ -318,9 +318,9 @@ final class FinderPatternFinder{ } /** - *After a horizontal scan finds a potential finder pattern, this method + * 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.
+ * finder pattern to see if the same proportion is detected. * * @param int $startI ; row where a finder pattern was detected * @param int $centerJ ; center of the section that appears to cross a finder pattern @@ -409,9 +409,9 @@ final class FinderPatternFinder{ } /** - *Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, + * Like #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.
+ * check a vertical cross check and locate the real center of the alignment pattern. */ private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal):?float{ $maxJ = $this->bitMatrix->getDimension(); @@ -489,13 +489,13 @@ final class FinderPatternFinder{ } /** - *This is called when a horizontal scan finds a possible alignment pattern. It will + * 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.
+ * 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 + * 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 @@ -581,7 +581,7 @@ final class FinderPatternFinder{ /** * @return bool true if 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 + * at least #CENTER_QUORUM times each, and, the estimated module size of the * candidates is "pretty similar" */ private function haveMultiplyConfirmedCenters():bool{ @@ -614,8 +614,8 @@ final class FinderPatternFinder{ } /** - * @return \chillerlan\QRCode\Detector\FinderPattern[] the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module + * @return \chillerlan\QRCode\Detector\FinderPattern[] the 3 best FinderPatterns from our list of candidates. The "best" are + * those that have been detected at least #CENTER_QUORUM times, and whose module * size differs from the average among those patterns the least * @throws \RuntimeException if 3 such finder patterns do not exist */ diff --git a/src/Detector/GridSampler.php b/src/Detector/GridSampler.php index 2f252c9f9..dbbb3d780 100644 --- a/src/Detector/GridSampler.php +++ b/src/Detector/GridSampler.php @@ -23,7 +23,7 @@ use function array_fill, count, sprintf; * Imaging library, but which may not be available in other environments such as J2ME, and vice * versa. * - * The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)} + * The implementation used can be controlled by calling #setGridSampler(GridSampler) * with an instance of a class which implements this interface. * * @author Sean Owen @@ -31,15 +31,15 @@ use function array_fill, count, sprintf; final class GridSampler{ /** - *
Checks a set of points that have been transformed to sample points on an image against - * the image's dimensions to see if the point are even within the image.
+ * Checks a set of points that have been transformed to sample points on an image against + * the image's dimensions to see if the point are even within the image. * - *This method will actually "nudge" the endpoints back onto the image if they are found to be + * This method will actually "nudge" the endpoints back onto the image if they are found to be * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder - * patterns in an image where the QR Code runs all the way to the image border.
+ * patterns in an image where the QR Code runs all the way to the image border. * - *For efficiency, the method will check points from either end of the line until one is found - * to be within the image. Because the set of points are assumed to be linear, this is valid.
+ * For efficiency, the method will check points from either end of the line until one is found + * to be within the image. Because the set of points are assumed to be linear, this is valid. * * @param \chillerlan\QRCode\Decoder\BitMatrix $bitMatrix image into which the points should map * @param float[] $points actual points in x1,y1,...,xn,yn form diff --git a/src/Detector/PerspectiveTransform.php b/src/Detector/PerspectiveTransform.php index 87c93d7c6..e7a137b0c 100644 --- a/src/Detector/PerspectiveTransform.php +++ b/src/Detector/PerspectiveTransform.php @@ -14,9 +14,9 @@ namespace chillerlan\QRCode\Detector; use function count; /** - *This class implements a perspective transform in two dimensions. Given four source and four + * This class implements a perspective transform in two dimensions. Given four source and four * destination points, it will compute the transformation implied between them. The code is based - * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.
+ * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56. * * @author Sean Owen */ diff --git a/src/Detector/ResultPoint.php b/src/Detector/ResultPoint.php index 5cc17116f..92997a746 100644 --- a/src/Detector/ResultPoint.php +++ b/src/Detector/ResultPoint.php @@ -14,8 +14,8 @@ namespace chillerlan\QRCode\Detector; use function abs; /** - *Encapsulates a point of interest in an image containing a barcode. Typically, this - * would be the location of a finder pattern or the corner of the barcode, for example.
+ * Encapsulates a point of interest in an image containing a barcode. Typically, this + * would be the location of a finder pattern or the corner of the barcode, for example. * * @author Sean Owen */ @@ -56,8 +56,8 @@ abstract class ResultPoint{ } /** - *Determines if this finder pattern "about equals" a finder pattern at the stated - * position and size -- meaning, it is at nearly the same center with nearly the same size.
+ * Determines if this finder pattern "about equals" a finder pattern at the stated + * position and size -- meaning, it is at nearly the same center with nearly the same size. */ public function aboutEquals(float $moduleSize, float $i, float $j):bool{