iPhone Barcode Reader SDK

DataSymbol Barcode Decoding SDK

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


 


Table of Contents

 

Introduction. 3

Requirements. 4

Installation. 4

Directory Structure. 4

Technical Specifications. 5

Getting Started. 6

CDecoderWrap methods. 9

Decode. 9

Decode. 10

SetDecoderParams. 10

getResNum.. 11

getResBarcodeType. 11

getResHymanData. 11

getResData. 12

getResDQ.. 13

getResPoints. 13

Other Types. 14

DW_DECODEPARAMS structure. 14

Barcode Types. 16

Error Codes. 16

 


 

Introduction

 

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

DataSymbol SDK is supplied as a “.a” file (Static 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:

·         iPhone 3G or higher

 

Installation

Copy the SDK in any folder of your machine.

 

Directory Structure

DataSymbol SDK is a static library written on С++. You should include into your project only one file libdsdecoder.a.

The DataSymbol SDK contains the following directories and files:

/lib

libdsdecoder.a - fat library, includes armv6, armv7, armv7s, arm64, i386, x86_64 architectures

libdsdecoder-armv6.a-  for armv6 devices

libdsdecoder-armv7.a-  for armv7 devices

libdsdecoder-armv7s.a-  for armv7s devices

libdsdecoder-arm64.a-  for arm64 devices

/lib/iPhoneSimulator

libdsdecoder-i386.a for iPhone Simulator i386

Libdsdecoder-x86_64.a for iPhone Simulator x86_64

/BarcodeDecoder1

Xcode 3.2 project. Decodes barcodes from the live camera stream. Requires iOS 4.2 and higher.

Uses AVCapture classes.

This is the most applicable example.

/ Untitled

Xcode 3.2 project. It doesn't work with camera, contains the simplest example how to call the library methods.

 

Please, copy the required file  libdsdecoder.a  into a project folder or change the project settings to link with necessary libdsdecoder.a  file.

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), QRCode, DataMatrix, Aztec (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

Add the libdsdecoder.a file in your project settings

linkerflags.bmp

Add #include “DecoderWrap.h” in your source file where you want to use DataSymbol SDK.

Rename .m file on .mm to use C++ library.

 

If  linker shows the error like this:

ld: warning: ignoring file /BarcodeDecoder1/libdsdecoder.a, file was built for archive which is not the architecture being linked (armv7)

Undefined symbols for architecture armv7:

  "__ZNK12CDecoderWrap9getResNumEPi", referenced from:

Then use  this .a  file /lib/libdsdecoder-armv7.a (or /lib/libdsdecoder.a)

 

 

 

 

Add "AddSupport" framework in project settings

im1.jpg

 

or in any ".m" file.

im2.jpg


 

 

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

 

      //memory with gray scale image, placed row by row

      /*

      int imgWidth = 640;

      int imgHeight = 480;

      unsigned char* pImg = new unsigned char[imgWidth*imgHeight];

      */

 

      //create decoder object

      CDecoderWrap dec;

 

      dec.InitLib(0);

 

      DW_DECODEPARAMS decParams;

      decParams.barcodeTypes |= DW_ST_AZTECCODE//add AztecCode decoding

      dec.SetDecoderParams( decParams );

 

      int res = dec.Decode( pImg, imgWidth, imgHeight, 0 );

 

      if( res == DW_OK )

      {

            int num=0;

 

            res = dec.getResNum( &num );

            printf( "Decoded: %d\n", num );

            for( int i=0; i < num; ++i )

            {

                  const char* pszStr;

                  res = dec.getResHymanData( &pszStr, i );

                  printf( "%s\n", pszStr );

            }

      }

      else

      {

            printf( "Error: %d\n", res );

      }

 

 


 

CDecoderWrap methods

 

 

InitLib

 

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

Syntax

    int InitLib(const char* pszKey);

 

 

Parameters

pszKey

Library key.

 

Return Value

Error code. DW_OK if no errors.

 

 

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

      int Decode(unsigned char* pImg, int width, int height,

const DW_RECT* pRect);

 

Parameters

pImg

pointer to the frame array

width

frame width

height

frame height

pRect

scanning zone rectangle, if null scan whole frame

 

Return Value

Error code. DW_OK if no errors.

 

 

Decode

 

Decodes .pgm file.

Syntax

      int Decode(void* pPGM, unsigned int pgmLen, const DW_RECT* pRect);

     

Parameters

pPgm

pointer to the .pgm file in memory

pgmLen

.pgm file length

pRect

scanning zone rectangle, if null scan whole frame

 

Return Value

Error code. DW_OK if no errors.

 

SetDecoderParams

 

Sets all decoder properties.

Syntax

      int SetDecoderParams(const DW_DECODEPARAMS& decParams);

 

     

Parameters

decParams

DW_DECODEPARAMS structure

 

Return Value

Error code. DW_OK if no errors.

 

getResNum


Returns the quantity of barcodes which were found.

Syntax

      int getResNum(int* pNum) const;

 

Parameters

pNum

Gets the quantityt of barcodes which were found

 

Return Value

Error code. DW_OK if no errors.

 

getResBarcodeType


Returns barcode type.

Syntax

      int getResBarcodeType(unsigned int* pType, int resNum) const;

 

Parameters

pType

Returns barcode type

resNum

Number of the barcode you want  to get. The following condition should be fulfilled:

resNum >= 0 && resNum < num (returned by getResNum)

 

Return Value

Error code. DW_OK if no errors.

 

 

getResHymanData

 

Returns human readable data (barcode string).

Syntax

      int getResHymanData(const char** ppszStr, int resNum) const;

 

Parameters

ppszStr

Returns pointer to the zero terminated string.

resNum

Number of the barcode you want to get.

 

Return Value

Error code. DW_OK if no errors.

Example

const char* pszStr;

res = dec.getResHymanData( &pszStr, i );

printf( pszStr );

 

 

 

getResData

 

Returns raw barcode data. Some barcode types (PDF417, Code128, QRCode, etc.) can contain binary data, that is why to get this barcode you should better use this method instead of  getResHymanData.

Syntax

      int getResData(const unsigned char** ppData, int* pDataLen, int resNum);

 

Parameters

ppData

Returns pointer to the raw barcode data.

pDataLen

Data length.

resNum

Number of the barcode you want to get.

 

Return Value

Error code. DW_OK if no errors.

Example

const unsigned char* pData;

int dataLen;

res = dec.getResData( &pData, &dataLen, 0 );

for( int j=0; j < dataLen; ++j )

      printf( "%d ", pData[j] );

 

 

getResDQ


Returns barcode decoding reliability (decoding quality). Possible values 0…100. Decoding quality less than 30 is considered as bad. This parameter is actual for 2D barcodes (PDF417, DataMatrix, QRCode, Aztec).

Syntax

      int getResDQ(unsigned char* pDQ, int resNum) const;

 

Parameters

pDQ

Decoding Quality

resNum

Number of the barcode you want to get.

 

Return Value

Error code. DW_OK if no errors.

 

getResPoints


Returns barcode coordinates.

Syntax

      int getResPoints(const DW_POINT** ppt, int resNum) const;

 

Parameters

ppt

Pointer to the array with four DW_POINT structure

resNum

Number of the barcode you want to get.

 

Return Value

Error code. DW_OK if no errors.

Example

const DW_POINT* pt;

res = dec.getResPoints( &pt, 0 );

printf( "(%d,%d), (%d,%d), (%d,%d), (%d,%d)\n", pt[0].x, pt[0].y, pt[1].x, pt[1].y, pt[2].x, pt[2].y, pt[3].x, pt[3].y );

 

 


 

Other Types

 

DW_DECODEPARAMS structure

 
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 = DW_ST_PDF417|DW_ST_QRCODE;

inverseType

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

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.

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.

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.

 


 

Barcode Types

 

Barcode Type

Value

Constant

Code 128

0x00000001

DW_ST_CODE128

Code 39

0x00000002

DW_ST_CODE39

Interleaved 2/5

0x00000004

DW_ST_INTERL25

EAN-13

0x00000008

DW_ST_EAN13

EAN-8

0x00000010

DW_ST_EAN8

Codabar

0x00000020

DW_ST_CODABAR

Code 11

0x00000040

DW_ST_CODE11

UPC-A

0x00000080

DW_ST_UPCA

UPC-E

0x00000100

DW_ST_UPCE

Industrial 2/5

0x00000200

DW_ST_INDUSTR25

Code 93

0x00000400

DW_ST_CODE93

DataBar omnidirectional, DataBar Truncated

0x00000800

DW_ST_DATABAR_OMNI

DataBar limited

0x00001000

DW_ST_DATABAR_LIM

DataBar stacked

0x00002000

DW_ST_DATABAR_STACKED

DataBar Expanded

0x00004000

DW_ST_DATABAR_EXP

DataBar Expanded stacked

0x00008000

DW_ST_DATABAR_EXP_STACKED

unrecognized linear

0x01000000

DW_ST_LINEAR_UNDEC

unrecognized PDF417

0x02000000

DW_ST_PDF417_UNDEC

unrecognized DataMatrix

0x04000000

DW_ST_DATAMATRIX_UNDEC

unrecognized QRCode

0x08000000

DW_ST_QRCODE_UNDEC

unrecognized AztecCode

0x00100000

DW_ST_AZTECCODE_UNDEC

DataMatrix

0x10000000

DW_ST_DATAMATRIX

PDF417

0x20000000

DW_ST_PDF417

QRCode

0x40000000

DW_ST_QRCODE

AztecCode

0x80000000

DW_ST_AZTECCODE

 

 

Error Codes

 

Constant

Value

Description

DW_OK

0

Ok

DW_ERROR

1

Error

DW_ERR_IN_PARAM

2

Invalid input parameter

DW_CANT_ALLOC_MEM

3

Can't allocate memory

DW_LIB_NOT_INIT

4

Library is not initialized

DW_ERR_RES_IDX

5

Invalid decoding result index