IDAutomation® .NET Barcode
Barcode Recognition
Manual & Tutorial
INDEX:
Application
Compatibility
IDAutomation's .NET Barcode Recognition Decoder
SDK is compatible with the .NET Framework 1.1 or greater.
|
Barcode
Symbology Compatibility |
| Linear
Symbology Compatibility |
Code
39, Extended Code 39, Code 128 (with character sets Auto, A, B and C),
GS1-128 (aka: UCC/EAN-128), USS-128, Interleaved 2 of 5, Codabar,
UPC-A, MSI, EAN-13 and Industrial 2 of 5. |
|
Installation:
- Download and unzip the package into a directory on
the development computer.
- Copy BarcodeDecoder.dll
to the project directory. In visual studio, select Project - Add
Reference and choose the DLL. Do not copy the DLL to the bin directory;
upon compiling the project, the DLL in the project folder will be
copied to the appropriate bin folder with the associated EXE file
automatically.
- Examples
are provided below that should help with the various methods of using
the product.
| Properties
and Methods |
| IDAutomation
recommends using default values for all properties, unless requirements
dictate otherwise. This section explains the main configuration
properties and methods. |
| Name |
Default |
Description |
| ReadBarcode |
N/A |
This
is the main entry point for most implementations,
this method returns a string array, address 0 is the decoded data, 1 is
the symbology, and 3 is the bar pattern. If no barcode is detected,
address 1 and 2 are set to "No Barcode Found", and address 3 is set to
null. |
| Angle |
0 |
An
integer value in the range from 0 to 359 that represents the number of
degrees the decoder will rotate clockwise on the image for recognition.
This is most useful when decoding images that are already
rotated. Images should be decoded from left to right. |
| AngleTolerance |
20 |
Rotates
the decoder on the image (plus and minus the given value) using the Angle property for the center
reference. For example, if Angle is set to 45 and the AngleTolerance is
5, the decoder will be rotated on the image 45 degrees to attempt a
scan, if no barcode is decoded after the first scan, it will be rotated
to 46, 44, 47, 43, etc. until it either successfully decodes a symbol
or uses up the allowed tolerance (40 to 50 degrees.) Setting this value
too high may increase processor utilization. |
| Code39FullAscii |
false |
If
set to True, decodes the Code-39 barcode in the extended
code 39 character set. |
| DecodeCode128 |
true |
Attempts
to decode the Code-128 barcode type. |
| DecodeCode39 |
true |
Attempts
to decode the Code-39 barcode type. |
| DecodeUpcEan |
false |
Attempts to decode the UPC-A
and EAN-13 barcode type. |
| DecodeCode93 |
false |
Attempts
to decode the Code-93 barcode type. |
| DecodeCodabar |
false |
Attempts
to decode the Codabar barcode type. |
| DecodeCode11 |
false |
Attempts
to decode the Code-11 barcode type. |
| DecodeMSI |
false |
Attempts
to decode the MSI Plessey barcode type. |
| DecodeInterleaved2of5 |
true |
Attempts
to decode the Interleaved 2 of 5 barcode type. |
| DecodeCode2of5 |
false |
Attempts
to decode the Code 2 of 5 (aka industrial 2 of 5) barcode type. |
| ExpandToEAN13 |
false |
If
set to true, this will expand a UPC-A or EAN 13 barcode to thirteen
digits. |
| DecodedFNC1First* |
]C1 |
A
string that will be substituted for the first FNC1 character.* |
| DecodedFNC1Additional* |
Group Separator |
A
string that will be substituted for the second FNC1 character.* |
| DecodedFNC2* |
Å |
A
string that will be substituted for the FNC2 character.* |
| DecodedFNC3* |
Ä |
A
string that will be substituted for the FNC3 character.* |
| DecodedFNC4* |
È |
A
string that will be substituted for the FNC4 character.* |
*These properties utilize the tilde character as a
method of entering in special characters. Entering in a "~" followed by
three numeric values will set property to the ASCII
equivalent. For example setting the DecodedFNC2 property to "~202" all
FNC2 characters will be represented as a "Ê" character in the
decoded string.
The code below assumes that the BarcodeDecoder object is
named "reader" and a picture box control named "barcode" has been added
to the form.
- Displaying the decoded data in text boxes:
Visual Basic .NET:
Dim barcodeData() As String
barcodeData=
reader.ReadBarcode(barcode.Image)
txtDecodedData.Text = barcodeData(0)
txtSymbology.Text = barcodeData(1)
txtBarPattern.Text = barcodeData(2)
C# .NET:
string
[] barcodeData= reader.ReadBarcode((Bitmap)barcode.Image);
txtDecodedData.Text = barcodeData[0];
txtSymbology.Text = barcodeData[1];
txtBarPattern.Text = barcodeData[2];
- Passing
a piece of an image to the ReadBarcode method (this
example checks the upper left region for a barcode):
Visual Basic .NET:
'declare the beginning and ending pixels of the image on the x and y
axis
Dim xStart As Integer = 0
Dim yStart As Integer = 0
Dim xEnd As Integer = barcode.Image.Width
Dim yEnd As Integer =
barcode.Image.Height
'set the end pixels to the upper left
region of the image
xEnd = xEnd / 2
yEnd = yEnd / 2
Dim PartialImgWidth As Integer = xEnd -
xStart
Dim PartialImgHeight As Integer = yEnd -
yStart
'Since picture box controls do not have
a GetPixel method, create a bitmap to hold the partial image
Dim copy As Bitmap
Dim partialImage As Bitmap
copy = New Bitmap(barcode.Image,
barcode.Image.Width, barcode.Image.Height)
partialImage = New
Bitmap(PartialImgWidth, PartialImgHeight)
Dim x As Integer
Dim y As Integer
'set the pixels of the partial image to
the same color of the copied barcode image
For x = xStart To xEnd - 1
For y = yStart To yEnd - 1
partialImage.SetPixel(x - xStart, y - yStart, copy.GetPixel(x, y))
Next y
Next x
barcode.Image = partialImage
C# .NET:
//declare
the beginning and ending pixels of the image on the x and y axis
int xStart = 0;
int yStart = 0;
int xEnd = barcode.Image.Width;
int yEnd = barcode.Image.Height;
//now we will set the end pixels to the
upper left region of the image
xEnd /= 2;
yEnd /= 2;
int PartialImgWidth = xEnd - xStart;
int PartialImgHeight = yEnd - yStart;
//Since picture box controls do not have
a GetPixel method, create a bitmap to hold the partial image
Bitmap copy = new Bitmap(barcode.Image,
barcode.Image.Width, barcode.Image.Height);
Bitmap partialImage = new
Bitmap(PartialImgWidth, PartialImgHeight);
//set the pixels of the partial image to
the same color of the copied barcode image
for (int x = xStart; x < xEnd;
x++)
{
for (int y = yStart; y < yEnd; y++)
{
partialImage.SetPixel(x - xStart, y - yStart, copy.GetPixel(x, y));
}
}
barcode.Image = partialImage;
Note: other regions of the document may be
easily specified, use the calculations below for other regions of the
image:
Upper Right:
xStart = xEnd / 2
yEnd = yEnd / 2
Downward Left:
xEnd = xEnd / 2
yStart = yEnd / 2
Downward Right:
xStart = xEnd / 2
yStart = yEnd / 2
- Decoding
a rotated image (assumes the image being passed in
is
already at 90°)
Visual Basic .NET:
Dim reader As New
IDAutomation.BarcodeDecoder.BarcodeDecoder
reader.Angle = 90
Dim barcodeData() As String
barcodeData=
reader.ReadBarcode(barcode.Image)
txtDecodedData.Text = barcodeData(0)
txtSymbology.Text = barcodeData(1)
txtBarPattern.Text = barcodeData(2)
C# .NET:
IDAutomation.BarcodeDecoder.BarcodeDecoder reader = new
BarcodeDecoder();
reader.Angle = 90;
string [] barcodeData=
reader.ReadBarcode((Bitmap)barcode.Image);
txtDecodedData.Text = barcodeData[0];
txtSymbology.Text = barcodeData[1];
txtBarPattern.Text = barcodeData[2];
Free product support may be obtained by reviewing
resolved public
help desk issues. Priority phone, e-mail and help desk support
is provided up to 60 days after purchase. Additional priority phone,
e-mail and help desk support
may be obtained if a Priority
Support and Upgrade Subscription is active.
Common
Problems and Solutions:
- Performance Improvements:
Decode performance is improved by setting the Angle property to the angle that is
most accurate. For example, if scanned barcodes usually appear at 7
degrees (meaning the barcode image is rotated 7 degrees clockwise), the
Angle property should
be 7. Additional performance is improved by setting all symbologies
to false except the type that is being decoded.
- EAN 13 barcodes return only 12 digits:
The first digit in an EAN 13 barcode is not
actually encoded in the barcode. This first digit is produced based on
a pattern of the next five digits. To enable this functionality set the
ExpandToEAN13 property to true and the first digit will be present in
the decoded string.
- A leading zero is added to the decoded data
of UPC-A barcodes:
This is a similar problem to the one above. If the
ExpandToEAN13 property is set to true, all UPC-A barcodes will contain
a leading zero because of the pattern contained in the first five
digits. To disable, set the ExpandToEAN13 property to false and the
leading zero will be truncated.
- Barcode is not being recognized in a
document:
Too much text in the document containing the barcode can cause this
behavior. Refer to the source
code example to pass a partial image into the ReadBarcode
method of the BarcodeDecoder class.
© Copyright 2008
IDAutomation.com, Inc., All Rights Reserved. Legal
Notices.
|
Over 70% of Fortune 100 companies use
IDAutomation's products to automate their businesses.
|
|