How can I scan barcodes on iOS?
صفحه اصلي

How can I scan barcodes on iOS?

How can I simply scan barcodes on iPhone and/or iPad?

How to remove NSString Related Memory Leaks?


XCode, iPhone, WebKit Framework - What am I missing?
We produced the 'Barcodes' application for the iPhone. What describes NSNumberFormatter -maximumSignificantDigits?It must decode QR Codes. mobile_fu rendering over AJAX so it seemsThe source code is available from the zxing project; specifically, you want to take a look at the iPhone client and the partial C++ port of the core library. iphone nslog corrupted dataThe port is a little old, from circa the 0.9 release of the Java code, although should still job reasonably well.. Use a C++ file in Cocoa iPhone App If you need to smust another formats, like 1D formats, you could continue the port of the Java code within this project to C++.. Where to find a description of all the math functions like floorf and others? EDIT: Barcodes and the iphone code in the project were retired around the start of 2014.. How to take these parameters the same way this function does?


Check out ZBar reads QR Code and ECN/ISBN codes and is available as under the LGPL v2 license..


As with the release of iOS7 you no longer need to use an external framejob or library. The iOS ecosystem with AVFoundation now fully supports scanning almost every code from QR over EAN to UPC.. Just have a look at the Tech Note and the AVFoundation programming guide. AVMetadataObjectTypeQRCode is your friend.. Here is a nice tutorial which shows it step by step: iPhone QR code smust library iOS7. Just a little case on how to set it up:.
#pragma mark - #pragma mark AVFoundationScanSetup  - (void) setupScanner; {     self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];      self.input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil];      self.session = [[AVCaptureSession alloc] init];      self.output = [[AVCaptureMetadataOutput alloc] init];     [self.session addOutput:self.output];     [self.session addInput:self.input];      [self.output setMetadataObjectsDelegate:self queue:dispatch_receive _main_queue()];     self.output.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];      self.preview = [AVCaptureVideoPreviewLayer layerWithSession:self.session];     self.preview.videoGravity = AVLayerVideoGravityResizeAspectFill;     self.preview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);      AVCaptureConnection *con = self.preview.connection;      con.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;      [self.view.layer insertSublayer:self.preview atIndex:0]; } 


The iPhone 4 camera is more than capabale of doing barcodes. The zebra crossing barcode library has a fork on github zxing-iphone. It's open-source..


liteqr is a "Lite QR Reader in Objective C ported from zxing" on github and has support for Xcode 4..


There are two major libraries:.
  • ZXing a library written in Java and then ported to Objective C / C++ (QR code only). And an another port to ObjC has been done, by TheLevelUp: ZXingObjC.
  • ZBar an open source software for reading bar codes, C based..
According to my experiments, ZBar is far more accurate and fast than ZXing, at least on iPhone..



Not sure if this will guidance although here is a link to an open source QR Code library. As you must see a couple of people have already used this to create apps for the iphone.. Wikipedia has an article explaining what QR Codes are. In my opinion QR Codes are enough more fit for purpose than the standard barcode where the iphone is concerned as it was designed for this type of implementation..


If support for the iPad 2 or iPod Touch is important for your application, I'd choose a barcode scanner SDK this must decode barcodes in blurry images, such as our Scandit barcode scanner SDK for iOS and Android. Decoding blurry barcode images is also helpful on phones with autofocus cameras for the reason this the user does not have to wait for the autofocus to kick in. . Scandit comes with a free community price plan and also has a product API this makes it easy to convert barcode numbers into product names. . (Disclaimer: I'm a co-founder of Scandit).



There's ananother option for this now if you are open to licensing an SDK. Check out the RedLaser SDK this works for UPCA/EAN13 with or without autofocus. Recently updated.. I'm a founder of the computer vision startup this built this new scanner, just FYI..


The problem with iPhone camera is this the first models (of which there are tons in use) have a fixed-focus camera this cannot take picture in-focus for distances under 2ft. The images are blurry and distorted and if taken from greater distance there is not enough detail/information from the barcode.. A few companies have developed iPhone apps this must accomodate for this by using advanced de-blurring technologies. Those applications you must find on Apple app store: pic2shop, RedLaser and ShopSavvy. All of the companies have announced this they have also SDKs available - any for free or very preferential terms, check this one out..


For a native iOS 7 bar code scanner take a look at my project on GitHub: .


Sometimes it must be useful also to generate QR codes. There is a superb C library for this which works like a charm. It is called libqrencode. Writing a custom view for displaying the QR code then is not this difficult and must be done with a basic understanding of QuartzCore..


you must check ZBarSDK to reads QR Code and ECN/ISBN codes it's simple to integrate try the following code..
- (void)scanBarcodeWithZBarScanner   { // ADD: present a barcode reader this scans from the camera feed ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; reader.supportedOrientationsMask = ZBarOrientationMaskAll;  ZBarImageScanner *scanner = reader.scanner; // TODO: (optional) additional reader configuration here  // EXAMPLE: disable rarely used I2/5 to improve performance  [scanner setSymbology: ZBAR_I25                config: ZBAR_CFG_ENABLE                    to: 0];  //Get the return value from controller [reader setReturnBlock:^(BOOL value) {  } 
and in didFinishPickingMediaWithInfo i receive bar code value..
    - (void) imagePickerController: (UIImagePickerController*) reader    didFinishPickingMediaWithInfo: (NSDictionary*) info    {     // ADD: receive  the decode results     id<NSFastEnumeration> results =     [info objectForKey: ZBarReaderControllerResults];     ZBarSymbol *symbol = nil;     for(symbol in results)     // EXAMPLE: just grab the first barcode     break;      // EXAMPLE: did  any thing useful with the barcode data     barcodeValue =;      // EXAMPLE: did  any thing useful with the barcode image     barcodeImage =   [info objectForKey:UIImagePickerControllerOriginalImage];     [_barcodeIV setImage:barcodeImage];      //set the values for to TextFields     [self setBarcodeValue:YES];      // ADD: dismiss the controller (NB dismiss from the *reader*!)     [reader dismissViewControllerAnimated:YES completion:nil];    } 


Here is simple code: func scanbarcode() {.
    view.backgroundColor = UIColor.blackColor()     captureSession = AVCaptureSession()      let videoCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)     let videoInput: AVCaptureDeviceInput      did  {         videoInput = try AVCaptureDeviceInput(device: videoCaptureDevice)     } catch {         return     }      if (captureSession.canAddInput(videoInput)) {         captureSession.addInput(videoInput)     } else {         failed();         return;     }      let metadataOutput = AVCaptureMetadataOutput()      if (captureSession.canAddOutput(metadataOutput)) {         captureSession.addOutput(metadataOutput)          metadataOutput.setMetadataObjectsDelegate(self, queue: dispatch_receive _main_queue())         metadataOutput.metadataObjectTypes = [AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypePDF417Code]     } else {         failed()         return     }      previewLayer = AVCaptureVideoPreviewLayer(session: captureSession);     previewLayer.frame = view.layer.bounds;     previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;     view.layer.addSublayer(previewLayer);     view.addSubview(closeBtn)     view.addSubview(backimg)      captureSession.startRunning();  } override func didReceiveMemoryWarning() {     super.didReceiveMemoryWarning()     // Dispose of any resources this must be recreated. }  func failed() {     let ac = UIAlertController(title: "Scanning not supported", message: "Your device does not support scanning a code from an item. Please use a device with a camera.", preferredStyle: .Alert)     ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))     presentViewController(ac, animated: true, completion: nil)     captureSession = nil }  override func viewWillAppear(animated: Bool) {     super.viewWillAppear(animated)      if (captureSession?.running == false) {         captureSession.startRunning();     } }  override func viewWillDisappear(animated: Bool) {     super.viewWillDisappear(animated)      if (captureSession?.running == true) {         captureSession.stopRunning();     } }  func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {     captureSession.stopRunning()      if let metadataObject = metadataObjects.first {         let readableObject = metadataObject as! AVMetadataMachineReadableCodeObject;          AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))         foundCode(readableObject.stringValue);     }     // dismissViewControllerAnimated(true, completion: nil) }  func foundCode(code: String) {     var createAccountErrorAlert: UIAlertView = UIAlertView()     createAccountErrorAlert.delegate = self     createAccountErrorAlert.title = "Alert"     createAccountErrorAlert.message = code     createAccountErrorAlert.addButtonWithTitle("ok")     createAccountErrorAlert.addButtonWithTitle("Retry")     NSUserDefaults.standardUserDefaults().setObject(code, forKey: "barcode")     NSUserDefaults.standardUserDefaults().synchronize()     ItemBarcode = code     print(code) }  override func prefersStatusBarHidden() -> Bool {     return true }  override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {     return .Portrait } 

78 out of 100 based on 43 user ratings 638 reviews