Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Zxing Android Embedded | 5,260 | 5 months ago | 6 | October 25, 2021 | 100 | apache-2.0 | Java | |||
Barcode scanner library for Android, based on the ZXing decoder | ||||||||||
Barcodescanner | 5,233 | 5 | 3 years ago | 27 | August 19, 2017 | other | Java | |||
Barcode Scanner Libraries for Android | ||||||||||
Lbxscan | 3,014 | 110 | 2 years ago | 5 | October 22, 2018 | 148 | mit | Objective-C | ||
A barcode and qr code scanner (二维码、扫码、扫一扫、ZXing、ZBar、iOS系统AVFoundation扫码封装,扫码界面效果封装) | ||||||||||
Html5 Qrcode | 2,975 | 4 | 3 days ago | 46 | April 07, 2022 | 198 | apache-2.0 | TypeScript | ||
A cross platform HTML5 QR code reader. See end to end implementation at: https://scanapp.org | ||||||||||
Zxinglite | 2,556 | 10 days ago | 4 | June 22, 2022 | 26 | apache-2.0 | Java | |||
🔥 ZXing的精简极速版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信) | ||||||||||
React Native Qrcode Scanner | 1,971 | 171 | 9 | a month ago | 51 | February 11, 2022 | 118 | mit | JavaScript | |
A QR code scanner component for React Native. | ||||||||||
React Native Camera Kit | 1,921 | 46 | 11 | 18 days ago | 185 | September 15, 2022 | 87 | mit | Objective-C | |
A high performance, easy to use, rock solid camera library for React Native apps. | ||||||||||
Qrcodereaderview | 1,770 | 231 | 3 years ago | 2 | March 29, 2017 | 49 | Java | |||
Modification of ZXING Barcode Scanner project for easy Android QR-Code detection and AR purposes | ||||||||||
Sgqrcode | 1,594 | 28 | 8 months ago | 21 | July 16, 2022 | 5 | apache-2.0 | Objective-C | ||
The easy to use bar code and QR code scan library for iOS【支持二维码生成、图片中读取二维码、条形码和二维码扫描】 | ||||||||||
Barcodescanner | 1,572 | 33 | 7 months ago | 16 | March 11, 2018 | 21 | other | Swift | ||
:mag_right: A simple and beautiful barcode scanner. |
A lightweight, easy-to-use barcode scanning library for iOS 8+. This library is built on top of Apple's excellent AVFoundation framework, and will continue to receive updates as Apple releases them.
With this library you can:
See demo project for examples of capturing one code, multiple codes, or highlighting codes as valid or invalid in the live preview.
MTBBarcodeScanner can be installed via CocoaPods by adding the following line to your Podfile:
pod "MTBBarcodeScanner"
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate MTBBarcodeScanner into your Xcode project using Carthage, specify it in your Cartfile
:
github "mikebuss/MTBBarcodeScanner"
Run carthage update
to build the framework and drag the built MTBBarcodeScanner.framework
into your Xcode project.
If you'd prefer not to use a dependency manager, you can download these two files and add them to your project:
To import the library: #import "MTBBarcodeScanner.h"
To initialize an instance of MTBBarcodeScanner
:
scanner = [[MTBBarcodeScanner alloc] initWithPreviewView:self.previewView];
Where previewView
is the UIView
in which the camera input will be displayed.
If you only want to scan for certain MetaObjectTypes, you can initialize with the initWithMetadataObjectTypes:previewView:
method:
s = [[MTBBarcodeScanner alloc] initWithMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]
previewView:self.previewView];
If you are using the MTBBarcodeScanner
library on iOS 10 and later, you need to include the following Info.plist
key in order to request camera access or the application will crash:
<key>NSCameraUsageDescription</key>
<string>Can we access your camera in order to scan barcodes?</string>
Of course you can also set your own (localized) message here. To find out more about privacy-keys in iOS, check the official Apple documentation.
To read the first code and stop scanning:
Note: To avoid a delay in the camera feed, start scanning in viewDidAppear
and not viewDidLoad
.
[MTBBarcodeScanner requestCameraPermissionWithSuccess:^(BOOL success) {
if (success) {
NSError *error = nil;
[self.scanner startScanningWithResultBlock:^(NSArray *codes) {
AVMetadataMachineReadableCodeObject *code = [codes firstObject];
NSLog(@"Found code: %@", code.stringValue);
[self.scanner stopScanning];
} error:&error];
} else {
// The user denied access to the camera
}
}];
If the camera is pointed at more than one 2-dimensional code, you can read all of them:
NSError *error = nil;
[self.scanner startScanningWithResultBlock:^(NSArray *codes) {
for (AVMetadataMachineReadableCodeObject *code in codes) {
NSLog(@"Found code: %@", code.stringValue);
}
[self.scanner stopScanning];
} error:&error];
Note: This only applies to 2-dimensional barcodes as 1-dimensional barcodes can only be read one at a time. See relevant Apple document.
To continuously read and only output unique codes:
NSError *error = nil;
[self.scanner startScanningWithResultBlock:^(NSArray *codes) {
for (AVMetadataMachineReadableCodeObject *code in codes) {
if ([self.uniqueCodes indexOfObject:code.stringValue] == NSNotFound) {
[self.uniqueCodes addObject:code.stringValue];
NSLog(@"Found unique code: %@", code.stringValue);
}
}
} error:&error];
An alternative way to setup MTBBarcodeScanner is to configure the blocks directly, like so:
self.scanner.didStartScanningBlock = ^{
NSLog(@"The scanner started scanning! We can now hide any activity spinners.");
};
self.scanner.resultBlock = ^(NSArray *codes){
NSLog(@"Found these codes: %@", codes);
};
self.scanner.didTapToFocusBlock = ^(CGPoint point){
NSLog(@"The user tapped the screen to focus. \
Here we could present a view at %@", NSStringFromCGPoint(point));
};
[self.scanner startScanning];
This is useful if you would like to present a spinner while MTBBarcodeScanner is initializing.
If you would like to reference self
in one of these blocks, remember to use a weak reference to avoid a retain cycle:
__weak MyViewController *weakSelf = self;
self.scanner.resultBlock = ^(NSArray *codes){
[weakSelf drawOverlaysOnCodes:codes];
};
See the SwiftExampleViewController.swift
file in the repository for a working example of this.
import UIKit
import MTBBarcodeScanner
class SwiftExampleViewController: UIViewController {
@IBOutlet var previewView: UIView!
var scanner: MTBBarcodeScanner?
override func viewDidLoad() {
super.viewDidLoad()
scanner = MTBBarcodeScanner(previewView: previewView)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
MTBBarcodeScanner.requestCameraPermission(success: { success in
if success {
do {
try self.scanner?.startScanning(resultBlock: { codes in
if let codes = codes {
for code in codes {
let stringValue = code.stringValue!
print("Found code: \(stringValue)")
}
}
})
} catch {
NSLog("Unable to start scanning")
}
} else {
UIAlertView(title: "Scanning Unavailable", message: "This app does not have permission to access the camera", delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "Ok").show()
}
})
}
override func viewWillDisappear(_ animated: Bool) {
self.scanner?.stopScanning()
super.viewWillDisappear(animated)
}
}
To start scanning with a particular camera (front or back):
try self.scanner?.startScanning(with: .front,
resultBlock: { codes in
if let codes = codes {
for code in codes {
let stringValue = code.stringValue!
print("Found code: \(stringValue)")
}
}
import UIKit
import MTBBarcodeScanner
class ViewController: UIViewController {
var scanner: MTBBarcodeScanner?
override func viewDidLoad() {
super.viewDidLoad()
scanner = MTBBarcodeScanner(previewView: self.view)
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
scanner?.startScanningWithResultBlock({ (codes) in
for code in codes {
print(code)
}
}, error: nil)
}
}
By default, MTBBarcodeScanner will allow the user to tap the screen to focus the camera. To disable this functionality, set the allowTapToFocus
property to NO. To be notified when the user taps the screen, provide a block for the didTapToFocusBlock
property, like so:
self.scanner.didTapToFocusBlock = ^(CGPoint point){
NSLog(@"The user tapped the screen to focus. \
Here we could present a view at %@", NSStringFromCGPoint(point));
};
Switch to the opposite camera with the flipCamera
method on the scanner:
- (IBAction)switchCameraTapped:(id)sender {
[self.scanner flipCamera];
}
Or specify the camera directly using setCamera:error
, like so:
NSError *error = nil;
MTBBarcodeScanner *scanner = [[MTBBarcodeScanner alloc] initWithPreviewView:_previewView];
[scanner setCamera:MTBCameraFront error:&error];
Examples for these are in the demo project.
Under some circumstances you may want to freeze the video feed when capturing barcodes. To do this, call the freezeCapture
and unfreezeCapture
methods.
To limit the section of the screen that barcodes can be scanned in, set the scanRect
property on MTBBarcodeScanner inside the didStartScanning
callback block. See MTBAdvancedExampleViewController
for a working example of this.
__weak MTBAdvancedExampleViewController *weakSelf = self;
self.scanner.didStartScanningBlock = ^{
weakSelf.scanner.scanRect = weakSelf.viewOfInterest.frame;
};
To control the torch, set the torchMode
property or call the toggleTorch
method.
Available values include:
MTBTorchModeOff,
MTBTorchModeOn,
MTBTorchModeAuto
To capture a still image, call the captureStillImage:
method after you've started scanning.
The primary goals of this library are to:
Mike Buss
MTBBarcodeScanner is available under the MIT license. See the LICENSE file for more info.