Skip to content

VisionSmarts/VSBarcodeReader-iOS

Repository files navigation

VSBarcodeReader for iOS - Evaluation only

⚠️ PROPRIETARY SOFTWARE & EVALUATION ONLY

This SDK is not open source. Use of the libraries and sample code provided in this repository is strictly limited to internal evaluation and testing only.

Any other production use or distribution is explicitly prohibited under the terms of the LICENSE file.

To use this SDK in a production environment, pilot program, or for any purpose other than evaluation, you must obtain a commercial license.

Overview

This project contains sample code that demonstrates one way of using the iOS/iPadOS APIs to capture a video stream and read barcodes using the VSBarcodeReader library.

The Android version of the VSBarcodeReader library, with the same APIs and capabilities, is available here: https://github.com/visionsmarts/VSBarcodeReader-Android.

Compiled versions of the iOS and Android "showcase" apps (the code in this repository and its Android sibling) are available on the App Store and Google Play Store for immediate testing:

Commercial Licensing

Interested in using the VSBarcodeReader SDK for a pilot, production app, or commercial project? We offer a simple, no-hassle yearly subscription license per app, with unlimited downloads.

To request a commercial license or a formal quote:

Contents of the Binary Library

The binary libraries can be fetched from the Vision Smarts server (no account needed) with the following command:

/bin/bash fetch_binary_libraries.sh

For extra security, verify the SHA256 checksum on www.visionsmarts.com

The VSBarcodeReader library is provided in the VSBarcodeReader-EVAL.xcframework package. It contains the iphoneos and iphonesimulator frameworks with arm64 and x86_64 slices.

The VSBarcodeReader library implements the VSBarcodeReader object that is declared in the VSBarcodeReader.h header file (copied below for convenience).

The methods of the VSBarcodeReader object are used to decode barcodes from image buffers obtained from an AVCaptureSession. The binary library's functionality is purely computational. It does not include any UI or image capture elements.

Important notes about the evaluation library

The functionality of the evaluation library is time-limited to about one minute after app launch. After that, the decoding method will return no barcode data, even if barcodes are present in the image.

The evaluation library transmits usage data, including device and application identifiers and IP addresses, to Vision Smarts. No personally identifiable information is collected or transmitted.

The commercially-licensed production library does not have any execution time limit and does not transmit any data.

Sample Code

The Swift sample code demonstrates how to:

  • set up and configure a VSBarcodeReader object,
  • set up an AVCaptureSession with live preview,
  • extract image buffers from the video frames, and pass them to the VSBarcodeReader object for decoding,
  • display the decoded barcode results.

After you acquire a license, the sample code can be freely copied and modified to fit the needs of your application.

The sample app's view structure is as follows:

  • MenuViewController.swift is the main view controller, it instantiates the following:
  • ScannerViewController.swift is the modal view that implements the real-time scanner
  • LiveResultsOverlayView.swift is the overlay that displays the live detected barcodes

The AVCaptureSession captures a continuous stream of images and the VSBarcodeReader object attempts barcode decoding.

The readFromImageBufferMultiple: method of the VSBarcodeReader object looks for barcodes in the specified rectangle image and in any orientation. It can also scan the entire image, or single horizontal or vertical line. It can return zero, one, or multiple barcodes detected in the input image.

These samples are view-based applications. A Tab Bar or an OpenGL application would integrate the camera view and overlays differently. Image capture and barcode decoding would be identical.

About symbologies

  • Only enable the symbologies that the application demands, since looking for more symbologies will slightly slow down decoding and cause misreads of symbologies with weak error detection such as Codabar or ITF.
  • Code 39, Code 93, Code 128, Codabar, ITF, Std2of5, Telepen, GS1 Databar can only be read when all the bars are visible (no blurry barcodes).
  • Derived formats with check character like ITF-14 and Code 39 mod 43 are not explicitly supported, but any checksum can easily be computed in the decodeImageOmnidirectional method of ScannerViewController before stopping the scanner.

(c) VISION SMARTS SRL 2009-2026

HEADER SYMBOLS

typedef NS_ENUM(NSInteger, VSSymbologies)   {
    // 1D symbologies
    kVSEAN13_UPCA = 0x0001,
    kVSEAN8       = 0x0002,
    kVSUPCE       = 0x0004,
    kVSITF        = 0x0008,
    kVSCode39     = 0x0010,
    kVSCode128    = 0x0020,
    kVSCodabar    = 0x0040,
    kVSCode93     = 0x0080,
    kVSStd2of5    = 0x0100,
    kVSTelepen    = 0x0200,
    kVSDatabarOmnidirectional    = 0x0400,
    kVSDatabarLimited            = 0x0800,
    kVSDatabarExpanded           = 0x1000,
    kVSEANPlus2  = 0x2000,
    kVSEANPlus5  = 0x4000,

    // 2D symbologies
    kVSQRCode     = 0x08000,
    kVSDataMatrix = 0x10000
};

typedef NS_ENUM(NSInteger, VSQRMode) {
    kVSQRNumericMode = 1,
    kVSQRAlphaMode   = 2,
    kVSQRByteMode    = 4,
    kVSQRKanjiMode   = 8,
};

// =====================================================
// Class VSBarcodeData holding the data belonging to one found barcode
@interface VSBarcodeData : NSObject

// For all symbologies: the barcode symbology (VSSymbologies)
@property NSInteger symbology;

// For all symbologies: the barcode text
// For QR: assuming UTF8 encoding (may be nil if not)
// For DataMatrix: assuming Iso-Latin-1 encoding  (may be nil if not)
@property NSString* text;

// For QR and DataMatrix: the data content
@property NSData* data;

// For QR and DataMatrix: the raw data content
@property NSData* bits;

// For QR and DataMatrix: Structured Append values
@property NSInteger sequenceLength;
@property NSInteger sequencePosition;
@property NSInteger sequenceChecksum;

// For QR: bit mask of the modes (VSQRMode) present in the data
@property NSInteger mode;

// Location of the barcode in the image
//      to draw a rectangle, order is 1, 2, 4, 3, 1
//      1, 2 and 3 are the basis corners of QR and DataMatrix codes
//      for 1D codes, 1 and 3 may be same, and 2 and 4 may be same
@property CGPoint corner1;
@property CGPoint corner2;
@property CGPoint corner3;
@property CGPoint corner4;

@end
// =====================================================


@interface VSBarcodeReader : NSObject {
}

// initializes the reader
-(id) init;

// reset the reader before reading new code
-(void) reset;

// Gives next image buffer of video stream to decode in any direction
//
// Returns all the barcodes found in image
//
// Image buffer is normally obtained from AVCaptureSession
// Pixel Format of Image buffer MUST BE either:
// -420v (preferably - video settings kCVPixelBufferPixelFormatTypeKey = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange)
// -2vuy (iPhone 3G  - video settings kCVPixelBufferPixelFormatTypeKey = kCVPixelFormatType_422YpCbCr8)
// -BGRA (deprecated - video settings kCVPixelBufferPixelFormatTypeKey = kCVPixelFormatType_32BGRA)
//
// return value: (NSArray*) of VSBarcodeData* (defined above) if code has been read,
//                          or array of size zero if no code has been found and more images are needed
//
// readFromImageBufferMultiple:(CVImageBufferRef) : image buffer from video capture
//
// symbologies:(int)symbologies : OR'ed values from the VSSymbologies enum (defined above)
//                                the symbologies to attempt reading
//                                for example, pass 0x01|0x08 (0x09) to decode EAN13 and ITF
//
// inRectFrom:(CGPoint)topLeft : top left of sub-image rectangle where to look for barcodes
//                               in normalized (x=0..1, y=0..1) image coordinates
//                               regardless of UI orientation (0,0) is upper left of image, (1,1) is bottom right.
//                               use (0,0) to read entire image
//
// to:(CGPoint)bottomRight : bottom right of sub-image rectangle where to look for barcodes
//                           use (1,1) to read entire image
//
-(NSArray*) readFromImageBufferMultiple:(CVImageBufferRef)imageBuffer symbologies:(int)symbologies  inRectFrom:(CGPoint)topLeft to:(CGPoint)bottomRight;

About

Barcode Scanner SDK for iOS - Reads EAN, GS1 Databar, Code 128, 39, QR, DataMatrix, etc. even dirty, damaged, or crumpled. Commercial - Eval Only

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors