Wenfengcheng / xamarin-notes

xamarin journal
MIT License
3 stars 0 forks source link

ZXing with AVCaptureSession #38

Open Wenfengcheng opened 5 years ago

Wenfengcheng commented 5 years ago

Using Apple's AVCaptureSession (iOS7 Built in) Barcode Scanning In iOS7, Apple added some API's to allow for scanning of barcodes in an AVCaptureSession. The latest version of ZXing.Net.Mobile gives you the option of using this instead of the ZXing scanning engine. You can use the AVCaptureScannerView or the AVCaptureScannerViewController classes directly just the same as you would use their ZXing* equivalents. Or, in your MobileBarcodeScanner, there is now an overload to use the AV Capture Engine:

//Scan(MobileBarcodeScanningOptions options, bool useAVCaptureEngine)
scanner.Scan(options, true);

In the MobileBarcodeScanner, even if you specify to use the AVCaptureSession scanning, it will gracefully degrade to using ZXing if the device doesn't support this (eg: if it's not iOS7 or newer), or if you specify a barcode format in your scanning options which the AVCaptureSession does not support for detection. The AVCaptureSession can only decode the following barcodes:

  • Aztec
  • Code 128
  • Code 39
  • Code 93
  • EAN13
  • EAN8
  • PDF417
  • QR
  • UPC-E

https://github.com/Redth/ZXing.Net.Mobile#using-apples-avcapturesession-ios7-built-in-barcode-scanning