-
-
Notifications
You must be signed in to change notification settings - Fork 301
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?
Conversation
Get qrcode coords
typo in $topLeftY and $topRightX
correct indentation
Hey! Thank you for the PR! I'm going to add some thoughts to the files - no worries, I don't bite :) 2 things kept me thinking:
|
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 comment
The 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 private array|null $finderPatterns = null
(nullable in case it gets called from the getter before Detector::detect()
was called).
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
Here just assign the result from the FinderPatternFinder
call to the property and unpack the list from that property afterwards:
$this->finderPatterns = (new FinderPatternFinder($this->matrix))->find();
[$bottomLeft, $topLeft, $topRight] = $this->finderPatterns;
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just add 3 properties with the FinderPattern
type here. I'm not sure yet what is returned when a pattern is not found - when in doubt, make the fields nullable. (edit: it seems like it will always return 3 instances)
$this->topRightX = $detector->topRightX; | ||
$this->topRightY = $detector->topRightY; | ||
$this->bottomLeftX = $detector->bottomLeftX; | ||
$this->bottomLeftY = $detector->bottomLeftY; |
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 the ResultPoint
class, which does the floor()
-ing and all
Proposed changes
...as discussed in
#240
Types of changes
What types of changes does your code introduce?
Checklist: