Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: As of 2013 what is the best way to scan barcodes and QR codes? [closed]

I'm finding older questions and answers on this topic. But I gather in iOS 7 there is a framework for QR codes. Does it support barcodes too? And if I want to support earlier devices, what is the library that is considered the best as of now?

like image 799
Friendly Avatar asked Nov 08 '13 16:11

Friendly


People also ask

Why can't my iPhone scan QR codes?

The QR code might not be scanned due to any of the following reasons: The OS version of the device is not iOS 11 or above. QR scanning is disabled in the camera app. The QR is not detected more than once.

Do I need a QR reader on my iPhone?

If you own an iPhone with iOS 11 and above, you do not need to download a separate app to scan a QR Code.


1 Answers

iOS 7 introduced QR code and Barcode reading support in AVCaptureMetadataOutput. It can read the following formats:

  • UPC-A
  • UPC-E
  • Code 39
  • Code 39 mod 43
  • Code 93
  • Code 128
  • EAN-8
  • EAN-13
  • Aztec
  • PDF417
  • QR

To implement it you need to add an AVCaptureMetadataOutput with the object types you want to scan for to an AVCaptureSession.

AVCaptureMetadataOutput *metadataOutput= [[AVCaptureMetadataOutput alloc] init];
[self.session addOutput:metadataOutput];
[metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
[metadataOutput setMetadataObjectTypes:@[AVMetadataObjectTypeCode128Code]];

And implement the following delegate method:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection

The different metadata objects you can listen for are listed here: https://developer.apple.com/library/ios/DOCUMENTATION/AVFoundation/Reference/AVMetadataMachineReadableCodeObject_Class/Reference/Reference.html

A popular library for previous versions of iOS was ZBar although I know a lot of users had issues with ZBar when trying to use it with iOS 7. This may have been fixed by now though.

http://zbar.sourceforge.net

like image 147
asjj Avatar answered Nov 15 '22 21:11

asjj