|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Class FinderPattern |
|
4
|
|
|
* |
|
5
|
|
|
* @created 17.01.2021 |
|
6
|
|
|
* @author ZXing Authors |
|
7
|
|
|
* @author Smiley <[email protected]> |
|
8
|
|
|
* @copyright 2021 Smiley |
|
9
|
|
|
* @license Apache-2.0 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace chillerlan\QRCode\Detector; |
|
13
|
|
|
|
|
14
|
|
|
use function chillerlan\QRCode\Common\{distance, squaredDistance}; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* <p>Encapsulates a finder pattern, which are the three square patterns found in |
|
18
|
|
|
* the corners of QR Codes. It also encapsulates a count of similar finder patterns, |
|
19
|
|
|
* as a convenience to the finder's bookkeeping.</p> |
|
20
|
|
|
* |
|
21
|
|
|
* @author Sean Owen |
|
22
|
|
|
*/ |
|
23
|
|
|
final class FinderPattern extends ResultPoint{ |
|
24
|
|
|
|
|
25
|
|
|
private int $count; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct(float $posX, float $posY, float $estimatedModuleSize, int $count = 1){ |
|
28
|
|
|
parent::__construct($posX, $posY, $estimatedModuleSize); |
|
29
|
|
|
|
|
30
|
|
|
$this->count = $count; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function getCount():int{ |
|
34
|
|
|
return $this->count; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param \chillerlan\QRCode\Detector\FinderPattern $b second pattern |
|
39
|
|
|
* |
|
40
|
|
|
* @return float distance between two points |
|
41
|
|
|
*/ |
|
42
|
|
|
public function distance(FinderPattern $b):float{ |
|
43
|
|
|
return distance($this->getX(), $this->getY(), $b->getX(), $b->getY()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get square of distance between a and b. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function squaredDistance(FinderPattern $b):float{ |
|
50
|
|
|
return squaredDistance($this->getX(), $this->getY(), $b->getX(), $b->getY()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Combines this object's current estimate of a finder pattern position and module size |
|
55
|
|
|
* with a new estimate. It returns a new {@code FinderPattern} containing a weighted average |
|
56
|
|
|
* based on count. |
|
57
|
|
|
*/ |
|
58
|
|
|
public function combineEstimate(float $i, float $j, float $newModuleSize):FinderPattern{ |
|
59
|
|
|
$combinedCount = $this->count + 1; |
|
60
|
|
|
|
|
61
|
|
|
return new self( |
|
62
|
|
|
($this->count * $this->x + $j) / $combinedCount, |
|
63
|
|
|
($this->count * $this->y + $i) / $combinedCount, |
|
64
|
|
|
($this->count * $this->estimatedModuleSize + $newModuleSize) / $combinedCount, |
|
65
|
|
|
$combinedCount |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths