GetBarcodeBP (deprecated)
Recognizes arbitrary 1D or 2D codes. This action has been deprecated and is scheduled to be removed in a future release.
Member of namespace
Barcode_PSyntax
bool GetBarcodeBP()Parameters
None.Returns
True, if the action is called at the page level or field level. Otherwise, False.In addition, the calling object's value and variable GetBarCode is filled with the barcode value. This action also stores barcode information such as confidence, coordinates, code name, and size. If the object's barcode settings are set to read more than one barcode, and more than one barcode is found, barcodes are also stored in the variable GetBarCodeX where X is the index of the barcode found.
Level
Page or Field level only.Details
Use this action if your page has 1D or 2D barcodes. Any field must have a Position assigned when barcode reading is performed. For example, the application would invoke the CreateFields action, and if the field has Position defined in the Document Hierarchy and the zones are loaded, it is ready for field level barcode reading. If anchors or fingerprint matching are used, ReadZones or other registration may be required to align the fields correctly to the fingerprint template zones.Setting the expected barcode type
By default, the barcode engine considers the barcode type to be unknown and attempts to detect the barcode. The barcode type must be set when detecting PatchCode and PDF417 barcodes. For other barcode formats, it still may be necessary to set the expected barcode type for the engine to find and recognize the barcode. If a barcode is not being detected, set the proper barcode type to aid the barcode detection.
The expected barcode types can be easily set using the "BAR/P" tab property within the "Zones" tab of Datacap Studio. This property can be set by selecting the target DCO node page or field, locking the DCO and selecting the expected barcode types. This automatically calculates the correct value based on all of the selected types and sets the bp_tp variable for your application in the Setup DCO. For best results, keep the expected types to a minimum. When you use this property approach to setting the expected barcode type, it is not necessary to separately set thebp_tp variable.
Alternatively, the expected barcode type can be set at runtime on the target field/page being recognized by setting the variable bp_tp. If the "bp_tp" variable is empty or does not exist, the engine defaults to "Unknown".
The bp_tp variable sets the expected barcode type, or types, which provides better recognition results. If multiple barcode types are expected, the value of this variable must be a combination of the barcode types shown below. Multiple types can be read by adding the values of their codes together. Always set the expected type to the minimum possible types. This variable can be set using rrSet prior to calling a barcode recognition action. For example: rrSet("256","@X.bp_tp") for reading a Code 39 barcode.
When the barcode type is set to Patch Code, the following string values may be returned by the engine. The string value depends on the type of Patch Code that is found:
- Patch 1 - 1100
- Patch 2 - 1001
- Patch 3 - 1010
- Patch 4 / Toggle Patch - 0110
- Patch 6 - 0011
- Patch T / Transfer patch - 0101
- Valid barcode types
-
- 0 - Unknown. Detects all barcode types automatically, except for PatchCode and PDF417. The PatchCode and PDF417 barcode types must be set explicitly to be detected.
- 1 - INDUSTRY 2 OF 5
- 2 - INTERLEAVED 2 OF 5
- 4 - IATA 2 OF 5
- 8 - DATALOGIC 2 OF 5
- 16 - INVERT 2 OF 5
- 32 - BCD MATRIX
- 64 - MATRIX 2 OF 5
- 128 - CODE 32
- 256 - CODE 39
- 512 - CODABAR 2
- 1024 - CODE 93
- 2048 - CODE 128
- 4096 - EAN-13
- 8192 - EAN-8
- 16384 - UPC-A
- 32768 - UPC-E
- 65536 - ADD 5
- 131072 - ADD 2
- 262144 - UCC128/EAN-128
- 524288 - Patch Code
- 1048576 - PostNet
- 2097152 - PDF417
- 4194304 - DataMatrix
- 8388608 - Code 39 Extended
- 16777216 - Code 93 Extended
- 33554432 - QRCode
- 67108864 - IntelligentMail
- 134217728 - Royal Mail (RM4SCC)
- 268435456 - Australian Post 4-State Code
- 536870912 - Aztec
- 1073741824 - GS1DataBar
- Variable Length Royal Mail Barcodes
-
The Royal Mail barcode is a fixed length barcode. Some countries use a variable length variation of the Royal Mail barcode, such as the Postal Services of Portugal. To allow reading of a variable length Royal Mail barcode for Portuguese CTT, in addition to selecting the Royal Mail barcode type, the variable length setting must be enabled. Setting the DCO variable "RoyalMailVariableLength" to "1" will allow detection of variable length Royal Mail barcodes. It is allowed to enable variable length for fixed length Royal Mail barcodes, if the length restriction does not need to be enforced.
This example sets the barcode type to variable length Royal Mail:
rrSet("1", "@P.RoyalMailVariableLength") rrSet("134217728", "@P.bp_tp") GetBarcodeBP()
- Minimum and Maximum Settings
- Multiple barcodes can exist and be recognized on a single page. The DCO variable
bp_su controls the maximum number of barcodes attempts to be read on a single
page. If not specified, the default maximum is 10.
The minimum number of expected barcodes can be specified by using the DCO variable bp_minExpected. This setting controls when image enhancement takes place. Unless specified, the minimum expected barcodes will default to the same value as the maximum number of barcodes setting.
Barcode detection steps
The barcode actions detect barcode using the following steps.
- Recognize barcodes on the page / field.
- Stop if minimum expected is detected.
- If minimum not reached and image enhancement is enabled then
-
- Use each of the enabled image enhancement features and read the barcode.
- Stop if minimum expected is detected.
- Continue performing each enabled image enhancement feature to detect the minimum expected barcodes.
If the number of recognized barcodes is equal to or more than the specified minimum, image enhancement is skipped. If the minimum number of barcodes is not reached, and if image enhancement is enabled, then barcode recognition is performed a second time. The recognition uses the configured type of image enhancement in an attempt to read the barcode.
For example, if the configured minimum barcode is 1 and the maximum is 10, first barcode recognition is performed without any image enhancement and attempt to read up to 10 barcodes. If at least one barcode is read, the action completes. If 0 barcodes are read, the action performs the specified image enhancement and attempts again to recognize the barcodes on the page. If 0 barcodes are read and no image enhancement is configured, the action completes without a second attempt at recognition.
Another example is, if two barcodes are expected with the minimum set to 2. If 2 or more barcodes are read, then recognition stops. If less than two are read and if image enhancement is enabled, the barcode action performs the configured image enhancement type and attempt to read the barcode again. It performs this for each type of enabled image enhancement.
- Image Enhancement
- Image enhancement might be necessary in order to help read damaged or poorly scanned barcodes.
Depending on the problem with the barcode, different types of enhancements might make the barcode
readable. The barcode_p actions offer a way to enhance the image before it reads the barcode. To
enable this feature, set the variable bp_enhance to "1". When set to "1", the
engine will first try to recognize the barcode without image enhancement.
If the minimum number of barcodes has not been read, then the action tries again using the specified image enhancement. If the minimum number of barcodes has been read, then the image enhancement is skipped. If your barcode images are such that they always require image enhancement, setbp_enhance to "2", which skips the first recognition step that attempts to recognize without image enhancement.
Enabling image enhancement for barcodes only alters the image during barcode recognition, the original image in the batch is left unchanged.
The image enhancements are not cumulative, enable only one type of image enhancement that is needed.
Image enhancement types
- Smooth Zoom bp_zoom - Scales the image larger to help improve recognition for small barcodes.
- Blur bp_blur - Blurs the image, which can help jagged lines.
- Dilate bp_dilate - Expands the pixels, which make the lines thicker.
- Erode bp_erode - Removes pixels along line edges.
- Flip bp_flip - It is usually not necessary to flip the image for an upside-down barcode to recognize.
- Resize bp_resize - Enlarges the image, which can help small barcodes.
- Binarize: bp_binarize - Converts 24 and 8 bit images to 1 bit. A 1 bit image can improve recognition for barcodes where the contrast between the barcode lines and the background is low or when there is light shading preventing recognition.
Enabling image enhancement
To activate automatic image enhancement, set the DCO variable bp_enhance to "1" prior to calling a barcode action on the DCO page or field node that will be recognized.
For example: rrSet("1","@X.bp_enhance")
Each specific image enhancement can be enabled by setting the associated DCO variable to "1" or disabled by setting it to "0". By default, "Smooth Zoom" is always enabled and all other image enhancements are disabled.
For example, if "Smooth Zoom" is the desired enhancement, simply enabling image enhancement by setting bp_enhance to "1" enables image enhancement for Smooth Zoom.
If only Binarize is required, then this sequence prior to calling a barcode action enables only the Binarize feature.
rrSet("1","@X.bp_enhance")
rrSet("0","@X.bp_zoom")
rrSet("1","@X.bp_binarize")
Enabling multiple enhancements
Multiple enhancements can be enabled if you find that you consistently receive documents that require different types of enhancements. For example, some documents always work the first time, other documents only detect if binarize is used and others work only if blur is used. If multiple enhancements are enabled, the action attempts to recognize using each of the enabled enhancement types until the minimum expected have been read.
For example, to always use Binarize and Blur to recognize the barcode, set the following prior to recognizing the barcode:
rrSet("1","@X.bp_enhance")
rrSet("0","@X.bp_zoom")
rrSet("1","@X.bp_binarize")
rrSet("1","@X.bp_blur")
The action then uses the blur and binarize enhancements until the minimum number is read. If bp_enhance is set to "1" the action always tries to recognize without any enhancements, and continues only if the minimum is not reached. Each additional enhancement type enabled will be attempted until the minimum are read or all enabled enhancements have been attempted.
For best performance, always set the minimum number of barcodes expected or the action may perform unnecessary enhancements.
The order in which the enhancements are attempted by the barcode action cannot be controlled.
- Barcode orientation
- Barcode orientation defaults to both horizontal and vertical. Specifying the orientation might
help in detection of barcodes. If necessary, the orientation can be configured by setting the DCO
variable bp_or.
0 = Horizontal and Vertical.
1 = Horizontal.
2 = Vertical.
3 = Horizontal, Vertical, and Diagonal.
- Barcode byte mode
-
Some specific barcode types, such as PDF-417, allow null characters within the data stream. If this occurs, the full length of the barcode can be truncated returning only the characters up to the first null character. This is typically observable by noting that the read barcode is shorter than expected. For example, if the barcode should be a 40 character ID but it returns truncated text.
To treat a barcode as byte data, set the DCO variable BarcodeUseByte to "1". This setting treats the stream as bytes and also converts any null characters to spaces so the entire string can then be utilized in other parts of the application.
When in byte mode, the default replacement character of a space can be set to a different replacement character by setting the DCO variable BarcodeReplacementChar to the desired replacement character.
Note: Unicode characters are not supported by the byte mode.
- Example 1
-
rrSet("1", "@X.bp_minExpected") rrSet("33554432", "@X.bp_tp") GetBarcodeBP()
This example configures the reader to expect 1 barcode on the page and sets the barcode type in rules prior to calling the barcode action.
- Example 2
-
rrSet("1", "@X.bp_minExpected") rrSet("1","@X.bp_enhance") rrSet("0","@X.bp_zoom") rrSet("1","@X.bp_binarize") GetBarcodeBP()
This example assumes the barcode type has previously been configured in Datacap Studio. It also enables the binarize image enhancement to run, if no barcodes are found on the page.