-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readFromFile/readFromBlob result returning also the QR code coordinates inside the source image #248
base: main
Are you sure you want to change the base?
readFromFile/readFromBlob result returning also the QR code coordinates inside the source image #248
Changes from all commits
51b135b
8377e28
d26525e
67b0f42
6c7ab47
e46ed70
896f096
47e4f61
bc3a7e2
e12279a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,12 @@ final class DecoderResult{ | |
private string $data = ''; | ||
private int $structuredAppendParity = -1; | ||
private int $structuredAppendSequence = -1; | ||
private int $topLeftX; | ||
private int $topLeftY; | ||
private int $topRightX; | ||
private int $topRightY; | ||
private int $bottomLeftX; | ||
private int $bottomLeftY; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd just add 3 properties with the |
||
|
||
/** | ||
* DecoderResult constructor. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,12 @@ | |
final class Detector{ | ||
|
||
private BitMatrix $matrix; | ||
public int $topLeftX; | ||
public int $topLeftY; | ||
public int $topRightX; | ||
public int $topRightY; | ||
public int $bottomLeftX; | ||
public int $bottomLeftY; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't do public properties here :) I think we can hand down the whole result from the finder pattern finder as the objects hold other useful values such as the estimated module size, so just add one property (with a getter) that holds the result array |
||
|
||
/** | ||
* Detector constructor. | ||
|
@@ -40,6 +46,13 @@ public function __construct(LuminanceSourceInterface $source){ | |
public function detect():BitMatrix{ | ||
[$bottomLeft, $topLeft, $topRight] = (new FinderPatternFinder($this->matrix))->find(); | ||
|
||
$this->topLeftX = (int)floor($topLeft->getX()); | ||
$this->topLeftY = (int)floor($topLeft->getY()); | ||
$this->topRightX = (int)ceil($topRight->getX()); | ||
$this->topRightY = (int)floor($topRight->getY()); | ||
$this->bottomLeftX = (int)floor($bottomLeft->getX()); | ||
$this->bottomLeftY = (int)ceil($bottomLeft->getY()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here just assign the result from the $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); | ||
$provisionalVersion = new Version(intdiv(($dimension - 17), 4)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'd just assign the
Detector
instance to a property and call$this->detector->getFinderPatterns()
only right before assigning the variables to the result object.Further i think we could add a
getCoordinates()
method to theResultPoint
class, which does thefloor()
-ing and all