Skip to main content

Configure Barcode Symbologies

Symbologies often have different properties, such as symbol count (length of the barcode) or inverted colors (printed white on black). To provide optimal performances, some properties/values are disabled by default in our SDK.

You might need to scan a symbology whose properties are by default disabled. This article explains you how to enable the specific properties and which one are available per symbology.

Setting Symbology Properties

You can set the properties of a symbology using the methods of the ScSymbologySettings class. You can get the symbology settings of Code128 as follows:

ScSymbologySettings *symbology_settings = sc_barcode_scanner_settings_get_symbology_settings(settings, SC_SYMBOLOGY_CODE128)

Some symbologies have optional checksums. A specific checksum method can be set in the following way:

sc_symbology_settings_set_checksums(symbology_settings, SC_CHECKSUM_MOD_10);

Symbologies may also have a certain length range configured by default. The length of a barcode can be checked using the "Any Code" mode of our demo app (Apple/Play Store). A new length range can be set by the dedicated symbol count method on the ScSymbologySettings class.

uint16_t symbol_counts[] = {
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
};
sc_symbology_settings_set_active_symbol_counts(symbology_settings, symbol_counts, sizeof(symbol_counts));

When working with symbologies printed white on black (default is black on white), you can set it using the dedicated inverted color method on the ScSymbologySettings class.

sc_symbology_settings_set_color_inverted_enabled(symbology_settings, SC_TRUE);

Symbologies may also have optional extensions/properties, as detailed in the next section. You can enforce these properties through a generic method on the ScSymbologySettings class.

sc_symbology_settings_set_extension_enabled(symbology_settings, "relaxed_sharp_quiet_zone_check", SC_TRUE);

Some symbologies support Optical Character Recognition (OCR) as a fallback when scanning fails. When the extension is enabled, an optional regular expression can be used to constrain results to a specific format, using the following method on the ScSymbologySettings class:

sc_symbology_settings_set_ocr_fallback_regex(symbology_settings, regex);

1D Symbology Properties

Keep the following in mind when configuring 1D symbologies:

  • All symbologies and all extensions are disabled by default when using the low-level API.
  • Color-inverted (bright bars on dark background) decoding for symbologies that support it is disabled and must be explicitly enabled.
  • Optional checksum digits (e.g. for interleaved 2 of 5 codes, or MSI-Plessey codes) are always returned as part of the data.
SymbologyMandatory ChecksumsSupported Optional
Checksums
Default Optional
Checksum
Default Symbol Count RangeSupported Symbol Count RangeColor-Inverted
Codes
ExtensionsGenerator Support
EAN-13 / UPC-Amod101212yesocr_fallback, remove_leading_upca_zero, strictyes
EAN-8mod1088yesstrictno
UPC-Emod1066yesreturn_as_upca, remove_leading_upca_zero, strictno
Two-Digit Add-onmod1022yesstrictno
Five-Digit Add-onmod1055yesstrictno
MSI Plesseynonemod10, mod11, mod1010, mod1110mod106-323-32nostrictno
Code 128mod1036-40 (includes 1 checksum and 2 guard symbols)4-50yesocr_fallback, strip_leading_fnc11, strictyes
Code 11nonemod11mod117-20 (includes 0-2 checksum digits)3-32nostrictno
Code 25nonemod107-203-32nostrictno
IATA 2 of 5nonemod10107-203-32nostrictno
Matrix 2 of 5nonemod107-203-32nostrictno
Code 32mod108 (plus one check digit)8nostrictno
Code 39nonemod436-40 (includes 2 guard symbols)3-50yesocr_fallback, full_ascii, relaxed_sharp_quiet_zone_check, strictyes
Code 93mod476-40 (includes 2 checksums and 2 guard symbols)5-60nofull_ascii2, strictno
Codabarnonemod16, mod117-20 (includes 2 guard symbols)3-34noocr_fallback, strict, remove_delimiter_datano
GS1 DataBar 14mod102 (encoding 14 digits)2nostrictno
GS1 DataBar Expandedmod2111-11 (encoding 1-74 characters)1-11nostrictno
GS1 DataBar Limitedmod891 (encoding 14 digits)1norelaxed_sharp_quiet_zone_check, strictno
Interleaved-Two-of-Five (ITF)nonemod106-404-50nostrictyes
Royal Mail 4-Statemod367-244-50nofluorescent_orange_inkno
KIXnone7-247-24nono
LAPAnone1616nono
USPS Intelligent Mailnone6565nono
UPU 4-Statenone19 or 2519 or 25nofluorescent_orange_ink, swiss_post_decodingno
Australian Post 4-Statenone10-41 (10 digits, 0-31 customer info characters)10-41noone of force_table_c, force_table_n, decode_bar_statesno
French Postnone--nofluorescent_orange_inkno

1: Enabled by default
2: Always enabled

2D Symbology Properties

Keep the following in mind when configuring 2D symbologies:

  • All symbologies and all extensions are disabled by default when using the low-level API.
  • Color-inverted decoding for symbologies that support it is disabled and must be explicitly enabled, except where mentioned.
SymbologyColor-Inverted
Codes
ExtensionsGenerator Support
ArUcoyesno
Aztec Codeyesyes
Data Matrixyesstrip_leading_fnc11, direct_part_marking_modeyes
DotCodeyesno
MaxiCodenono
MicroPDF417nono
PDF417nono
QR Codeyes1strictyes
Micro QR Codeyes1no

1: Enabled by default.

Symbology Extensions

Extension NameDescription
full_asciiInterprets the Code39 code data using two symbols per output character to encode all ASCII characters.
relaxed_sharp_quiet_zone_checkEnables scanning codes that have quiet zones (white area before and after the code) that are significantly smaller than allowed by the symbology specification. Use this extension if you are having difficulties to scan codes due to quiet zone violations. However, enabling it may come at the cost of more false positives under certain circumstances.
return_as_upcaTransforms the UPCE result into its EAN-13/UPC-A representation.
remove_leading_upca_zeroRemoves the leading zero digit from the result if the UPC-A representation extension 'return_as_upca' is enabled.
strip_leading_fnc1Removes the leading FNC1 character that indicates a GS1 code. To determine whether a certain code is a GS1 code, use sc_barcode_is_gs1_data_carrier.
direct_part_marking_modeUse this mode to improve scan performance when reading direct part marked (DPM) Data Matrix codes. Enabling this extension comes at the cost of increased frame processing times. It is recommended to restrict the scanning area to a smaller part of the image for best performance.
strictEnforce strict standard adherence to eliminate false positives in blurry, irregular or damaged barcodes at the cost of reduced scan performance.
fluorescent_orange_inkEnables the scanning of low contrast fluorescent orange codes. Enabling this option can have a negative impact on the scan performance of other symbologies.
force_table_c(For Australian Post 4-State) Forces decoding of Australian Post 4-State customer information with Table C.
force_table_n(For Australian Post 4-State) Forces decoding of Australian Post 4-State customer information with Table N.
decode_bar_states(For Australian Post 4-State) Returns the error-corrected customer information bars as a string of the bar states, A for ascending, D for descending, T for tracker and F for full.
swiss_post_decodingEnables scanning of proprietary Swiss Post UPU 4-State symbology.
remove_delimiter_dataRemoves start and stop patterns from the result of scanning a Codabar code.
ocr_fallbackEnables Optical Character Recognition of text as a fallback when other readers fail. For more details, refer to section "Using OCR Fallback Symbology Extension".

Using OCR Fallback Symbology Extension

When enabled, the OCR Fallback symbology extension performs text detection and recognition next to detected codes. This extension requires Smart Scan Intention which is only available in SparkScan or through the Linux settings preset SC_PRESET_SINGLE_CODE_HAND_HELD. It also requires the LabelText module.

OCR Fallback is triggered after 1 second of unsuccessful decoding while remaining stationary. The duration can be customized by setting the ocr_fallback_smart_stationary_timeout engine property with a value in milliseconds.

When the scanner is configured with multiple symbologies enabled with OCR Fallback, OCR is performed for each symbology in a hard-coded sequence. As soon as a result is detected that is valid for one symbology, OCR Fallback ends and the result is returned.

For some symbologies with overlapping character set and no checkum algorithms for the printed text label, this may cause unwanted results. For instance, a Code128 label may be misidentified as Code39, or vice-versa, depending on the order of execution. It is advised to configure different OCR regular expressions for each symbology when possible, so that codes are identified properly.

When no OCR regular expression is configured for Code128 or Code39, results returned by OCR Fallback may only contain alpha-numerical characters to reduce false-positives. Characters detected through OCR that are non-alpha-numerical are removed from results. To scan codes containing non-alpha-numerical characters, such as spaces or dashes, it is required to configure a regular expression that matches those characters.

Calculating Symbol Counts for Variable-Length Symbologies

The length of data encoded in variable-length symbologies such as Code 128, Codabar, Code 39 etc. is measured as the number of symbols. Depending on the symbology, the symbol count includes the start and end symbol, and/or checksum characters. The following list shows how to calculate the number of symbols for each variable-length symbology. These counts can be used as the input to sc_symbology_settings_set_active_symbol_counts.

Interleaved-Two-of-Five

The number of symbols corresponds to the number of digits in the code. Note that the number of digits must be even.

Example: the code “1234567890123” has a symbol count of 14. For the active symbol count calculation, optional checksum digits are treated like normal data symbols.

Codabar

The number of symbols corresponds to the number of digits in the code, plus the start and end symbols.

Example: the code “A2334253D” has a symbol count of 7 + 2 = 9.

Code 11

The number of symbols corresponds to the number of digits in the code, plus one or two checksum symbols. For less than ten digits in the code, one checksum symbol is added. Two checksum symbols are added for ten or more digits in the code.

Example: the code “912-34956” (“912-349566”) has a symbol count of 9 + 1 = 10. The code “912-3495-6” (“912-3495-638”) has a symbol count of 10 + 2 = 12.

Code 128

The number of symbols depends on the encoding used (A, B or C). All encodings require a start, an end and a checksum symbol. The ASCII encoding modes (A and B) store each character in one symbol.

Example: the code “ABC123” in mode A has a symbol count of 6 + 2 + 1 = 9.

The numeric encoding mode (C) encodes pairs of digits in one symbol.

Example: the code “123456” has a symbol count of 3 + 2 + 1 = 6.

Some encoders switch modes inside the code using switch symbols to optimize the code length. In this case the exact encoding used is needed to compute the number of symbols.

Code 93

The number of symbols corresponds to the number of characters in the code, plus the start and end symbols and 2 checksum digits. Shift characters used in “extended code93” are treated as normal data symbols.

Example: the code “ABCDE12345” has a symbol count of 10 + 2 + 2 = 14.

Code 39

The number of symbols corresponds to the number of characters in the code, plus the start and end symbols. Note that the start and end symbols are not included in the returned barcode data.

Example: the code “4F70050378196356D” (“*4F70050378196356D”) has a symbol count of 17 + 2 = 19.

MSI Plessey and Code 25

The number of symbols corresponds to the number of digits in the code.

Example: the code “12345674” has a symbol count of 8. For the active symbol count calculation, optional checksum digits are treated like normal data symbols.

GS1 DataBar 14

The symbol count corresponds to the number of finder patterns in the code. Each finder is accompanied by two data segments.

GS1 DataBar Expanded

The symbol count cannot be changed. All lengths defined by the standard are supported.

RM4SCC

The number of symbols corresponds to the number of characters in the code, including the checksum character.

KIX

The number of symbols corresponds to the number of characters in the code.

UPU 4-State

The number of symbols corresponds to the number of code words. Two lengths are supported, 19 or 25 codewords with a maximum number of error correcting codewords of 6 or 12 respectively.

Australian Post 4-State

The number of symbol corresponds to 10 digit FCC and DPID codes, and up to 31 characters representing the customer information bar states.