Skip to content
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

[ENHANCEMENT] readFromFile/readFromBlob result returning also the QR code coordinates inside the source image #240

Open
pedrospinto opened this issue Feb 7, 2024 · 5 comments

Comments

@pedrospinto
Copy link

pedrospinto commented Feb 7, 2024

Request: literally what the title says.
Thanks!

@codemasher
Copy link
Member

Hi, why did you ignore the issue template? Please provide a proper description and reasons/use cases why this should be a feature, otherwise I'll close this issue.
https://php-qrcode.readthedocs.io/en/main/Appendix/Contribute.html

@pedrospinto
Copy link
Author

pedrospinto commented Feb 7, 2024

Hi, sorry about not adhering to the template.

Description: when detecting QR codes in an image, getting back the pixel coordinates of the detected code.

Use case: I'm trying to detect all the QR codes in an image, not a single one. From what I gather, only the first QR code that is found is returned. With the pixel coordinates of the QR code, I can draw a rectangle on the image over the QR code, effectively erasing it. Then, I can run the detection again on the same image and get the second QR code, and so on.

Hope this is enough! :)

@codemasher
Copy link
Member

Ok thanks, that gives a rough idea. I guess the easiest way would be to get the coordinates of the finder patterns over here:

public function detect():BitMatrix{
[$bottomLeft, $topLeft, $topRight] = (new FinderPatternFinder($this->matrix))->find();

However, these values are already run though the binarizer and might have undergone transformations during the locate process, so the accuracy may vary.

Either way, this is a very low priority enhancement unless it comes to me in form of a vision or a pull request, so I'll tag it as "help wanted".

@pedrospinto
Copy link
Author

Hi, I've done it myself here:
https://github.com/pedrospinto/php-qrcode/tree/main
This works perfectly for me. With the XY coordinates of the last detected QR code, I can obscure it and run the detection again on the same image to get the next code, and so on.
Didn't make a pull request though. I'm not sure if this code is up to par with your standards...

@codemasher
Copy link
Member

Hey that looks great!

Didn't make a pull request though. I'm not sure if this code is up to par with your standards...

No worries, a PR is for working out the details - it's your contribution after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants