Collapse
CollapsingX
  • - or -

CodeReader step overview


Using symbols (codes) from symbologies (code types) such as bar codes and Data Matrix codes can be useful for identifying products and storing information. The CodeReader step allows you to read a single code from an image and return a string with the decoded information.

The step supports 1D, 2D, and composite code types. One dimensional (1D) code types are linear bar codes and are used for small amounts of data, whereas 2-dimensional (2D) codes can store information in the horizontal and vertical direction, allowing them to contain more data. Composite codes are a combination of specific 1D and 2D code types.

Aside from supporting multiple code types, the CodeReader step allows you to read codes with a black or white foreground. The code is binarized before being read; therefore, unevenly lit images might result in erroneous reads. In this case, you can use adaptive thresholding to improve the reliability of the read.

If the code does not appear horizontally in the image, you can define an angle range in which to search for and read the code. Furthermore, when more than one code is present in the image, or if significant background noise is present, the CodeReader step allows you to define a search region around the appropriate code to read. In some cases, you can enable a presearch operation instead of defining a search region.

You can make the read operation more robust by providing the CodeReader step with additional specifications, such as the speed level for the read operation, the number of cells, and the cell size. In addition, depending on the type of code being read, you can improve your results by providing the step with information about the error correction code used, the expected string size, and the encoding type.

When is preprocessing required?

Fast reliable reading requires a clear difference between foreground and background elements.

2 common causes for poor differentiation between light and dark elements, especially in 1D codes, is poor or insufficient resolution. As shown in the image below, if a Line Profile graph across the code shows that the thin bars and thick bars do not reach the same level, you might need to apply a sharpening filter before the CodeReader step. The Deriche Sharpen works well in these cases.

If the image has clutter, using a Morphology tophat to extract dots and bright lines or a Morphology bottomhat for dark lines might improve reading.