<a id="easybarcode"></a>

# EasyBarCode1 - Reading Bar Codes (deprecated)

#### WARNING
This library is deprecated, use [**EasyBarCode2**](easybarcode2.html.md) instead.

<a id="easybarcode-brc2"></a>

## Why use EasyBarCode2 Instead

Compared to **EasyBarCode**, **EasyBarCode2** has the following advantages:

* A faster and more reliable detection of bar codes.
* The ability to read multiple bar codes at once (with or without grid).
* The ability to use an [`ERegion`](../../../doxygen_cpp/classeVision_1_1ERegion.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ERegion.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ERegion.html) to restrict the search domain.
* The ability to set a timeout.
* A better support for many symbologies.
* A more flexible support of checksums.

The following examples illustrate bar codes read by **EasyBarCode2** that cannot be read by **EasyBarCode**.

![](assets/images/easybarcode/reading_1.webp)![](assets/images/easybarcode/reading_2.webp)![](assets/images/easybarcode/reading_3.webp)![](assets/images/easybarcode/reading_4.webp)

<a id="easybarcode-basics"></a>

## Basics

![Bar code](assets/images/easybarcode/barcodeean13.webp)

[EasyBarCode](../../../reference_manual/text_and_code_reading/easybarcode-library.html.md) can locate and read bar codes automatically.

Location can be performed manually for prototyping or when automatic mode results are unsatisfactory.

<a id="easybarcode-workflow"></a>

## Workflow

![](assets/images/easybarcode/easybarcodeworkflow.webp)

<a id="easybarcode-definition"></a>

## Bar code definition

A bar code is a 2D pattern of parallel bars and spaces of varying thicknesses that represents a character string. It is arranged according to an encoding convention (**symbology**) that specifies the character set and encoding rules.

* The bar code may be black ink on white background or inversely white ink on black background.
* The bar code should be preceded and followed by a quiet zone of at least ten times the module width (smallest bar or space thickness).
* Bars should be surrounded below and above by a quiet zone of a few pixels.
* Bars and spaces widths must be greater than or equal to 2 pixels.

<a id="easybarcode-symbologies"></a>

## Symbologies

A symbology defines the way a bar code is encoded.

Symbologies can be enabled with [`EBarCode::SetStandardSymbologies`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#a67651e9bf188d29ae82e794f00444892) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#aa47b754240739af1dbce40c38dc337d9) or [`EBarCode::SetAdditionalSymbologies`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#ae38c517fcb9e80b006f29ce5be93051e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#a4aa3c08b5e6ac9ceaf07091a98b7f950) parameters.

The standard symbologies are enabled by default:

* Code 39
* Code 128
* Code 2/5 5 Interleaved
* Codabar
* EAN 13
* EAN 128
* MSI
* UPC A
* UPC E

#### NOTE
EAN 13 and UPC A only differ by the layout of surrounding digits.

Additional symbologies that are supported:

* ADS Anker
* Binary code
* Code 11
* Code 13
* Code 32
* Code 39 Extended (a super-set of Code 39)
* Code 39 Reduced (a subset of Code 39)
* Code 93
* Code 93 Extended
* Code 412 SEMI
* Code 2/5 3 Bars Datalogic
* Code 2/5 3 Bars Matrix
* Code 2/5 5 Bars IATA
* Code 2/5 5 Bars Industry
* Code 2/5 5 Compressed
* Code 2/5 5 Inverted
* Code BCD Matrix
* Code C.I.P
* Code STK
* EAN 8
* IBM Delta Distance A
* Plessey
* Telepen

<a id="easybarcode-checksum"></a>

## Checksum

A checksum character enables the reader to check the bar code validity depending on the symbology:

* The checksum may be mandatory and must be checked by the reader.
* The checksum may be mandatory but may not need to be checked.
* The checksum and its verification may both be optional.

[`EBarCode::SetVerifyChecksum`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#a8c1d712a60f0add403ae26817a68325c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#a171dec8fab1b1eef82384367469789fe) enables or disables (default) checksum verification.

![image](assets/images/easybarcode/barcodestructure.webp)

<a id="easybarcode-read"></a>

## Read a Bar Code

The **Automatic** mode reading algorithm locates a bar code in the field of view and uses [`EBarCode::Read`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#aeca23f231474c538bad3b28e5a351239) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#a7842f920ae6c9dc151497e405627472b) to read it.

If several bar codes are present, only one is located, like a straightforward hand-held bar code reader.

Before reading, the decoding symbologies must be specified in the StandardSymbologies, or AdditionalSymbologies properties.

Mono-symbology mode reads the bar code using the expected symbology type(s) and reports the encoded information (if readable) or the reason for failure (if not readable). There is only one interpretation for the character string.

![image](assets/images/easybarcode/decodedbarcode.webp)

#### NOTE
When the bar code contains `\0x00` characters, the `std::string::c_str` method should not be used (since C-strings are terminated by the `\0x00` character). An iterator over the characters should be used instead of a C-string.

<a id="easybarcode-advanced"></a>

## Advanced Features

<a id="easybarcode-locate"></a>

### Locate and Read Bar Code Manually

If automatic localization fails or for prototyping purposes, the user can provide the **bar code position** and **reading area** to manually locate the code.

* **Bar code position** can be provided graphically by a bounding box around the bar code or by its parameters. If several symbols appear in the image, they can be processed one after the other.
* The **reading area** of the bar code is the area that is read. It should be wider than the bar code bounding box width, and less high than the bar code bounding box height. It may also be rotated relative to the bar code bounding box, to take into account slanting bars (Advanced mode!).

| ![image](assets/images/easybarcode/18060.gif)   | ![image](assets/images/easybarcode/18062.gif)   |
|-------------------------------------------------|-------------------------------------------------|

<a id="easybarcode-read-all"></a>

### Read all Interpretations (Multi-Symbology Mode)

Use [`EBarCode::Detect`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#aaf1a7e05ebb86632b81f544bfa247992) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#ae1d9a27f068d9c30ff2ce35e1ec213b5) to report the number of possible symbologies in the [`EBarCode::GetNumEnabledSymbologies`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#aced0827e0955683868dd40f980358875) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#abeff2844f95f81bbc4a1b7f032cf0e2d) property, and list the data contents by decreasing likeliness.

Then call the [`EBarCode::Decode`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#adeb56f5e7de99898dc475ed16d727792) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#a758a0a1eee676c2c1e778216ac5bdb29) method in a loop, using [`EBarCode::GetDecodedSymbology`](../../../doxygen_cpp/classeVision_1_1EBarCode.html#a2e099d24688dfb23398767d896cec6e1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBarCode.html#af798b5301c33a4c8f30bba59dd88bb90) to walk through the list of successful symbologies in decreasing order of likelihood.

<a id="easybarcode-quick-links"></a>

## Quick Links

List of all Classes, Structs and Enumerations of the **EasyBarCode** library.

Code snippets for the **EasyBarCode** library.
