Barcode Reader & Decoder Software

Home arrow Barcode Recognition SDK arrow Java SDK
Home
Barcode Recognition SDK
Barcode Scanner
Document Processor
Buy Now
††
FAQs
Support
OnLine Barcode Decoder

Our Barcode Creation Tools:
www.BarcodeTools.com

On-Line Barcode Generator:
www.bcmaker.com

Barcode Generator
Barcode Reader Java SDK
DataSymbol Java SDK

Text Box: RKD Software & RKD System Inc.
www.DataSymbol.com
www.BarcodeTools.com
Text Box: DataSymbol Java SDK
Linux/MacOS/Windows  Barcode Decoding Library
Developerís Guide


 


Table of Contents

 

Introduction. 3

Installation. 4

Directory Structure. 5

Getting Started. 6

BarcodeReaderWrapper class. 7

InitLib. 7

Decode. 7

DecodePgm.. 8

SetParams. 8

decError. 9

Error Codes. 9

DecoderParameters class. 10

DecoderParameters members. 10

DecoderParameters Barcode Types. 12

DecodingResult class. 13

DecodingResult members. 13

 


 

Introduction

 

This Java DataSymbol Barcode Reader SDK is a wrapper for barcode decoding library (libdsdecoder.so.1 on Linux, BarcodeReader.dll on Windows). This wrapper works with native barcode library through JNI interface.


 

Installation

Copy the Java library in required folder of your machine.

         Linux/MacOS

copy "libjnidsdecoder.so" file in "/usr/lib" folder or any other folder where Java finds required libraries.

 

         Windows

 

copy "jnidsdecoder.dll" file in "windows/system32" folder or any other folder where Java finds required libraries.


 

Directory Structure

 

The Java SDK contains the following directories and files:

Java/ libjnidsdecoder.so (on Linux)

Or

Java/jnidsdecoder.dll (on Windows)

Java JNI library.

Java/src/main.java

Simple Java example

Java/src/com/datasymbol/barcodereader/

BarcodeReaderWrapper.java

DecoderParameters.java

DecodingResult.java

The Java Barcode Reader classes

 


 

Getting Started

 

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

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

 

import com.datasymbol.barcodereader.BarcodeReaderWrapper;

import com.datasymbol.barcodereader.DecoderParameters;

import com.datasymbol.barcodereader.DecodingResult;

 

class Main

{

†††††† public static void main(String[] args) throws IOException

†††††† {

†††††† ††† BarcodeReaderWrapper dec = new BarcodeReaderWrapper();

†††††† ††† boolean b = dec.InitLib("");

†††††† ††† if(!b)

†††††† ††† {

†††††† †††††† System.out.println(String.format("Error: %d", dec.decError));

†††††††††††† return;

†††††† ††† }

††††††††††††

†††††† ††† //set decoder parameters

†††††† ††† DecoderParameters dp = new DecoderParameters();

†††††† ††† dp.barcodeTypes |= DecoderParameters.ST_DATAMATRIX;

†††††† ††† b = dec.SetParams(dp);

††††††††††††

†††††† ††† //read file

†††††† ††† Path path = Paths.get("img_lin.pgm");

†††††† ††† byte[] data = Files.readAllBytes(path);

 

†††††† ††† //decode

†††††† ††† DecodingResult res[] = dec.DecodePgm(data, 0, 0, 0, 0);

††† †† ††††for(int j=0; res!=null && j < res.length; ++j)

††† †† ††††{

††† †† †††††††String sBarcode = new String( res[j].data, 0, res[j].data.length );

††† †† †††††††System.out.println(sBarcode);

††† †† ††††}

†††††† }

}

 

 


BarcodeReaderWrapper class

 

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

Syntax

†††††† boolean InitLib(String sKey);

 

 

Parameters

sKey

Library key.

 

Return Value

True if no errors, otherwise see decError member.

 

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

†††††† DecodingResult[] Decode( byte[] graymapImage, int width, int height, int left, int

†††††††††††† top, int right, int bottom );

 

Parameters

graymapImage

pointer to the frame array

width

frame width

height

frame height

Left,top,right,bottom

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

 

Return Value

DecodingResult Array or null if no barcodes.

 

DecodePgm
Decodes .pgm file.

Syntax

†††††† DecodingResult[] DecodePgm( byte[] pgmImg, int left, int top, int right, int bottom );

†††††

Parameters

pgmImg

pointer to the .pgm file in memory

Left,top,right,bottom

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

 

Return Value

DecodingResult Array or null if no barcodes.

 

SetParams
Sets all decoder properties.

Syntax

†††††† boolean SetParams(DecoderParameters dp);

 

†††††

Parameters

dp

DecoderParameters structure

 

Return Value

True if no errors, otherwise see decError member.

 

decError

If some functions returns the negative result check this field to get the error code.

 

Error Codes

 

Constant

Value

Description

BR_OK

0

Ok

BR_ERROR

1

Error

BR_NULL_DATA

2

Data to encode is null

BR_DATA_ERR_LEN

3

byte array length doesn't match the width and height

BR_CANT_GET_ARRAY

4

unable to get byte array elements

BR_LIB_NOT_INIT

5

Library is not initialized

BR_DECODING_ERR

6

Error during decoding

BR_PACK_RESULT

7

cannot pack decoding result

BR_CANT_CREATE_DECODER

8

cannot create barcode decoder object

BR_ERR_INPUT

9

invalid input parameter

 


 

DecoderParameters class

 

DecoderParameters†members
Sets all decoder properties.

General

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 = BR_ST_PDF417|BR_ST_QRCODE;

inverseType

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

frameTime

Time to decode 1 frame in milliseconds.

Default value - 0 (unlimited).

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

PDF417

uiPDF417FindBarcodes

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

PDF417DecSpeed

PDF417 barcode reading speed.

bPDF417SymbologyID

Add Symbology ID to the barcode text or not.

bPDF417FindMicro

Finds Micro PDF417 barcodes.

Default value - false

bPDF417Robust

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

Default value - false

DataMatrix

uiDataMatrixFindBarcodes

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

DataMatrixDecSpeed

DataMatrix barcode reading speed.

bDataMatrixSymbologyID

Add Symbology ID to the barcode text or not.

DataMatrixInverseType

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

bDataMatrixSupportECI

Support or not ECI (Extended Channel Interpretation).

QRCode

uiQRCodeFindBarcodes

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

QRCodeDecSpeed

QRCode barcode reading speed.

bQRCodeSymbologyID

Add Symbology ID to the barcode text or not.

bQRCodeFindMicro

Finds Micro QRCode barcodes.

AztecCode

uiAztecCodeFindBarcodes

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

AztecCodeDecSpeed

AztecCode barcode reading speed.

bAztecCodeSymbologyID

Add Symbology ID to the barcode text or not.

 


 

DecoderParameters†Barcode Types

 

Barcode Type

Value

Constant

Code 128

0x00000001

ST_CODE128

Code 39

0x00000002

ST_CODE39

Interleaved 2/5

0x00000004

ST_INTERL25

EAN-13

0x00000008

ST_EAN13

EAN-8

0x00000010

ST_EAN8

Codabar

0x00000020

ST_CODABAR

Code 11

0x00000040

ST_CODE11

UPC-A

0x00000080

ST_UPCA

UPC-E

0x00000100

ST_UPCE

Industrial 2/5

0x00000200

ST_INDUSTR25

Code 93

0x00000400

ST_CODE93

DataBar omnidirectional, DataBar Truncated

0x00000800

ST_DATABAR_OMNI

DataBar limited

0x00001000

ST_DATABAR_LIM

DataBar stacked

0x00002000

ST_DATABAR_STACKED

DataBar Expanded

0x00004000

ST_DATABAR_EXP

DataBar Expanded stacked

0x00008000

ST_DATABAR_EXP_STACKED

unrecognized linear

0x01000000

ST_LINEAR_UNDEC

unrecognized PDF417

0x02000000

ST_PDF417_UNDEC

unrecognized DataMatrix

0x04000000

ST_DATAMATRIX_UNDEC

unrecognized QRCode

0x08000000

ST_QRCODE_UNDEC

unrecognized AztecCode

0x00100000

ST_AZTECCODE_UNDEC

DataMatrix

0x10000000

ST_DATAMATRIX

PDF417

0x20000000

ST_PDF417

QRCode

0x40000000

ST_QRCODE

AztecCode

0x80000000

ST_AZTECCODE

 


 

DecodingResult class

 

DecodingResult†members
Determines decoded barcode.

barcodeType

Barcode Type

data

Array of bytes of decoded barcode.

x1,y1,† x2,y2,† x3,y3,† x4,y4

Barcode coordinates

rel

Returns the decoding quality (0...100).

Works only for PDF417, DataMatrix, QRCode, AztecCode barcodes.

 

 

 

Copyright © 1999-2017, RKD Software & RKD System Inc., All rights reserved.
All trademarks mentioned are the property of their respective owners.