get_2d_bar_code_pos ( BarCodeRegion, Image : : BarCodeDescr, CodeRegDescr, GenParamNames, GenParamValues : BarCodeDimension, BarCodeData, DataElementRow, DataElementCol )

Extract the data values of the elements (in ECC 200: ``modules'') inside a bar code region (``Data Matrix symbol'') and their positions in the image.

get_2d_bar_code_pos extracts the 2D bar code data from a candidate symbol region given in BarCodeRegion and the corresponding image given in Image elements. In contrast to get_2d_bar_code, this operator also returns the positions of the data elements in the image in the parameters DataElementRow and DataElementCol. This can be used to check the result of the operator, e.g., by displaying the data in the real image. For a description of the other parameters, see get_2d_bar_code.


Attention

The operator get_2d_bar_code_pos returns error codes to signal that the candidate region did not contain a valid 2D bar code. As the region candidates extracted by the operator find_2d_bar_code can perfectly well encompass regions without a bar code, every call to get_2d_bar_code_pos should be surrounded by error handling code (see example).


Parameters

BarCodeRegion (input_object)
region -> object
Region that might contain a bar code.

Image (input_object)
image -> object : byte
Corresponding image.

BarCodeDescr (input_control)
barcode_2d-array -> string / integer / real
Description of the 2D bar code class.

CodeRegDescr (input_control)
string-array -> string / integer / real
Additional parameters describing the bar code region. They can be used for extracting the data.

GenParamNames (input_control)
string-array -> string
List of names of (optional) generic control parameters.
Default value: '[]'
List of values: 'module_rad_ratio', 'use_grayvals', 'use_grayval_min', 'use_grayval_max', 'use_grayval_range', 'enlarge_region_rad', 'thresh_percent', 'thresh_step_width', 'smooth_cont', 'max_line_dist1', 'max_line_dist2', 'min_cont_len', 'border_width_min', 'border_width_max', 'border_width', 'median_mask_rad', 'gray_erosion_size', 'measure_sigma', 'measure_thresh'

GenParamValues (input_control)
number-array -> real / integer
List of values of the generic parameters.
Default value: '[]'
Suggested values: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 'yes', 'no', -1, 1.5, 2.5, 3.5, 4.5, 5.5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50

BarCodeDimension (output_control)
integer-array -> integer
Tuple with the dimension of the extracted symbol. In the case of ECC 200: data field width, height, symbol index.

BarCodeData (output_control)
integer-array -> integer
Tuple with the data values of the extracted symbol. value > 0: logical 1, value < 0: logical 0, value = 0: module could not be classified.

DataElementRow (output_control)
real-array -> real
Tuple with the row positions of the data elements of the extracted symbol in the image.

DataElementCol (output_control)
real-array -> real
Tuple with the column positions of the data elements of the extracted symbol in the image.


Example
dev_set_check ('~give_error')
get_2d_bar_code_pos (ObjectSelected, Image, BarCodeDescr,
                     CodeRegDescr, [], [], BarCodeDimension, BarCodeData,
                     DataElementRow, DataElementCol)
err := ErrorCode
dev_set_check ('give_error')
if (err = 2)
  idx := 0
  dev_update_pc ('off')
  dev_update_time ('off')
  dev_update_var ('off')
  for m := 0 to BarCodeDimension[0]-1 by 1
    for n := 0 to BarCodeDimension[1]-1 by 1
      if (BarCodeData[idx]>0)
        set_color (WindowHandle, 'green')
      else
        if (BarCodeData[idx]<0)
          set_color (WindowHandle, 'red')
        else
          set_color (WindowHandle, 'blue')
        endif
      endif
      disp_circle (WindowHandle, DataElementRow[idx], 
                   DataElementCol[idx], 1)
      idx := idx+1
    endfor
  endfor
  dev_update_pc ('on')
  dev_update_time ('on')
  dev_update_var ('on')
  decode_2d_bar_code (BarCodeDescr, BarCodeDimension, BarCodeData,
                      SymbolCharacters, CorrSymbolData, DecodedData,
                      DecodingError, StructuredAppend)
endif

Result

The return value can signal incorrect parameters as well as the failure to extract a 2D bar code. Such a failure can be due to different causes: If no surrounding rectangle was found, the operator returns the error code 8808. Error code 8807 signals that the rectangle does not lie completely inside the image. If no finder pattern was detected inside the border search area, the error code 8810 is returned. If the two continuous lines forming the 'L' of the finder pattern could not be found, the error code 8809 is returned. In the case of the printing method 'engraved_darkfield', the error code 8811 signals that none of the gray value features can separate the test regions, i.e., that modules cannot be classified.


Parallelization Information

get_2d_bar_code_pos is reentrant and processed without parallelization.


Possible Predecessors

find_2d_bar_code


Possible Successors

decode_2d_bar_code


Alternatives

get_2d_bar_code


See also

gen_2d_bar_code_descr


Module

Data Code



Copyright © 1996-2008 MVTec Software GmbH