decode_bar_code_rectangle2🔗
Short description🔗
decode_bar_code_rectangle2 — Decode bar code symbols within a rectangle.
Signature🔗
decode_bar_code_rectangle2( image Image, barcode BarCodeHandle, string CodeType, rectangle2.center.y Row, rectangle2.center.x Column, rectangle2.angle.rad Phi, rectangle2.hwidth Length1, rectangle2.hheight Length2, out string DecodedDataStrings )
Description🔗
The operator decode_bar_code_rectangle2 uses the bar code
model specified by BarCodeHandle to decode a bar code at
a given position within the image Image.
BarCodeHandle must be created with
create_bar_code_model, its parameters can be set with
set_bar_code_param. The position of the bar code is given
as an arbitrarily oriented rectangle. Contrary to
find_bar_code, where the decoding is preceded by a time
consuming search for candidate regions,
decode_bar_code_rectangle2 scans the provided region directly
for bar codes. The rectangular region is defined by the parameters
Row and Column for the center, Phi for
the orientation and Length1 and Length2 for the
half edge lengths (see gen_rectangle2). The angle Phi
also determines the reading direction and is defined as the angle
between the reading direction of the bar code and the horizontal
image axis. The angle is positive in counter clockwise direction and
is given in radians as in gen_rectangle2. Note that the angle
unit deviates from the conventions in get_bar_code_result and
set_bar_code_param where angles are given in degrees.
Phi can be in the range of
\([-\pi, +\pi]\).
The reading direction is perpendicular to the bars of the bar code.
Bar codes with a reading direction
\(\textrm{Phi} + \pi\) are also returned.
Multiple regions for decoding can be given by supplying tuples for
Row, Column, Phi, Length1 and
Length2.
The rectangle should cover completely the bar code and the quiet zones.
Regions that are too big will be decoded, if there is no disturbing
pattern within these regions and the height (Length2) is
small enough such that scanlines can be placed sufficiently dense.
Rectangles that are too short in reading direction (Length1)
cannot be decoded.
decode_bar_code_rectangle2 can be used if the position of
the bar code is already known in advance. For example, the candidate
regions found by find_bar_code and get_bar_code_object
could be reused with a different code type (see the following example).
Multiple bar code types can be specified for CodeType. See
section Autodiscrimination for find_bar_code.
Further aspects of the actual decoding are explained with the operator
find_bar_code.
Execution information🔗
Execution information
-
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
-
Multithreading scope: global (may be called from any thread).
-
Automatically parallelized on internal data level.
This operator supports canceling timeouts and interrupts.
This operator modifies the state of the following input parameter:
During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.
Parameters🔗
Image (input_object) singlechannelimage → object (byte)
Input image.
BarCodeHandle (input_control, state is modified) barcode → (handle)
Handle of the bar code model.
CodeType (input_control) string(-array) → (string)
Type of the searched bar code.
Default: 'EAN-13'
List of values: '2/5 Industrial', '2/5 Interleaved', 'Codabar', 'Code 128', 'Code 39', 'Code 93', 'EAN-13 Add-On 2', 'EAN-13 Add-On 5', 'EAN-13', 'EAN-8 Add-On 2', 'EAN-8 Add-On 5', 'EAN-8', 'GS1 DataBar Expanded Stacked', 'GS1 DataBar Expanded', 'GS1 DataBar Limited', 'GS1 DataBar Omnidir', 'GS1 DataBar Stacked Omnidir', 'GS1 DataBar Stacked', 'GS1 DataBar Truncated', 'GS1-128', 'MSI', 'PharmaCode', 'UPC-A Add-On 2', 'UPC-A Add-On 5', 'UPC-A', 'UPC-E Add-On 2', 'UPC-E Add-On 5', 'UPC-E', 'auto'
Row (input_control) rectangle2.center.y(-array) → (real / integer)
Row index of the center.
Default: 50.0
Column (input_control) rectangle2.center.x(-array) → (real / integer)
Column index of the center.
Default: 100.0
Phi (input_control) rectangle2.angle.rad(-array) → (real / integer)
Orientation of rectangle in radians.
Default: 0.0
Suggested values: 0.0, 0.785398, 1.570796, 3.1415926
Length1 (input_control) rectangle2.hwidth(-array) → (real / integer)
Half of the length of the rectangle along the reading direction of the bar code.
Default: 200.0
Length2 (input_control) rectangle2.hheight(-array) → (real / integer)
Half of the length of the rectangle perpendicular to the reading direction of the bar code.
Default: 100.0
DecodedDataStrings (output_control) string(-array) → (string)
Data strings of all successfully decoded bar codes.
Example🔗
(HDevelop)
read_image (Image, 'barcode/ean13/ean1301.png')
create_bar_code_model ([], [], BHandle)
find_bar_code (Image, SymReg, BHandle, '2/5 Industrial', Dec)
if (|Dec| == 0)
* A 2/5 Industrial code wasn't found. Try decoding an EAN-13 code.
get_bar_code_object (CandReg, BHandle, 'all', 'candidate_regions')
smallest_rectangle2 (CandReg, R, C, Phi, L1, L2)
decode_bar_code_rectangle2 (Image, BHandle, 'EAN-13', R, C, Phi, \
L1, L2, Dec)
endif
Result🔗
The operator decode_bar_code_rectangle2 returns the value 2 (H_MSG_TRUE)
if the given parameters are correct.
Otherwise, an exception will be raised.
Combinations with other operators🔗
Combinations
Possible predecessors
create_bar_code_model, set_bar_code_param, smallest_rectangle2
Possible successors
get_bar_code_result, get_bar_code_object, clear_bar_code_model
Alternatives
See also
Module🔗
Bar Code