Feature: Labelprint für Kistenetiketten hinzugefügt

This commit is contained in:
2025-10-27 12:14:44 +01:00
parent 43bc416554
commit 14bae6c9ef
1068 changed files with 229014 additions and 1807 deletions
@@ -256,7 +256,7 @@ final class AlignmentPatternFinder{
$i++;
}
if($i == $maxI || $stateCount[1] > $maxCount){
if($i === $maxI || $stateCount[1] > $maxCount){
return null;
}
@@ -269,6 +269,7 @@ final class AlignmentPatternFinder{
return null;
}
// phpcs:ignore
if((5 * abs(($stateCount[0] + $stateCount[1] + $stateCount[2]) - $originalStateCountTotal)) >= (2 * $originalStateCountTotal)){
return null;
}
+17 -6
View File
@@ -25,6 +25,8 @@ use const NAN;
final class Detector{
private BitMatrix $matrix;
/** @var \chillerlan\QRCode\Detector\FinderPattern[] */
private array $finderPatterns = [];
/**
* Detector constructor.
@@ -33,11 +35,20 @@ final class Detector{
$this->matrix = (new Binarizer($source))->getBlackMatrix();
}
/**
* @return \chillerlan\QRCode\Detector\FinderPattern[]
*/
public function getFinderPatterns():array{
return $this->finderPatterns;
}
/**
* Detects a QR Code in an image.
*/
public function detect():BitMatrix{
[$bottomLeft, $topLeft, $topRight] = (new FinderPatternFinder($this->matrix))->find();
$this->finderPatterns = (new FinderPatternFinder($this->matrix))->find();
[$bottomLeft, $topLeft, $topRight] = $this->finderPatterns;
$moduleSize = $this->calculateModuleSize($topLeft, $topRight, $bottomLeft);
$dimension = $this->computeDimension($topLeft, $topRight, $bottomLeft, $moduleSize);
@@ -305,11 +316,11 @@ final class Detector{
*
*/
private function createTransform(
FinderPattern $nw,
FinderPattern $ne,
FinderPattern $sw,
int $size,
AlignmentPattern $ap = null
FinderPattern $nw,
FinderPattern $ne,
FinderPattern $sw,
int $size,
?AlignmentPattern $ap = null
):PerspectiveTransform{
$dimMinusThree = ($size - 3.5);
@@ -27,7 +27,7 @@ final class FinderPattern extends ResultPoint{
/**
*
*/
public function __construct(float $posX, float $posY, float $estimatedModuleSize, int $count = null){
public function __construct(float $posX, float $posY, float $estimatedModuleSize, ?int $count = null){
parent::__construct($posX, $posY, $estimatedModuleSize);
$this->count = ($count ?? 1);
@@ -290,11 +290,13 @@ final class FinderPatternFinder{
// Now also count down, right from center
$i = 1;
// phpcs:ignore
while(($centerI + $i) < $dimension && ($centerJ + $i) < $dimension && $this->matrix->check(($centerJ + $i), ($centerI + $i))){
$stateCount[2]++;
$i++;
}
// phpcs:ignore
while(($centerI + $i) < $dimension && ($centerJ + $i) < $dimension && !$this->matrix->check(($centerJ + $i), ($centerI + $i))){
$stateCount[3]++;
$i++;
@@ -304,6 +306,7 @@ final class FinderPatternFinder{
return false;
}
// phpcs:ignore
while(($centerI + $i) < $dimension && ($centerJ + $i) < $dimension && $this->matrix->check(($centerJ + $i), ($centerI + $i))){
$stateCount[4]++;
$i++;
+9 -9
View File
@@ -152,15 +152,15 @@ final class GridSampler{
// no need to try/catch as QRMatrix::set() will silently discard out of bounds values
# try{
for($x = 0; $x < $max; $x += 2){
// Black(-ish) pixel
$bits->set(
intdiv($x, 2),
$y,
$matrix->check((int)$this->points[$x], (int)$this->points[($x + 1)]),
QRMatrix::M_DATA
);
}
for($x = 0; $x < $max; $x += 2){
// Black(-ish) pixel
$bits->set(
intdiv($x, 2),
$y,
$matrix->check((int)$this->points[$x], (int)$this->points[($x + 1)]),
QRMatrix::M_DATA
);
}
# }
# catch(\Throwable $aioobe){//ArrayIndexOutOfBoundsException
// This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
@@ -152,7 +152,7 @@ final class PerspectiveTransform{
/**
* @return array[] [$xValues, $yValues]
*/
public function transformPoints(array $xValues, array $yValues = null):array{
public function transformPoints(array $xValues, ?array $yValues = null):array{
$max = count($xValues);
if($yValues !== null){ // unused