Android Barcode Reader SDK

DataSymbol Barcode Decoding SDK

Download DataSymbol Android Demo from google play store You can download the Android test application from Google Play Store. The source code of this application you can find in Android SDK.

Text Box: RKD Software
www.DataSymbol.com
www.BarcodeTools.com
Text Box: DataSymbol Barcode Decoding SDK
Android  Barcode Decoding Library
Developer’s Guide


 


Table of Contents

 

Introduction. 3

Requirements. 4

Installation. 4

Directory Structure. 4

Technical Specifications. 5

Getting Started. 6

BarcodeReaderWrapper methods. 11

InitLib. 11

FreeLib. 11

Renew.. 11

getDeviceID.. 12

Decode. 12

GetBlurring. 13

BarcodeReaderWrapper members. 15

General 15

Decoder Settings. 15

Barcode Types. 17

Error Codes. 17

DecodingResult members. 18

 


 

Introduction

 

Android DataSymbol SDK is a barcode decoding library that can easily be integrated into a customer's applications.

DataSymbol SDK is supplied as a “.so” file (Dynamic Link Library).

High performance and reliable barcode decoding. It reads torn, crumpled barcodes and also barcodes corrupted in other ways. Decodes barcodes printed on various surfaces - plastic surfaces, distorted surfaces, etc.

Can search only part of image for barcodes.

Reads all barcodes from an image at a once independently of the orientation and location of the barcode.

Does not require the barcode to have a quiet zone. That is why it can read incorrectly positioned barcodes.

Can read barcodes from noisy and blurred images.

It can find barcodes that cannot be recognized.

Decodes images that have distortions typical of scanned images and images received by fax.

Processes low resolution and dithering images.

Decodes barcodes with human-introduced artifacts (signatures, marks, etc.).


 

Requirements

The DataSymbol SDK library has the following system requirements:

·         Android 2.1 or higher

·         Eclipse developer environment

 

Installation

Copy the SDK in any folder of your machine.

 

Directory Structure

DataSymbol SDK is a dynamic library written on С++. You should include into your project (libs/armeabi folder) only one file libbarcodereader.so.

The DataSymbol SDK contains the following directories and files:

/BarcodeReader/BarcodeDecoder/
libs/armeabi

armeabi-v7a

arm64-v8a

mips

mips64

libbarcodereader.so

/BarcodeReader/BarcodeDecoder/src/

com/datasymbol/barcodereader

Barcode reader wrapper.

·         BarcodeReaderWrapper.java

·         DecodingResult.java

/BarcodeDecoder1

Eclipse example.

/BarcodeDecoder2

Eclipse example. Multi threading.

 


 

Technical Specifications

Decodes all popular barcode types.

Linear:

Interleaved 2/5, Industrial 2/5, Code 39, Code 39 Extended, Codabar, Code 11, Code 128, Code 128 Extended, EAN/UCC 128, UPC-E, UPC-A, EAN-8, EAN-13, Code 93, Code 93 Extended, DataBar Omnidirectional (RSS-14), DataBar Truncated (RSS-14 Truncated), DataBar Limited (RSS Limited), DataBar Stacked, DataBar Expanded, DataBar Expanded Stacked.

2D: PDF417 (PDF417 Compact, Truncated), QRCode (Micro), DataMatrix, Aztec (Compact)

Decodes any oriented barcodes.

Decoding time: depends from many factors (library settings, image size, barcode count, etc.) but usually up to 50ms on 2 GHz machine on 840x480 image.

 

Approximately barcode resolution (minimal module size) in pixel

Linear: 0.7 px

PDF417: 1.3 px

DataMatrix: 2 px

QRCode: 1.6 px

AztecCode: 1.6 px


 

Getting Started

Create the empty BarcodeReader (or any else) folder (Eclipse workspace).

Open BarcodeReader workspace.

Untitled.png

 

 

Import BarcodeDecoder1 and BarcodeDecoder2 applications

 

Untitled1.png

 

Untitled2.png

 

Untitled3.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You will get Eclipse workspace

 

Untitled4.png

 

 

 

 

Clean Project (Project - Clean ...).

 

 

 

 

 

 

 

The usage of the library is very simple. Here below, please, find the typical sample of the library usage.

 

BarcodeReaderWrapper mbr;

mbr = new BarcodeReaderWrapper();

mbr.barcodeTypes |= BarcodeReaderWrapper.ST_AZTECCODE; //add AztecCode

mbr.InitLib( context );

 

public void onPreviewFrame(byte[] data, Camera camera)

{

//supported formats

int fmt = camera.getParameters().getPreviewFormat();

if( !(fmt == PixelFormat.YCbCr_422_SP ||

fmt == PixelFormat.YCbCr_420_SP) )

return;

 

//preview size

int width = camera.getParameters().getPreviewSize().width;

int height = camera.getParameters().getPreviewSize().height;

 

//decode the frame

DecodingResult[] decRes = mbr.Decode(data, width, height, 0, 0, 0, 0);

 

//successful

if( mbr.decError == 0 && decRes != null && decRes.length != 0 )

{

String sBarcodeText = new String( decRes[0].data, 0,

decRes[0].data.length );

}

 

 


BarcodeReaderWrapper methods

 

InitLib

Initializes library. You need to call this method before any else.

Syntax

public native boolean InitLib(Object activity);

 

 

Parameters

activity

Activity object. If you are working in demo mode you can set null.

 

Return Value

True if no errors.

 

FreeLib

Finalizes working with library.

Syntax

public native boolean FreeLib();

 

 

Return Value

True if no errors.

 

Renew

Force re-reading barcode decoder settings.

Syntax

public native boolean Renew();

 

 

 

 

 

 

 

 

Example

BarcodeReaderWrapper mbr;

mbr = new BarcodeReaderWrapper();

mbr.barcodeTypes |= BarcodeReaderWrapper.ST_AZTECCODE; //add AztecCode

mbr.InitLib( context );

//change decoder settings after initialization

mbr.barcodeTypes |= BarcodeReaderWrapper.ST_QRCODE;

 

mbr.Renew();

 

 

Return Value

True if no errors.

 

getDeviceID

Returns device ID. This ID has been used to activate SDK library on the device.

Syntax

public native String getDeviceID(Object activity);

 

 

Return Value

Device ID string.

 

Decode

Decodes one frame. The frame is a byte matrix. Each byte has the value from 0 to 255 and represents one image pixel. 0 means a black pixel, 255 means a white pixel. Pixels are placed from the left to the right, from top to bottom, row by row.

The matrix is passed to the Decode method as a one-dimensional array. The first upper line of the image is sent first, then comes the second line and so on.

See the picture below for explanation.

rawdata.gif

Syntax

public native DecodingResult[] Decode( byte[] img, int width, int height,

int left, int top, int right, int bottom );

 

Parameters

img

Array of bytes that contains the frame

width

frame width

height

frame height

left, top, right, bottom

scanning zone rectangle, if all parameters are null then scan whole frame

 

Return Value

DecodingResult array.

 

GetBlurring

Returns blurring value in required rect.

Syntax

public native int GetBlurring( byte[] img, int width, int height,

int left, int top, int right, int bottom );

 

Parameters

img

Array of bytes that contains the frame

width

frame width

height

frame height

left, top, right, bottom

Blurring measure rectangle, if all parameters are null then scan whole frame

 

 

Return Value

Blurring value.


 

BarcodeReaderWrapper members

 

General

sKey

Set this field if you have the license key to set SDK in production mode.

 

Example:

BarcodeReaderWrapper mbr;

mbr = new BarcodeReaderWrapper();

mbr.sKey = “MQgqfP6lARpINhTpNvxXh9vE3k...”;

mbr.InitLib( context );

 

decError

SDK saves in this field the decoding error or BR_OK if no errors

Decoder Settings

barcodeTypes

Sets what types of barcodes should be decoded. Each barcode type has specified integer value. The barcodeTypes property can consist of any combination of these values, you should use the OR for that.

Example:

barcodeTypes = DW_ST_PDF417|DW_ST_QRCODE;

inverseType

Sets what barcodes should be decoded (darks on light or lights on dark).

frameTime

Time to decode 1 frame in milliseconds, if 0 – time unlimited

bCalcBlurring

Calculate barcode blurring

Decoder Settings (Linear)

bLinearShowSymbologyID

Sets the value determining whether to add Symbology ID to the barcode text or not.

uiLinearFindBarcodes

Sets how many Linear barcodes should be decoded on the image. An image may contain one or several barcodes. Works only in Professional edition, Standard decodes only one barcode.

bLinearVerifyCheckDigit

Sets the value determining whether to verify the optional check digit in barcodes where this check digit is optional.

bLinearShowCheckDigit

Show the check digit or not.

bLinearShowStartStop

Show the start/stop characters or not. Some barcode types have start/stop characters (for example, Code39).

bLinearCode39EnableExtended

Decode Code 39 as Code 39 Extended or not.

bLinearUPCE2UPCA

Convert a UPC-E barcode to UPC-A or not.

uiLinearInterl25MinLen

The minimum length of an Interleaved 2/5 barcode. If the length of a read barcode is less than this value, the barcode is considered unrecognized.

uiLinearInterl25MaxLen

The maximum length of an Interleaved 2/5 barcode.

uiLinearIndustr25MinLen

The minimum length of an Industrial 2/5 barcode.

uiLinearIndustr25MaxLen

The maximum length of an Industrial 2/5 barcode.

uiLinearCode11MinLen

The minimum length of a Code11 barcode.

uiLinearCode11MaxLen

The maximum length of a Code11 barcode.

uiLinearCode39MinLen

The minimum length of a Code39 barcode.

uiLinearCode39MaxLen

The maximum length of a Code39 barcode.

uiLinearCode128MinLen

The minimum length of a Code128 barcode.

uiLinearCode128MaxLen

The maximum length of a Code128 barcode.

uiLinearCodabarMinLen

The minimum length of a Codabar barcode.

uiLinearCodabarMaxLen

The maximum length of a Codabar barcode.

uiLinearCode93MinLen

The minimum length of a Code93 barcode.

uiLinearCode93MaxLen

The maximum length of a Code93 barcode.

LinearDecSpeed

Linear barcode reading speed. Possible values:

·         0 - Normal

·         1 - Fast

·         2 - Slow

bLinearVerify

Verify linear barcode after decoding. Improves reliability linear barcode reading.

Decoder Settings (PDF417)

uiPDF417FindBarcodes

Sets how many PDF417 barcodes should be decoded on the image.

PDF417DecSpeed

PDF417 barcode reading speed.

bPDF417SymbologyID

Determining whether to add Symbology ID to the barcode text or not

bPDF417FindMicro

Decode or not Micro PDF417

bPDF417Robust

Activates the robust PDF417 decoder mode. This property can help to decode high distorted PDF417 barcodes.

Decoder Settings (DataMatrix)

uiDataMatrixFindBarcodes

Sets how many DataMatrix barcodes should be decoded on the image.

DataMatrixDecSpeed

DataMatrix barcode reading speed.

DataMatrixInverseType

what barcodes should be decoded (darks on light or lights on dark)

bDataMatrixSymbologyID

determining whether to add Symbology ID to the barcode text or not

bDataMatrixSupportECI

support or not ECI (Extended Channel Interpretation)

Decoder Settings (QRCode)

uiQRCodeFindBarcodes

Sets how many QRCode barcodes should be decoded on the image.

QRCodeDecSpeed

QRCode barcode reading speed.

bQRCodeSymbologyID

determining whether to add Symbology ID to the barcode text or not

bQRCodeFindMicro

Decode or not Micro QRCode

Decoder Settings (AztecCode)

uiAztecCodeFindBarcodes

Sets how many AztecCode barcodes should be decoded on the image.

AztecCodeDecSpeed

AztecCode barcode reading speed.

bAztecCodeSymbologyID

determining whether to add Symbology ID to the barcode text or not

Barcode Types

DW_ST_CODE128

Code 128

DW_ST_CODE39

Code 39

DW_ST_INTERL25

Interleaved 2/5

DW_ST_EAN13

EAN-13

DW_ST_EAN8

EAN-8

DW_ST_CODABAR

Codabar

DW_ST_CODE11

Code 11

DW_ST_UPCA

UPC-A

DW_ST_UPCE

UPC-E

DW_ST_INDUSTR25

Industrial 2/5

DW_ST_CODE93

Code 93

DW_ST_DATABAR_OMNI

DataBar omnidirectional, DataBar Truncated

DW_ST_DATABAR_LIM

DataBar limited

DW_ST_DATABAR_STACKED

DataBar stacked

DW_ST_DATABAR_EXP

DataBar Expanded

DW_ST_DATABAR_EXP_STACKED

DataBar Expanded stacked

DW_ST_LINEAR_UNDEC

unrecognized linear

DW_ST_PDF417_UNDEC

unrecognized PDF417

DW_ST_DATAMATRIX_UNDEC

unrecognized DataMatrix

DW_ST_QRCODE_UNDEC

unrecognized QRCode

DW_ST_AZTECCODE_UNDEC

unrecognized AztecCode

DW_ST_DATAMATRIX

DataMatrix

DW_ST_PDF417

PDF417

DW_ST_QRCODE

QRCode

DW_ST_AZTECCODE

AztecCode

Error Codes

BR_OK

Ok

BR_ERROR

Error

BR_NULL_DATA

img parameter in the Decode method is empty

BR_DATA_ERR_LEN

byte array length (Decode method) doesn't much to width and height

BR_CANT_GET_ARRAY

unable to get byte array elements

BR_LIB_NOT_INIT

library is not initialized

BR_DECODING_ERR

decoding error

BR_PACK_RESULT

can't transfer decoding result

 

DecodingResult members

 

barcodeType

Barcode type

data

Barcode data (byte array)

pt

Array of barcode coordinates (4 points)

blurring

Barcode blurring (calculated if bCalcBlurring is true)