Scanning a barcode from an image
Processing the image
The barcode scanner can quickly analyze a still image and identify any barcodes present within it. Once a barcode is detected, the scanner extracts information and returns the result. Take a look at an example down below:
Example for detecting barcodes on the image
- Swift
- Objective-C
import Foundation
import ScanbotBarcodeScannerSDK
func detectBarcodesOnImage() {
// Image containing barcode.
guard let image = UIImage(named: "barcodeImage") else { return }
// Types of barcodes you want to detect.
let typesToDetect = SBSDKBarcodeType.allTypes
// Creates an instance of `SBSDKBarcodeScanner`.
let detector = SBSDKBarcodeScanner(types: typesToDetect)
// Returns the result after running detector on the image.
let result = detector.detectBarCodes(on: image)
}
#import "BarcodeDetectionOnImage.h"
@import ScanbotSDK;
@implementation BarcodeDetectionOnImage
- (void) detectBarcodesOnImage {
// Image containing barcode.
UIImage *image = [UIImage imageNamed:@"barcodeImage"];
// Types of barcodes you want to detect.
NSArray<SBSDKBarcodeType *> *typesToDetect = [SBSDKBarcodeType allTypes];
// Creates an instance of `SBSDKBarcodeScanner`.
SBSDKBarcodeScanner *detector = [[SBSDKBarcodeScanner alloc] initWithTypes:typesToDetect];
// Returns the result after running detector on the image.
NSArray<SBSDKBarcodeScannerResult *> *results = [detector detectBarCodesOnImage:image];
}
@end
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.