Created
August 26, 2018 08:37
-
-
Save freak4pc/3f7ae2801dd8b7a068daa957463ac645 to your computer and use it in GitHub Desktop.
Detect text messages from QR code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func parseQR() -> [String] { | |
guard let image = CIImage(image: self) else { | |
return [] | |
} | |
let detector = CIDetector(ofType: CIDetectorTypeQRCode, | |
context: nil, | |
options: [CIDetectorAccuracy: CIDetectorAccuracyHigh]) | |
let features = detector?.features(in: image) ?? [] | |
return features.compactMap { feature in | |
return (feature as? CIQRCodeFeature)?.messageString | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it does not work for iOS Simulator 14.4