aslanyanhaik / RoundCode

Custom rounded QR code with lots of customization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decode not working from camera roll

maxmzd opened this issue · comments

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
  }
}

@maxmzd which configuration are you using?

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.

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

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!

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.

@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

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