IMAQ Read QR Code VI

LabView NI Vision

IMAQ Read QR Code VI

Owning Palette: Instrument ReadersInstalled With: NI Vision Development Module

Locates and then reads the value encoded in a QR code. You can compare the decoded data to a reference string or check whether the data contains a specific pattern. Many of the options of this VI allow for automatic detection of QR code properties or determine which methods the VI should use to locate and decode the QR code. Selecting specific properties and methods for these options will greatly increase the performance of the VI.

Examples

IMAQ Read QR Code

ccclst.gif

QR Search Options is a cluster that contains the search options to use when searching for QR codes in the image.

cenum.gif

Rotation Mode specifies the amount of QR code rotation the VI should allow for. The following values are valid:

Unlimited (0)

The VI allows for unlimited rotation

0 Degrees (1)

The VI allows for 0 degrees of rotation

90 Degrees (2)

The VI allows for 90 degrees of rotation

180 Degrees (3)

The VI allows for 180 degrees of rotation

270 Degrees (4)

The VI allows for 270 degrees of rotation

cbool.gif

Skip Location?, when TRUE, specifies that the VI should assume that the QR code occupies the entire image (or the entire search region). The VI skips the location phase and moves immediately to extracting and decoding the QR code. When FALSE, the VI does not make any assumptions about the percentage of the image occupied by the QR code. The default value is FALSE.

cu32.gif

Edge Threshold specifies the minimum contrast a pixel must have in order to be considered part of a matrix cell edge. The lower this value is set, the more potential edge candidates the VI will examine during the location phase. Setting this value too low will decrease the performance of the VI because the VI will examine too many potential edge candidates. Setting this value too high may also decrease the performance of the VI by removing valid edge candidates, making location more difficult. Setting this value too high may also cause the VI to fail to identify the matrix because all edge candidates are eliminated.

ci32.gif

Demodulation Mode specifies the mode the VI should use to demodulate (determine which cells are on and which cells are off) the QR code. The following values are valid:

Auto-detect (-2)

(Default) The VI tries each demodulation mode and use the one which decodes the QR code within the fewest iterations and utilizing the least amount of error correction.

Histogram  (0)

The VI uses a histogram of all of the matrix cells to calculate a threshold. This threshold determines if a cell is on or off. This is the fastest method, but it requires QR code images with consistent levels of contrast in the matrix.

Local Contrast (1)

The VI examines each of the cell's neighbors to determine if the cell is on or off. This method is slower, but works with QR code images that have inconsistent levels of contrast in the matrix.

Combination (2)

The VI uses the histogram of the matrix to calculate a threshold. For cells with pixel values that are sufficiently below or above this threshold, the VI will use the threshold to determine if the cell is on or off. If the cell pixel values are close to the threshold, the VI will use the Local Contrast method to determine if the cell is on or off. This method is slower, but works with QR code images that have extremely low cell fill percentages or gross print growth errors.

All (3)

The VI tries Histogram, Local Contrast, and Combination, stopping once one mode is successful.

ci32.gif

Cell Sample Size specifies the sample size, in pixels, the VI should take to determine if each cell is on or off.

Auto-detect (-2)

(Default) The VI will try each sample size and use the one which decodes the QR code within the fewest iterations and utilizing the least amount of error correction.

1×1 (1)

The VI will use a 1×1 sized sample from each cell.

2×2 (2)

The VI will use a 2×2 sized sample from each cell.

3×3 (3)

The VI will use a 3×3 sized sample from each cell.

4×4 (4)

The VI will use a 4×4 sized sample from each cell.

5×5 (5)

The VI will use a 5×5 sized sample from each cell.

6×6 (6)

The VI will use a 6×6 sized sample from each cell.

7×7 (7)

The VI will use a 7×7 sized sample from each cell.

ci32.gif

Cell Filter Mode specifies the mode the VI uses to determine the pixel value for each cell. Note that if Cell Sample Size is 1×1, the value of the single samples pixel always determines the pixel value for the cell. The following values are valid:

Auto-detect (-2)

The VI tries all filter modes and uses the one that decodes the QR code within the fewest iterations and utilizing the least amount of error correction.

Average (0)

The VI sets the pixel value for the cell to the average of the sampled pixels.

Median (1)

The VI sets the pixel value for the cell to the median of the sampled pixels.

Central Average (2)

The VI sets the pixel value for the cell to the average of the pixels in the center of the cell sample.

High Average (3)

The VI sets the pixel value for the cell to the average value of the half of the sampled pixels with the highest pixel values.

Low Average (4)

The VI sets the pixel value for the cell to the average value of the half of the sampled pixels with the lowest pixel values.

Very High Average (5)

The VI sets the pixel value for the cell to the average value of the ninth of the sampled pixels with the highest pixel values.

Very Low Average (6)

The VI sets the pixel value for the cell to the average value of the ninth of the sampled pixels with the lowest pixel values.

All Filters (8)

The VI tries each filter mode, starting with Average and ending with Very Low Average, stopping once a filter mode decodes correctly.

cu32.gif

Skew Degrees Allowed specifies the amount of skew in the code the VI should allow for. The default is 5 degrees.

cgenclasstagrefflat.gif

Image is a reference to the source image.

ccclst.gif

ROI Descriptor is a descriptor that defines the the rectangle, rotated rectangle, or polygon within which the QR code is located.

c1di32.gif

Global Rectangle contains the coordinates of the bounding rectangle.

c1dcclst.gif

Contours are each of the individual shapes that define an ROI.

cenum.gif

ID refers to whether the contour is the external or internal edge of an ROI.

cu32.gif

Type is the shape type of the contour.

c1di32.gif

Coordinates indicates the relative position of the contour.

cnclst.gif

QR Description Options is a cluster that contains the QR code description options to use when searching for QR codes in the image.

ci32.gif

Matrix Size (cells) specifies the size of QR code.

ci32.gif

Barcode Polarity specifies the data-to-background contrast for the QR code. The following values are valid:

Auto-detect (-2)

(Default) Sets the VI to determine the code polarity automatically.

Black On White (0)

Sets the VI to read codes with dark data on a bright background.

White On Black (1)

Sets the VI to read codes with bright data on a dark background.

ci32.gif

Mirror Mode specifies if the code appears normally in the image or if the code appears mirrored in the image. The following values are valid:

Auto-detect (-2)

(Default) Sets the VI to automatically determine if the code is mirrored.

Normal (0)

Sets the VI to read codes that appear normally in the image.

Mirrored (1)

Sets the VI to read codes that appear mirrored in the image.

ci32.gif

QR Model is the Model Type to look for. There are three major QR code models: QR Code Model 1, QR Code Model 2, and Micro QR Code. Micro QR Codes have only a single target in the top left, while Model 1 and Model 2 have targets in all corners except for the bottom right. Model 2 codes have alignment patterns inside the data. Model 1 codes have alignment patterns along the edges.

Auto Detect (0)

Automatically selects the QR model.

Micro (1)

Selects the Micro QR Code model.

Model 1 (2)

Selects the QR Code Model 1 model.

Model 2 (3)

Selects the QR Code Model 2 model.

cerrcodeclst.gif

error in (no error) describes the error status before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.

cbool.gif

status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.

ci32.gif

code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.

cstr.gif

source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.

cnclst.gif

QR Code Cell Size (pixels) is a cluster that contains the code size options to use when searching for codes in the image. The size refers to cell size in pixels.

cu32.gif

Minimum Size specifies the minimum size (in pixels) of a cell in the code.

cu32.gif

Maximum Size specifies the maximum size (in pixels) of a cell in the code.

igenclasstagrefflat.gif

Image (duplicate) is the reference to the image that contains the QR code.

icclst.gif

QR Code Report is a cluster that contains the QR code description options to use when searching for QR codes in the image.

ibool.gif

Found? returns TRUE if a QR code was found and decoded in the image. This parameter returns FALSE if the VI failed to locate and decode a QR barcode.

istr.gif

Data shows the encoded data in the code.

i1dnclst.gif

Bounding Box is an array that define the boundary of the QR code in the image.

iu32.gif

Errors Corrected specifies the number of rows in the QR code.

iu32.gif

Dimensions (Rows/Cols) specifies the number of rows and columns in the QR code. This is measured in cells. All QR codes are square by specification.

iu32.gif

Version specifies the version of the QR code. This is with respect to the model type.

ii32.gif

QR Model is the QR code model found.

ii32.gif

Stream Mode specifies the stream mode or the format of the data that is encoded in the QR code.

ii32.gif

Barcode Polarity indicates the data-to-background contrast for the QR code.

ibool.gif

Mirrored? indicates if the QR code appeared mirrored (TRUE) or normally (FALSE) in the image.

iu32.gif

Append Stream Position indicates what position the QR symbol is in with respect to the stream of data in all symbols. It is possible for a QR symbol to be part of a larger array of symbols.

iu32.gif

Size of Append Stream specifies how many QR symbols are part of a larger array of symbols. Sometimes a QR symbol is part of a larger array of symbols. This tells us how many symbols are involved in this array.

ii32.gif

First EAN-128 ID is the first EAN-128 Application ID encountered in the stream. This is only useful for EAN-128 codes. For mixed/appended EAN-128 codes, refer to the tokenized output.

ii32.gif

First Alternate Language ID is the first Regional Language Designator encountered in the stream. This is only useful for ECI codes and for multiple language ECI symbols, refer to the tokenized output.

iu32.gif

Append Stream ID specifies what stream this symbol is in relation to. Sometimes a QR symbol is part of a larger array of symbols. Stream ID can be useful when there are a number of QR streams and a symbol needs to be categorized.

iu32.gif

Minimum Edge Strength specifies the minimum contrast a pixel must have in order to be considered part of a matrix cell edge. The lower this value, the more potential edge candidates the VI will examine during the location phase. Setting this value too low will decrease the performance of the VI because the VI will examine too many potential edge candidates. Setting this value too high may also decrease the performance of the VI by removing valid edge candidates, making location more difficult. Setting this value too high may also cause the VI to fail to identify the matrix because all edge candidates are eliminated.

ii32.gif

Demodulation Mode specifies the mode the VI used to demodulate (determine which cells are on and which cells are off) the QR code.

ii32.gif

Cell Sample Size specifies the sample size, in pixels, the VI used to determine if each cell is on or off.

ii32.gif

Cell Filter Mode specifies the mode the VI used to determine the pixel value for each cell.

i1dcclst.gif

Tokenized Output Data contains the data tokenized in exactly the way it was encoded in the symbol. This is useful if the symbol is encoded using multiple languages. ModeData will contain the language identifier. This is also useful if the symbol contains multiple EAN-128 application IDs. ModeData will contain the Application Identifiers. Otherwise, the QR Code Report data should suffice.

ii32.gif

Stream Mode specifies the stream mode or the format of the data that is encoded in the QR code.

iu32.gif

Mode Data specifies Stream Mode specific data. This parameter uses the following mapping:

  • Numeric – Length of Data String
  • AlphaNumeric – Length of Data String
  • Raw-Byte – Length of Data String
  • UCC/EAN-128 In Tokens – Application ID for the length of the data token
  • UCC/EAN-128 In Data – Length of Data String
  • Extended Character Interpretation – Language Identifier for the length of the data token
  • Kanji –Length of Data String
istr.gif

Data shows the encoded data in the code.

ierrcodeclst.gif

error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out indicator on the front panel and select Explain Error from the shortcut menu for more information about the error.

ibool.gif

status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.

ii32.gif

code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.

istr.gif

source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.

Examples

Refer to the following for an example that uses this VI.

  • LabVIEW\examples\Vision\2. Functions\2D Barcodes\2D Barcode.llb