find_1d_bar_code_scanline ( Image : CodeRegion : BarCodeDescr, GenericName, GenericValue, StopIfFound : BarcodeFound, BarCodeElements, Orientation, ScanlineNumPoints, ScanlineDecoded, ScanlinePointsRow, ScanlinePointsColumn )

Look for one bar code in an image.

Like find_1d_bar_code, find_1d_bar_code_scanline looks for a bar code in an image. but find_1d_bar_code_scanline also returns information about the used scanlines.

Each scanline is represented by a set of points. The row- an column- coordinates of these points are returned in ScanlinePointsRow and in ScanlinePointsColumn, respectively. Note that these output parameters are tuples; they contain the points of all scanlines. To enable to access the points of a specific scanline, the number of points for each scanline is returned in the tuple ScanlineNumPoints. The tuple ScanlineDecoded indicates for each scanline whether the bar code code be decoded with it. 0 is returned if the bar code couldn't be decoded with that scanline, else 1 or 2, depending on which method has been used to detect the edges. In general, 1 is returned, for thin lines 2. If StopIfFound = true, the operator is left as soon as the bar code could be decoded, else all scanlines are checked.

For a description of the other parameters see find_1d_bar_code.


Parameters

Image (input_object)
image -> object : byte / uint2
Image with bar code inside.

CodeRegion (output_object)
region -> object
Region of bar code.

BarCodeDescr (input_control)
barcode_1d-array -> string / integer / real
Description of a bar code class.

GenericName (input_control)
string(-array) -> string
Names of optional control parameters.
Default value: '[]'
List of values: 'amplitude_sobel', 'min_size_element', 'max_size_element', 'angle_range', 'correct_angle', 'dilation_factor', 'sum_angles', 'sigma_project', 'amplitude_project', 'width_project', 'add_length_project', 'interpolation_project', 'num_scanlines', 'max_extra_elements'

GenericValue (input_control)
number(-array) -> real / integer
Values of optional control parameters.
Default value: '[]'

StopIfFound (input_control)
string -> string
Leave operator as soon as the bar code has been decoded?.
Default value: 'false'
List of values: 'true', 'false'

BarcodeFound (output_control)
integer -> integer
Information whether the bar code was found.
List of values: 0, 1

BarCodeElements (output_control)
number-array -> real
Widths of elements.

Orientation (output_control)
angle.rad -> real
Orientation of bar code.

ScanlineNumPoints (output_control)
number(-array) -> integer
Number of points belonging to that scanline.

ScanlineDecoded (output_control)
integer(-array) -> integer
Information whether the bar code could be decoded with that scanline.
List of values: 0, 1, 2

ScanlinePointsRow (output_control)
real(-array) -> real
Row - coordinates of the the points of the scanline.

ScanlinePointsColumn (output_control)
real(-array) -> real
Column - coordinates of the the points of the scanline.


Example (Syntax: C++)
HTuple   empty;   // empty list of values
HTuple   BarCodeDescr;
HTuple   BarcodeFound,Elements,Orientation;
HTuple   Characters,Reference,IsCorrect;
Hobject  Image,CodeRegion;
HTuple   ScanlineNumPoints, ScanlineDecoded, ScanlinePointsRow, 
         ScanlinePointsColumn;
HTuple   NumScanlines, NumPoints;
HTuple   j, k, indexPoint, nStart, nEnd;
HTuple   WindowHandle;  

gen_1d_bar_code_descr("EAN 13",13,13,&BarCodeDescr);
find_1d_bar_code_scanline(Image,&CodeRegion,BarCodeDescr,empty,empty,
                 "false",&BarcodeFound,&Elements,&Orientation,
                 &ScanlineNumPoints,&ScanlineDecoded,
                 &ScanlinePointsRow,&ScanlinePointsColumn);
set_window_attr("background_color",HTuple("black"));
open_window(HTuple(0),HTuple(0),HTuple(512),HTuple(512),0,"","",
            &WindowHandle);

if (BarcodeFound[0].l)
{
  decode_1d_bar_code(Elements,BarCodeDescr,
                     &Characters,&Reference,&IsCorrect);
  if (IsCorrect[0].l)
    for (int i=0; i<Characters.Num(); i++)
    {
      char *value = Characters[i];
    }
  // display scanlines
  NumScanlines = ScanlineNum.Num();
  indexPoint = HTuple(0);
  for (j=0; j<=NumScanlines-1; j+=1)
  {
    if (HTuple(ScanlineDecoded[(long)(j)[0]])==1)
    {
      set_color(WindowHandle,HTuple("green"));
    }
    else
    {
      set_color(WindowHandle,HTuple("red"));
    }
    NumPoints = HTuple(ScanlineNumPoints[(long)(j)[0]]);
    nStart = indexPoint;
    nEnd = (indexPoint+NumPoints)-1;
    for (k=nStart; k<=nEnd; k+=1)
    {
      disp_circle(WindowHandle,HTuple(ScanlinePointsRow[(long)(k)[0]]),
      HTuple(ScanlinePointsColumn[(long)(k)[0]]),HTuple(1));
    }
    indexPoint = nEnd+1;
  }
}

Result

The operator find_1d_bar_code returns the value 2 (H_MSG_TRUE) if the parameters are correct.


Parallelization Information

find_1d_bar_code_scanline is reentrant and processed without parallelization.


Possible Predecessors

gen_1d_bar_code_descr, gen_1d_bar_code_descr_gen


Possible Successors

decode_1d_bar_code, discrete_1d_bar_code


Alternatives

find_1d_bar_code_region


See also

sobel_dir, gray_projections, gen_measure_rectangle2


Module

Bar Code



Copyright © 1996-2008 MVTec Software GmbH