HALCON Reference Manual 10.0.2
Table of Contents / Identification / Bar Code ClassesClassesClasses | | | Operators

find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode (Operator)

Name

find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode — Detect and read bar code symbols in an image.

Signature

find_bar_code(Image : SymbolRegions : BarCodeHandle, CodeType : DecodedDataStrings)

Herror find_bar_code(const Hobject Image, Hobject* SymbolRegions, const Hlong BarCodeHandle, const char* CodeType, char* DecodedDataStrings)

Herror T_find_bar_code(const Hobject Image, Hobject* SymbolRegions, const Htuple BarCodeHandle, const Htuple CodeType, Htuple* DecodedDataStrings)

Herror find_bar_code(Hobject Image, Hobject* SymbolRegions, const HTuple& BarCodeHandle, const HTuple& CodeType, char* DecodedDataStrings)

Herror find_bar_code(Hobject Image, Hobject* SymbolRegions, const HTuple& BarCodeHandle, const HTuple& CodeType, HTuple* DecodedDataStrings)

HRegionArray HImage::FindBarCode(const HBarCode& BarCodeHandle, const HTuple& CodeType, HTuple* DecodedDataStrings) const

HRegionArray HBarCode::FindBarCode(const HImage& Image, const HTuple& CodeType, HTuple* DecodedDataStrings) const

void HOperatorSetX.FindBarCode(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*SymbolRegions, [in] VARIANT BarCodeHandle, [in] VARIANT CodeType, [out] VARIANT* DecodedDataStrings)

IHRegionX* HBarCodeX.FindBarCode(
[in] IHImageX* Image, [in] VARIANT CodeType, [out] VARIANT* DecodedDataStrings)

IHRegionX* HImageX.FindBarCode(
[in] IHBarCodeX* BarCodeHandle, [in] VARIANT CodeType, [out] VARIANT* DecodedDataStrings)

static void HOperatorSet.FindBarCode(HObject image, out HObject symbolRegions, HTuple barCodeHandle, HTuple codeType, out HTuple decodedDataStrings)

HRegion HBarCode.FindBarCode(HImage image, HTuple codeType, out HTuple decodedDataStrings)

HRegion HBarCode.FindBarCode(HImage image, string codeType, out string decodedDataStrings)

HRegion HImage.FindBarCode(HBarCode barCodeHandle, HTuple codeType, out HTuple decodedDataStrings)

HRegion HImage.FindBarCode(HBarCode barCodeHandle, string codeType, out string decodedDataStrings)

Description

The operator find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode finds and reads bar code symbols in a given image (ImageImageImageImageimage) and returns the decoded data. In one image an arbitrary number of bar codes of a single type can be read. The type of the desired bar code symbology is given by CodeTypeCodeTypeCodeTypeCodeTypecodeType. The decoded strings are returned in DecodedDataStringsDecodedDataStringsDecodedDataStringsDecodedDataStringsdecodedDataStrings and the corresponding bar code regions in SymbolRegionsSymbolRegionsSymbolRegionsSymbolRegionssymbolRegions. For a total of n successfully read bar codes, the indices from 0 to (n-1) can be used as candidate handle in the operators get_bar_code_objectget_bar_code_objectget_bar_code_objectGetBarCodeObjectGetBarCodeObject and get_bar_code_resultget_bar_code_resultget_bar_code_resultGetBarCodeResultGetBarCodeResult in order to retrieve the desired data of one specific bar code result.

Before calling find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode a bar code model must be created by calling create_bar_code_modelcreate_bar_code_modelcreate_bar_code_modelCreateBarCodeModelCreateBarCodeModel. This operator returns a bar code model BarCodeHandleBarCodeHandleBarCodeHandleBarCodeHandlebarCodeHandle, which is input to find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode.

The output value DecodedDataStringsDecodedDataStringsDecodedDataStringsDecodedDataStringsdecodedDataStrings contains the decoded string of the symbol for each bar code result. The contents of the strings are conform to the appropriate standard of the symbology. Typically, DecodedDataStringsDecodedDataStringsDecodedDataStringsDecodedDataStringsdecodedDataStrings contains only data characters. For bar codes with a mandatory check character the check character is not included in the string. For bar codes with a facultative check character, like for example Code 39, Codabar, 2/5 Industrial or 2/5 Interleaved, the result depends on the value of the 'check_char'"check_char""check_char""check_char""check_char" parameter, which can be set in create_bar_code_modelcreate_bar_code_modelcreate_bar_code_modelCreateBarCodeModelCreateBarCodeModel, set_bar_code_paramset_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParam or set_bar_code_param_specificset_bar_code_param_specificset_bar_code_param_specificSetBarCodeParamSpecificSetBarCodeParamSpecific. By default 'check_char'"check_char""check_char""check_char""check_char" is 'absent'"absent""absent""absent""absent" and the check character is interpreted as a normal data character and hence included in the decoded string. When 'check_char'"check_char""check_char""check_char""check_char" is set to 'present'"present""present""present""present" the correctness of the check character is primarily tested. If the check character is correct the decoded string contains just the data characters; if the check character is not correct the bar code is graded as unreadable. Accordingly, the symbol region and the decoded string do not appear in the list of resulting strings (DecodedDataStringsDecodedDataStringsDecodedDataStringsDecodedDataStringsdecodedDataStrings) and in the list of resulting regions (SymbolRegionsSymbolRegionsSymbolRegionsSymbolRegionssymbolRegions).

The underlying decoded reference data, including start/stop and check characters, can be queried by using the get_bar_code_resultget_bar_code_resultget_bar_code_resultGetBarCodeResultGetBarCodeResult operator with the option 'decoded_reference'"decoded_reference""decoded_reference""decoded_reference""decoded_reference".

Following bar code symbologies are supported:

    2/5 Industrial       EAN-8                RSS-14
    2/5 Interleaved      EAN-8 Add-On 2       RSS-14 Truncated
    Codabar              EAN-8 Add-On 5       RSS-14 Stacked
    Code 39              EAN-13               RSS-14 Stacked Omnidirectional
    Code 93              EAN-13 Add-On 2      RSS Limited
    Code 128             EAN-13 Add-On 5      RSS Expanded
    MSI                  UPC-A                RSS Expanded Stacked
    PharmaCode           UPC-A Add-On 2
                         UPC-A Add-On 5
                         UPC-E
                         UPC-E Add-On 2
                         UPC-E Add-On 5

Note, that the PharmaCode can be read in forward and backward direction, both yielding a valid result. Therefore, both strings are returned and concatenated into a single string in DecodedDataStringsDecodedDataStringsDecodedDataStringsDecodedDataStringsdecodedDataStrings by a separating comma.

Autodiscrimination

Autodiscrimination describes the simultaneous decoding of multiple bar code types in one call of find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode. For this purpose a tuple of bar code types is specified for the parameter CodeTypeCodeTypeCodeTypeCodeTypecodeType. Using the generic value 'auto'"auto""auto""auto""auto" all known bar code types are decoded - except 'PharmaCode'"PharmaCode""PharmaCode""PharmaCode""PharmaCode" and 'MSI'"MSI""MSI""MSI""MSI" because these codes don't have enough features to be reliably separated from other bar code types. The tuple can also contain bar code types with the tilde prefix (~) which won't be decoded. For example

['auto'"auto""auto""auto""auto", '~EAN-8'"~EAN-8""~EAN-8""~EAN-8""~EAN-8", '~EAN-8 Add-On 2'"~EAN-8 Add-On 2""~EAN-8 Add-On 2""~EAN-8 Add-On 2""~EAN-8 Add-On 2", '~EAN-8 Add-On 5'"~EAN-8 Add-On 5""~EAN-8 Add-On 5""~EAN-8 Add-On 5""~EAN-8 Add-On 5"]

describes all bar code types without 'PharmaCode'"PharmaCode""PharmaCode""PharmaCode""PharmaCode", 'MSI'"MSI""MSI""MSI""MSI" and all kinds of 'EAN-8'"EAN-8""EAN-8""EAN-8""EAN-8". Please note that each additionally allowed bar code type increases the run-time of the operator. Using too many bar code types the reliability of the decoding could decrease because not all bar code types can be discriminated reliably. To improve autodiscrimination compatibility bar codes with a check character or check sum should be used.

The bar code reader tries to decode the bar code types in the following order:

RSS-14, RSS-14 Truncated, RSS-14 Stacked,RSS-14 Stacked Omnidirectional, RSS Limited, RSS Expanded, RSS Expanded Stacked, Code 128, EAN-13 Add-On 5, EAN-13 Add-On 2, EAN-13, UPC-A Add-On 5, UPC-A Add-On 2, UPC-A, EAN-8 Add-On 5, EAN-8 Add-On 2, EAN-8, UPC-E Add-On 5, UPC-E Add-On 2, UPC-E, Code 93, Code 39, Codabar, 2/5 Interleaved, 2/5 Industrial.

Therefore you should exclude at least all definitely not occuring bar code types that are scanned before the first of the bar code types you expect to find or, better, just scan for the explicit list of bar code types you expect.

Especially for the autodiscrimination there is the operator set_bar_code_param_specificset_bar_code_param_specificset_bar_code_param_specificSetBarCodeParamSpecificSetBarCodeParamSpecific. With it some parameters of the bar code model can be set specifically for certain bar code types.

Training

If the bar code reader is in training mode, the operator find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode executes a training cycle. The training mode is described with the operator set_bar_code_paramset_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParam.

Attention

A bar code model 'BarCodeHandle'"BarCodeHandle""BarCodeHandle""BarCodeHandle""BarCodeHandle" cannot be shared between two or more user's threads. Different bar code models can be used independently and safely in different threads.

Parallelization

Parameters

ImageImageImageImageimage (input_object)  image objectHImageHImageHImageXHobject (byte / uint2)

Input image.

SymbolRegionsSymbolRegionsSymbolRegionsSymbolRegionssymbolRegions (output_object)  region(-array) objectHRegionHRegionHRegionXHobject *

Regions of the successfully decoded bar code symbols.

BarCodeHandleBarCodeHandleBarCodeHandleBarCodeHandlebarCodeHandle (input_control)  barcode HBarCode, HTupleHBarCode, HTupleHBarCodeX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Handle of the bar code model.

CodeTypeCodeTypeCodeTypeCodeTypecodeType (input_control)  string(-array) HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Type of the searched bar code.

Default value: 'EAN-13' "EAN-13" "EAN-13" "EAN-13" "EAN-13"

List of values: '2/5 Industrial'"2/5 Industrial""2/5 Industrial""2/5 Industrial""2/5 Industrial", '2/5 Interleaved'"2/5 Interleaved""2/5 Interleaved""2/5 Interleaved""2/5 Interleaved", 'Codabar'"Codabar""Codabar""Codabar""Codabar", 'Code 39'"Code 39""Code 39""Code 39""Code 39", 'Code 93'"Code 93""Code 93""Code 93""Code 93", 'Code 128'"Code 128""Code 128""Code 128""Code 128", 'EAN-13'"EAN-13""EAN-13""EAN-13""EAN-13", 'EAN-13 Add-On 2'"EAN-13 Add-On 2""EAN-13 Add-On 2""EAN-13 Add-On 2""EAN-13 Add-On 2", 'EAN-13 Add-On 5'"EAN-13 Add-On 5""EAN-13 Add-On 5""EAN-13 Add-On 5""EAN-13 Add-On 5", 'EAN-8'"EAN-8""EAN-8""EAN-8""EAN-8", 'EAN-8 Add-On 2'"EAN-8 Add-On 2""EAN-8 Add-On 2""EAN-8 Add-On 2""EAN-8 Add-On 2", 'EAN-8 Add-On 5'"EAN-8 Add-On 5""EAN-8 Add-On 5""EAN-8 Add-On 5""EAN-8 Add-On 5", 'UPC-A'"UPC-A""UPC-A""UPC-A""UPC-A", 'UPC-A Add-On 2'"UPC-A Add-On 2""UPC-A Add-On 2""UPC-A Add-On 2""UPC-A Add-On 2", 'UPC-A Add-On 5'"UPC-A Add-On 5""UPC-A Add-On 5""UPC-A Add-On 5""UPC-A Add-On 5", 'UPC-E'"UPC-E""UPC-E""UPC-E""UPC-E", 'UPC-E Add-On 2'"UPC-E Add-On 2""UPC-E Add-On 2""UPC-E Add-On 2""UPC-E Add-On 2", 'UPC-E Add-On 5'"UPC-E Add-On 5""UPC-E Add-On 5""UPC-E Add-On 5""UPC-E Add-On 5", 'MSI'"MSI""MSI""MSI""MSI", 'PharmaCode'"PharmaCode""PharmaCode""PharmaCode""PharmaCode", 'RSS-14'"RSS-14""RSS-14""RSS-14""RSS-14", 'RSS-14 Truncated'"RSS-14 Truncated""RSS-14 Truncated""RSS-14 Truncated""RSS-14 Truncated", 'RSS-14 Stacked'"RSS-14 Stacked""RSS-14 Stacked""RSS-14 Stacked""RSS-14 Stacked", 'RSS-14 Stacked Omnidir'"RSS-14 Stacked Omnidir""RSS-14 Stacked Omnidir""RSS-14 Stacked Omnidir""RSS-14 Stacked Omnidir", 'RSS Limited'"RSS Limited""RSS Limited""RSS Limited""RSS Limited", 'RSS Expanded'"RSS Expanded""RSS Expanded""RSS Expanded""RSS Expanded", 'RSS Expanded Stacked'"RSS Expanded Stacked""RSS Expanded Stacked""RSS Expanded Stacked""RSS Expanded Stacked", 'auto'"auto""auto""auto""auto"

DecodedDataStringsDecodedDataStringsDecodedDataStringsDecodedDataStringsdecodedDataStrings (output_control)  string(-array) HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Data strings of all successfully decoded bar codes.

Result

The operator find_bar_codefind_bar_codefind_bar_codeFindBarCodeFindBarCode returns the value 2 (H_MSG_TRUE) if the given parameters are correct. Otherwise, an exception will be raised.

Possible Predecessors

create_bar_code_modelcreate_bar_code_modelcreate_bar_code_modelCreateBarCodeModelCreateBarCodeModel, set_bar_code_paramset_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParam

Possible Successors

get_bar_code_resultget_bar_code_resultget_bar_code_resultGetBarCodeResultGetBarCodeResult, get_bar_code_objectget_bar_code_objectget_bar_code_objectGetBarCodeObjectGetBarCodeObject, clear_bar_code_modelclear_bar_code_modelclear_bar_code_modelClearBarCodeModelClearBarCodeModel

Alternatives

decode_bar_code_rectangle2decode_bar_code_rectangle2decode_bar_code_rectangle2DecodeBarCodeRectangle2DecodeBarCodeRectangle2

Module

Bar Code


Table of Contents / Identification / Bar Code ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH