BarcodeDecoder Methods

AboutBox
Opens an About window.

Syntax
object.AboutBox()
Return Value
No return value.



DecodeFile
Decodes barcodes in the specified image file.

Syntax
object.DecodeFile(FileName)
Parameters
FileName A string defining the file name.
Return Value
Integer. Returns the number of decoded barcodes.
Example
[Script]

var dec = new ActiveXObject("BarcodeReader.BarcodeDecoder");
var objBarcode;
dec.DecodeFile("c:\\barcodes.jpg");
for (var i=0; i < dec.Barcodes.length; i++)
{
  objBarcode = dec.Barcodes.item(i);
  alert(objBarcode.Text);
}

[Visual Basic]

Dim dec As Object
Set dec = CreateObject("BarcodeReader.BarcodeDecoder")

dec.DecodeFile ("c:\barcodes.jpg")

For i = 0 To dec.Barcodes.length - 1
   Dim bc As Barcode
   Set bc = dec.Barcodes.Item(i)
   MsgBox bc.Text
Next i

Set dec = Nothing

[C/C++]

//creates the barcode decoder object
CComPtr<IBarcodeDecoder> pIBarcodeDecoder;
HRESULT hr = pIBarcodeDecoder.CoCreateInstance( 
  _T("BarcodeReader.BarcodeDecoder") );
_ASSERTE( SUCCEEDED(hr) );

hr = pIBarcodeDecoder->DecodeFile( _bstr_t("c:\\barcodes.jpg") );
_ASSERTE( SUCCEEDED(hr) );



DecodeFileRect
Similar to the DecodeFile method, but searches only a certain part of the image defined by the parameters x, y, width, height.

Syntax
object.DecodeFileRect(FileName, x, y, width, height)
Parameters
FileName A string defining the file name.
x An integer value that defines the X coordinate of scanning zone.
y An integer value that defines the Y coordinate of scanning zone.
width An integer that defines the width of scanning zone.
height An integer that defines the height scanning zone.
Return Value
Integer. Returns the number of decoded barcodes.



DecodeStream
Similar to the DecodeFile method, but a file in the form of a data stream is passed as a parameter. Everything that is contained in the image file is passed as a data stream.

Syntax
object.DecodeStream(FileStream)
Parameters
FileStream A Variant that contains a safe array of Bytes.
Return Value
Integer. Returns the number of decoded barcodes.
Remarks
This method is convenient when there is no need to save the barcode image to a file, for instance, while decoding barcodes from some video capture device.



DecodeStreamRect
Similar to the DecodeStream method, but searches only a certain part of the image defined by the parameters x, y, width, height.

Syntax
object.DecodeStreamRect(FileStream, x, y, width, height)
Parameters
FileStream A Variant that contains a safe array of Bytes.
x An integer value that defines the X coordinate of scanning zone.
y An integer value that defines the Y coordinate of scanning zone.
width An integer that defines the width of scanning zone.
height An integer that defines the height scanning zone.
Return Value
Integer. Returns the number of decoded barcodes.



DecodeGrayMap
This method finds barcodes in a raw gray map. It is the fastest method as compared to the other methods because no additional image transformations are performed in this case.

Syntax
object.DecodeGrayMap(GrayMap, GrayMapWidth, GrayMapHeight)
Parameters
GrayMap A Variant that contains a safe array of Bytes.
GrayMapWidth Gray map width.
GrayMapHeight Gray map height.
Return Value
Integer. Returns the number of decoded barcodes.
Remarks
A gray map 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.
The matrix is passed to the DecodeGrayMap 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.

Decode barcodes from raw gray map stream
Example
[C/C++]

const BYTE pgm[6300] = {
  0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0, //...
};

//creates the barcode decoder object
CComPtr<IBarcodeDecoder> pIBarcodeDecoder;
HRESULT hr = pIBarcodeDecoder.CoCreateInstance( 
  _T("BarcodeReader.BarcodeDecoder") );
_ASSERTE( SUCCEEDED(hr) );

//creates the safe array
CComVariant var;
var.vt = VT_ARRAY | VT_UI1;
var.parray = SafeArrayCreateVector( VT_UI1, 0, sizeof(pgm) );
_ASSERTE( var.parray );

//locks the safe array
BYTE* pSaBuf=NULL;
if( SUCCEEDED(SafeArrayAccessData(var.parray, (void HUGEP**)&pSaBuf)) )
{
   //copy the image into the safe array
   memcpy( pSaBuf, pgm, sizeof(pgm) );
   //unlock safe array
   SafeArrayUnaccessData( var.parray );
}

hr = pIBarcodeDecoder->DecodeGrayMap( var, 105, 60 );



DecodeGrayMapRect
Similar to the DecodeGrayMap method, but searches only a certain part of the image defined by the parameters x, y, width, height.

Syntax
object.DecodeGrayMapRect(GrayMap, GrayMapWidth, GrayMapHeight,
  x, y, width, height)
Parameters
GrayMap A Variant that contains a safe array of Bytes.
GrayMapWidth Gray map width.
GrayMapHeight Gray map height.
x An integer value that defines the X coordinate of scanning zone.
y An integer value that defines the Y coordinate of scanning zone.
width An integer that defines the width of scanning zone.
height An integer that defines the height scanning zone.
Return Value
Integer. Returns the number of decoded barcodes.



SetProperty
It sets additional Barcode Decoder object properties. The input parameter PropertyValue is VARIANT, it can take data of various types depending on the PropertyName parameter.

Syntax
object.SetProperty(PropertyName, PropertyValue)
Parameters
PropertyName String that defines the property name.
PropertyValue Variant that contains the property value.


PropertyName Description
TotalBarcodes how many barcodes of all types to search for in the entire document.
Default value - 0 (unlimited)
FrameTime Time to decode 1 frame in milliseconds.
Default value - 0 (unlimited).
DecodePageNumber the number of the page to be recognized. This property works only for multipage files, e.g. TIFF, PDF. If this page does not exist in the file, an error will be returned during the decoding process. Default value - 0 (decode all pages).
AddFilter1 Filter binary scanning noise like this. Usually don't need to use this filter but it may need when image too distorted by this noise type.
AddFilter2 Filter binary scanning noise like this.
Filter2Value Filter 2 parameter. Recommended 0.5 - 1.5 (default 1).
BlurringRect the rect for blurring measure. This is string value like "0;10;150;100;" (where: 0-left, 10-top, 150-right, 100-bottom).
Default value - "0;0;0;0;" (don't measure).
BlurringValue the integer value of blurring if BlurringRect is determined. You can get this value after calling one of Decode___ method.
BlurringCalc calculate the blurring value of decoded barcode (default - false).
LinearInterl25MinLen 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.
Default value - 2
LinearInterl25MaxLen the maximum length of an Interleaved 2/5 barcode. If the length of a read barcode is greater than this value, the barcode is considered unrecognized.
Default value - 50
LinearIndustr25MinLen same as LinearInterl25MinLen only for Industrial 2/5 barcode
Default value - 1
LinearIndustr25MaxLen same as LinearInterl25MaxLen only for Industrial 2/5 barcode
Default value - 50
LinearCode11MinLen Default value - 1
LinearCode11MaxLen Default value - 50
LinearCode39MinLen Default value - 1
LinearCode39MaxLen Default value - 50
LinearCode128MinLen Default value - 1
LinearCode128MaxLen Default value - 70
LinearCodabarMinLen Default value - 1
LinearCodabarMaxLen Default value - 50
LinearFindErrorBarcodes search for linear barcodes that have not been recognized for some reason. For example, corrupted, partially closed, etc. Example here.
Default value - false
LinearBarcodesPerPage how many linear barcodes to search for on each page. By default, this value is 0, i.e. search for all barcodes on each page. If the number of found barcodes equals to LinearFindBarcodes, the search is stopped.
Default value - 0
LinearFastDecoding quick Linear barcode reading. It may be used on real-time barcode reading devices (mobile devices), where it is impossible to spend much time on recognition of poor-quality images. It is not recommended to set this property for image recognition on non-mobile devices. Default value - 0 (Normal). Possible values:0 - Normal
1 - Fast
2 - Slow
LinearVerify Verify linear barcode after decoding. Improves reliability linear barcode reading. Default value - False (don't verify).
PDF417BarcodesPerPage how many PDF417 barcodes to search for on each page. By default, this value is 0, i.e. search for all barcodes on each page.
Default value - 0
PDF417FindBarcodes how many PDF417 barcodes to search for in the entire document.
Default value - 1
PDF417FastDecoding same as LinearFastDecoding only for PDF417.
PDF417SymbologyID the value determining whether to add Symbology ID to the barcode text or not.
Default value - false
PDF417FindMicro Finds Micro PDF417 barcodes.
Default value - false
PDF417Robust Activates the robust PDF417 decoder mode. This property can help to decode high distorted PDF417 barcodes.
Default value - false
DataMatrixBarcodesPerPage how many DataMatrix barcodes to search for on each page. By default, this value is 0, i.e. search for all barcodes on each page.
Default value - 0
DataMatrixFindBarcodes how many DataMatrix barcodes to search for in the entire document.
Default value - 1
DataMatrixFastDecoding same as LinearFastDecoding only for DataMatrix.
DataMatrixInverseType what barcodes should be decoded (darks on light or lights on dark).
Default value - darks on light
DataMatrixSupportECI support or not ECI (Extended Channel Interpretation).
Default value - false
DataMatrixSymbologyID the value determining whether to add Symbology ID to the barcode text or not.
Default value - false
QRCodeBarcodesPerPage how many QRCode barcodes to search for on each page. By default, this value is 0, i.e. search for all barcodes on each page.
Default value - 0
QRCodeFindBarcodes how many QRCode barcodes to search for in the entire document.
Default value - 1
QRCodeFastDecoding same as LinearFastDecoding only for QRCode.
QRCodeSymbologyID the value determining whether to add Symbology ID to the barcode text or not.
Default value - false
QRCodeFindMicro Finds Micro QRCode barcodes.
Default value - false
AztecCodeBarcodesPerPage how many AztecCode barcodes to search for on each page. By default, this value is 0, i.e. search for all barcodes on each page.
Default value - 0
AztecCodeFindBarcodes how many AztecCode barcodes to search for in the entire document.
Default value - 1
AztecCodeFastDecoding same as LinearFastDecoding only for AztecCode.
AztecCodeSymbologyID the value determining whether to add Symbology ID to the barcode text or not.
Default value - false
VideoDelayAfterDec The pause (in milliseconds) in decoding after barcode has been found.
Default value - 1000 (1 second)
VideoDelayFrame The pause (in milliseconds) between frames.
Default value - 0 (no pause)
VideoDelayRedraw The pause (in milliseconds) between frames redrawing.
Default value - 0 (no pause)
VideoStretch Stretch or not image on control size.
Default value - 0 (doesn't stretch)
VideoBeep Beep or not after barcode.
Default value - 1 (beep)
Return Value
No return value.
Example
[Visual Basic]

Dim dec As Object
Set dec = CreateObject("BarcodeReader.BarcodeDecoder")

dec.BarcodeTypes = dec.BarcodeTypes Or &H20000000 'add PDF417
Call dec.SetProperty("PDF417FindBarcodes", 3)

dec.DecodeFile ("c:\pdf417.bmp")

For i = 0 To dec.Barcodes.length - 1
   Dim bc As Barcode
   Set bc = dec.Barcodes.Item(i)
   MsgBox bc.Text
Next i

Set dec = Nothing



GetProperty
Returns the properties set with the SetProperty method.

Syntax
object.GetProperty(PropertyName)
Parameters
PropertyName String that defines the property name.
Read only parameters
GetErrorLinear Returns last error code of Linear decoder.
GetErrorPDF417 Returns last error code of PDF417 decoder.
GetErrorDataMatrix Returns last error code of DataMatrix decoder.
GetErrorQRCode Returns last error code of QRCode decoder.
GetErrorAztecCode Returns last error code of AztecCode decoder.
Return Value
Variant. Returns the property value.



GetSDKInfo
Returns various SDK information.

Syntax
object.GetSDKInfo(Version, Edition, Symbology, buildDate, LicenseInfo, expDate, hwID)
Parameters
Version Returns String that defines SDK version. "5.02" for example.
Edition Returns Integer that defines SDK edition. 1 - Standard Edition, 2 - Professional Edition.
Symbology Returns Integer that defines what barcodes types can decode this instance of SDK.
1 - Linear Barcode
2 - PDF417
4 - DataMatrix
8 - QRCode
16 - Aztec Code
Symbology value can combine (binary OR operation) different barcode types. For example: 3 - means Linear+PDF417, 1 - only Linear, 24 - QRCode+Aztec.
buildDate Returns DATE (double) that defines SDK building date.
LicenseInfo Returns String that defines the license owner. If this value is null or empty then SDK works in demo mode.
expDate expDate returns the DATE (double value) on which the subscription will expire. All SDKs released before this date (whose buildDate is less than the expDate) will work without any limitations. Newer versions released after the expDate will work only in demo mode.
If expDate is -1 then subscription expired.
hwID Returns hardware ID used in SDK.
Return Value
No return value.



VideoStart
Starts barcode decoding from video input device. To see video set ShowImage property.

Syntax
object.VideoStart(cameraID, frameWidth, frameHeight)
Parameters
cameraID Video device number (0 is first device).
frameWidth Required frame width.
frameHeight Required frame height.
Return Value
No return value.
Remarks
If frameWidth or frameHeight is 0 then SDK selects the maximum frame resolution. If the device doesn't not support the required frameWidthxframeHeight format then SDK selects nearest format.



VideoStop
Stops decoding from video input device.

Syntax
object.VideoStop()
Return Value
No return value.



VideoSuspend
Suspends or resume video decoding.

Syntax
object.VideoSuspend(Suspend)
Parameters
Suspend A Boolean type to determine video suspending.
Return Value
No return value.