Is it possible to decode a QRCode image for evaluation

I am looking for a code that will help me convert a QRCode from an image. There is a very simple way: AVFoundationscan the QR code using the camera. But if I want to get the qr encoded string from UIImage, is there any way to do this?

+4
source share
5 answers

Native solution:
As far as I know, you can scan QR from video from iOS 7. (See Other answers)
But scanning from an image appeared only in iOS 8.

Cm. CIQRCodeFeature

and this shinobicontrols tutorial

third-party libraries: for
example ZBar

+9
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];
if (detector)  {
  NSArray* featuresR = [detector featuresInImage:scannedImg.CIImage];
  NSString* decodeR;
  for (CIQRCodeFeature* featureR in featuresR)  {
    NSLog(@"decode %@ ",featureR.messageString);
    decodeR = featureR.messageString;
  }
}
+5

EDIT:

, QR- . , . . . @DanSkeel .

, - .


. Apple API - iOS 7.

: AVCaptureMetadataOutput, AVMetadataMachineReadableCodeObject.

. AVCaptureSession, , AVCaptureMetadataOutput , - ( AVMetadataObjectTypeQRCode).

shinobicontrols, , . :

shinobicontrols - iOS7 ​​

, , - 16: QR-.

, API Apple -. , . , -. UPC, - , QR- , .

, . API- Apple, iOS 7 .

EDIT:

, , . Apple - ( 10, ""...)

AVMetadataObjectTypeUPCECode,
AVMetadataObjectTypeCode39Code,
AVMetadataObjectTypeCode39Mod43Code,
AVMetadataObjectTypeEAN13Code,
AVMetadataObjectTypeEAN8Code,
AVMetadataObjectTypeCode93Code,
AVMetadataObjectTypeCode128Code,
AVMetadataObjectTypePDF417Code,
AVMetadataObjectTypeQRCode,
AVMetadataObjectTypeAztecCode
+3

We use https://github.com/TheLevelUp/ZXingObjC , which supports all kinds of barcodes, including QR. This is a pure version of Objective-C ZXing, which is now only java.

+2
source

Just posting to people who tried to answer above, but that didn't work for them. It worked for me.

CIContext *context = [CIContext contextWithOptions:nil];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:context options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];
CIImage *imageQRCode = [CIImage imageWithCGImage:<YourImageToBeRead>.CGImage];
NSArray *features = [detector featuresInImage:imageQRCode];
        CIQRCodeFeature *feature = [features firstObject];

NSString *result = feature.messageString;
0
source

All Articles