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

Decode not working from camera roll #5

Closed
maxmzd opened this issue May 3, 2020 · 7 comments
Closed

Decode not working from camera roll #5

maxmzd opened this issue May 3, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@maxmzd
Copy link

maxmzd commented May 3, 2020

Love the package. Great work. I'm not able to get it working with codes generated by the package that are then loaded from my camera roll. I tested the example project in the repo which also failed with a generic decode error.

if let message = try? coder.decode(camImage) {
  messageLabel.text = message
  messageLabel.isHidden = false
  DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
    self.messageLabel.isHidden = true
  }
}
@aslanyanhaik
Copy link
Owner

@maxmzd which configuration are you using?

@maxmzd
Copy link
Author

maxmzd commented May 4, 2020

I didn't specify a configuration so I assume the default.

It only works when I pass in the exact file produced by the example app.

In my app, I place the generated code on an "invite sheet" the user can share. When it's loaded back into the app, I crop the invite sheet to only show the code, but it doesn't work.

I also tested by taking the code generated from the example app and cropping it slightly. This caused an error as well. It only seems to work if the image uploaded from the camera roll is the same exact one that was generated originally.

I think it should be able to recognize the code even if the resolution and position of the code changes slightly.

@maxmzd
Copy link
Author

maxmzd commented May 4, 2020

I was able to crop my invite sheet into the exact rect of the original QR code dimensions and it's now working.

This might be a valuable note for the readme when referencing decoding. I assume most people will display the QR Code somewhere other than its original dimensions.

I still think it would be valuable if the package could read a code uploaded from the camera roll regardless of it's position on the image, but for now, this works.

Loving this package! Keep it up

@maxmzd maxmzd closed this as completed May 4, 2020
@maxmzd
Copy link
Author

maxmzd commented May 5, 2020

After thinking this through some more, I’m re-opening this issue.

One of the main ways people will use the QR codes generated from my app is by taking a screenshot of the code on Instagram Stories, then uploading that into my app. In this case the decode function fails because the image is not exactly the same dimensions as when it was created.

I would like to request an enhancement that will enable scanning of a code imported from the camera roll when the dimensions of the QR code might have changed slightly.

Thank you!

@maxmzd maxmzd reopened this May 5, 2020
@aslanyanhaik aslanyanhaik added the enhancement New feature or request label May 5, 2020
@aslanyanhaik
Copy link
Owner

Indeed. The decoder scans only 20% of area from edges. This was some kind of "optimization" in order to have fast scanning logic. I was assuming that images will not be modified.
Anyway I'll update the framework to scan whole image for control points.

@aslanyanhaik
Copy link
Owner

@maxmzd just pushed a new commit to develop branch. Although decoder will detect non centered qr code, the image size should be square.
Let me know if it's working correctly so I will push to main branch.

P.S. Al

@maxmzd
Copy link
Author

maxmzd commented May 6, 2020

@aslanyanhaik thank you so much. Tested and confirmed it works perfectly. Well done!

@maxmzd maxmzd closed this as completed May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants