Collapse
CollapsingX
  • - or -

Procedure for using the CodeReader step


The CodeReader step allows you to read several types of 1D, 2D, and composite codes. To read a code, follow the steps below:

  1. Select the code type to be read and determine if the code type supports GS1.

  2. Optionally, modify the expected angle range.

  3. Optionally, modify the threshold setting with regards to lighting.

  4. Optionally, modify the distortion correction method.

  5. Optionally, specify a search region.

  6. Optionally, fine-tune your read.

  7. Optionally, specify input code type specific information.

If you are having difficulties reading a code after following these steps, see the points listed in the Hints subsection of this section.

Select the code type to be read

To select a Code type to be read, do the following:

  1. Run the project to the CodeReader step.

  2. In the Configuration pane, choose the code type to read by clicking on View All CodeTypes... and selecting the image of the code type, or choose the appropriate code type from the dropdown list. Matrox Design Assistant supports 1D (including EAN/UPC), 2D, and composite code types.

  3. Specify the Foreground color of the code to be read in the Configuration pane.

To help achieve a successful code read, make sure that the thinnest bar or cell in the code is at least 2 pixels wide.

Code types that support GS1

GS1 is a metadata bar code industry standard. If you read a string with GS1 information, you can specify the format in which the decoded string is returned. There are 3 options for the String format:

  • The GS1RawData string format has separator characters that can be read by a hex reader or scanner, but might not be printable.

    • Example string: รจ010123456789012815051231.

  • The GS1HumanReadable string format has GS1 application identifiers, or separator strings, in parentheses.

    • The application identifier is one or more prefix characters that precede a data field and give meaning to the encoded data. For example, the application identifier can specify a YYMMDD format for the expiry date.

    • Example string: (01)01234567890128(15)051231.

  • Auto, which is the default String format, does not add parentheses around the application identifiers.

    • Example string: 010123456789012815051231.

Modify the expected angle range

By default, the CodeReader step searches over a range of +- 180 degrees. If necessary, you can restrict the range.

Modify the threshold setting with regards to lighting

During a read operation, the Threshold Mode is used to binarize the entire image, separating the code from the background. By default, the Threshold Mode is set to Adaptive. If a different thresholding value would result in a better separation (and therefore in a more efficient operation), you can change the Threshold Mode to GlobalSegmentation, GlobalWithLocalResegmentation, or you can link a value.

To specify a Threshold setting, do the following:

  1. In the Configuration pane, you can set the Threshold Mode. Setting the Threshold Mode to Adaptive computes a threshold value for each pixel based on the range of intensity values in its neighborhood. Adaptive is best suited for codes with non-uniform lighting.

    Setting the Threshold Mode to GlobalSegmentation sets a global threshold value. Setting the Threshold Mode to GlobalWithLocalResegmentation specifies that the source image will be globally thresholded, and then the edges in the image will be resegmented based on the intensities of the surrounding bars and spaces in the original image.

  2. If you are reading 1D codes and the Threshold Mode is set to Adaptive, you can specify the Minimum contrast (the default is 50) between the foreground and background. Valid values for the minimum contrast are between 1 and 255.

  3. If the Threshold Mode is set to either GlobalSegmentation or GlobalWithLocalResegmentation, the ImageThresholdValue can be set. The default value is set to Auto, in which case Matrox Design Assistant automatically selects a threshold value to use.

Modify the distortion correction method

If an Aztec, Data Matrix, or QR code is distorted, it might not be read during a read operation. In this case, you can apply a distortion compensation algorithm that increases the robustness of the read operation. There are 2 different options for the Distortion correction property that you can use, depending on the code type and the type of distortion present in your image.

If the code has different column widths or row heights, you can select the UnevenGrid option. This option is the default for Aztec and QR code. It can also work in the presence of small perspective distortion.

For a Data Matrix code with large perspective distortion, the default setting is Perspective. This option can compensate for codes that are skewed though maintain parallelism and those that are skewed beyond parallelism.

Specify the search region

It might be necessary to specify the Search Region if there are multiple codes of the same type in the image, or if there is a lot of interference from objects in the background.

To set the search region interactively, select the CodeReader step in the flowchart and use the Define a region () toolbar button in the Project toolbar. See the Search regions section in Chapter 2: Building a project for more information.

When specifying the search region, it is important to leave a quiet zone around the code. The quiet zone is an area around the code with no markings in it. For 1D codes, the quiet zone immediately precedes the start character and immediately follows the stop character, whereas for 2D codes, the quiet zone must be present on all 4 sides of the code. The quiet zone must be large enough to meet the code type specifications; for example, the Data Matrix code type requires that the quiet zone be at least 1 cell wide, while 1D code types require a quiet zone of 2 to 10 times the width of the thinnest bar, depending on the type.

If you are reading Data Matrix codes, it is preferable to enable Presearch instead of specifying a search region. The presearch operation allows Matrox Design Assistant to locate 2D codes in the image prior to the read operation.

If the search region is too small and the quiet zone is not sufficient, or if there are markings in the quiet zone, you can set CheckQuietZone to Disable to help achieve a successful code read.

Fine-tuning your read

To improve your read, provide the CodeReader step with additional specifications.

If you are reading 1D codes:

  • You can adjust ScanlineHeight and ScanlineStep properties to manually control the sampling of a 1D code. The scanline height is the thickness of the scanline across which the code information is read. Increasing this value will lead to a slower but more accurate code read. The scanline step is the gap between scanlines; increasing the scanline step will lead to a faster code read.

  • You can adjust the Speed property to control the speed of the scan. The scanline height and the scanline step will be internally adjusted according to the change in speed. If you are having problems finding the code, you might want to search at a speed lower than the default.

If you are reading 2D codes:

  1. Click on the Target Grid... button. The TargetGrid tab is presented.

  2. To increase the robustness of your read, set NumberOfCellsX and NumberOfCellsY to appropriate values.

  3. If you are reading Data Matrix or Maxicode types, you can set the values of MinimumCellSize and MaximumCellSize to make the operation more robust.

  4. If the cells are dots (dot peen) instead of squares, set DotSpacing to half the distance, in pixels, between dot edges.

    If the dots overlap and/or when the dots have extended into the surrounding spaces, you can set a negative dot spacing. For example, in the image below, since the dots are too close together, specifying a negative dot spacing will shrink the dots, which might result in better results. The image on the right shows how Matrox Design Assistant interprets the image after applying negative dot spacing.

In certain cases, a read might take longer than expected. If this happens, you can set the Timeout property to a maximum time for the read operation. By default, the Timeout value is set to 2000 milliseconds.

If the edges of the cells or bars are fuzzy and you cannot improve the focus, try using an image processing filter such as sharpen, sharpen 2, Deriche sharpen, or Shen sharpen. For more information on image processing filters, see the Filtering subsection of the ImageProcessing step operations section in Chapter 9: ImageProcessing step.

Code type specific information

To increase the chances of a successful read, you can provide additional information for certain code types. The following table contains code type specific information. If you are using a composite code type, make sure to specify the 1D Encoding; the 2D Encoding type will always be PDF417.

Code Type

Specification

BC412

Specify the expected string size.

Code 39

Specify the encoding type and error correction type. Possible encoding types are Standard or ASCII. The error correction type should be specified as CheckDigit or None in the Properties pane.

Code 93

Specify the encoding type which can be Standard or ASCII.

Interleaved 2/5 (ITF-14)

Specify whether or not the CheckDigit error correction code has been used.

PDF417

If you decide to specify the number of cells, make sure to note that the number of cells in the X-direction must equal 17 c + 35, where c is the number of columns and 35 represents the number of cells required for the start and stop patterns.

Planet

If you specify the string size, note that it must be an 11 or 13-digit string. The specified string size should not include the check digit.

Postnet

If you specify the string size, note that it must be a 5, 9, or 11-digit string. The specified string size should not include the check digit.

Hints

The following points should be considered to achieve a successful code read:

  • The thinnest bar or cell in the code should be at least 2 pixels wide.

  • If the edges of the cells or bars are fuzzy and you cannot improve the focus, try using an image processing filter such as sharpen, sharpen 2, Deriche sharpen or Shen sharpen.

  • If the search region is too small and the quiet zone is not sufficient or there are markings in the quiet zone, you can set CheckQuietZone to Disable.

Initialization mode

When you add a CodeReader step, the InitializationMode property is set to ImprovedRecognition (default). This configures the step for robust read operations.

In rare cases, such as when reading Pharmacode symbols, you might need to change the initialization mode to TypicalRecognition. This configures the step for faster but less robust read operations.

Changing the initialization mode resets all related settings.

Results

The most commonly accessed results are Decoded String and Status. To fine-tune the read operation, the Number of cells and Cell size results can also be useful.

The CodeReader position result can be used as a Fixture provider. For 2D codes, the position is the center of the first corner cell. For 1D codes, the position will be somewhere along the first bar. If it is necessary to force the position to the top of the first bar, you can set the PositionAccuracy to High in the Properties pane.

In the Quick Watch flyout panel, the Angle, DecodedString, Position, and Status results are displayed by default.

In the Annotations control panel, the Search region, Decoded string, Position, Box, and Output coordinates are selected for display by default. You can click on the filter button to show the advanced annotations Code, Quiet Zone, and Absolute coordinates. For more information on annotations, see the Displays section in Chapter 50: Customizing the operator view.