Operators |
get_bar_code_result — Get the alphanumerical results that were accumulated during the decoding of bar code symbols.
get_bar_code_result( : : BarCodeHandle, CandidateHandle, ResultName : BarCodeResults)
The operator get_bar_code_result allows to access alphanumeric results of the find and decode process. To access a result, first the handle of the bar code model (BarCodeHandle) and the index of the resulting symbol or candidate (CandidateHandle) must be passed. CandidateHandle refers to the results in the same order that is returned by the operator find_bar_code. CandidateHandle can take at least numbers from 0 to (n-1), where n is the total number of successfully decoded symbols, for all queries and can take numbers from 0 to (m-1), where m is the total number of candidates, if stated in the description of ResultName below. Alternatively, CandidateHandle can be set to 'all' if all results are desired. The option 'all' can be chosen only in cases where the return value of a single result is single valued.
The result returned in BarCodeResults can be selected by setting ResultName to:
returns the decoded result as a string in a human readable format. This decoded string can be returned for a single result, e.g., for CandidateHandle 0, or for all results simultaneously when CandidateHandle is set to 'all' . Note that only data characters are contained in the decoded string. Start, stop, and check characters are excluded. For optional check characters the behavior depends on the value of the 'check_char' parameter.
returns the bar code type of the decoded result as a string. This is especially important in the context of autodiscrimination (see find_bar_code). CandidateHandle specifies the results for which the type should be returned: The code type can be returned for a single result, e.g., for CandidateHandle 0 when requesting the type of the first result, or for all results simultaneously if CandidateHandle is set to 'all' .
returns the decoded result as a tuple of byte values. In contrast to 'decoded_reference' , this contains the same high level processed data that is also returned for 'decoded_strings' . However, if the data contains binary non-printable characters, this parameter is more convenient. Also, for Code 128 or Code 93, the decoded data may contain NULL characters. In this case, the data can only be fully retrieved using this parameter, as the NULL character will otherwise terminate the string.
returns the underlying decoded reference data. It comprises all original characters of the symbol, i.e., data characters, potential start or stop characters and check characters if present. For codes taking only numeric data, like, e.g., the EAN/UPC codes, the GS1 DataBar codes (except the GS1 DataBar Expanded variants), or the 2/5 codes, the decoded reference data takes the same values as the decoded string data including check characters. For codes with alphanumeric data, like for example Code 128 or Code 39 the decoded reference data are the indices of the respective decoding table. For GS1-128, the reference values are the ASCII codes of the decoded data (see also Tuple / String Operations), where the special character FNC1 appears with value 102. For GS1 DataBar Expanded and GS1 DataBar Expanded Stacked, the reference values are the ASCII codes of the decoded data, where the special character FNC1 appears with value 29. Furthermore, for all codes from the GS1 DataBar family the first reference value represents a linkage flag with value of 1 if the flag is set and 0 otherwise. As the decoded reference is a tuple of whole numbers it can only be called for a single result, meaning that CandidateHandle has to be the handle number of the corresponding decoded symbol.
returns the decoded string of a GS1 Composite component. For further details see the description of the parameter 'composite_code' of set_bar_code_param.
returns the decoded string of a GS1 Composite component as a tuple of byte values. If the data contains binary non-printable characters, this parameter is more convenient than 'composite_strings' .
returns the orientation for the specified result. The 'orientation' of a bar code is defined as the angle between its reading direction and the horizontal image axis. The angle is positive in counter clockwise direction and is given in degrees. It can be in the range of [-180.0 ... 180.0] degrees. Note that the reading direction is perpendicular to the bars of the bar code. A single angle is returned when only one result is specified, e.g., by entering 0 for CandidateHandle. Otherwise, when CandidateHandle is set to 'all' , a tuple containing the angles of all results is returned.
returns the size of barcode elements for the specified result.
returns whether find_bar_code was aborted. This might be caused by a timeout (see 'timeout' in set_bar_code_param) or an explicit abort (see 'abort' in set_bar_code_param).
Value | Description |
---|---|
0 | find_bar_code completed |
1 | find_bar_code was aborted by a timeout |
2 | find_bar_code was aborted using set_bar_code_param with 'abort' |
returns a tuple with the assessment of print quality in compliance with the international standard ISO/IEC 15416. The first element always contains the overall print quality of the symbol. The length of the tuple and the interpretation of the remaining elements depend on whether a simple 1D bar code is evaluated (such as EAN-13, Code 128, GS1 DataBar etc.) or a composite bar code (such as GS1 DataBar Omnidirectional CC-A, GS1 DataBar Limited CC-B).
For the print quality assessment a set of scan reflectance profiles (scan lines) is generated across the symbol. For each scan line a grade for each of the evaluated parameters is allocated. According to the standard these grades are whole numbers from 0 to 4, where 0 is the lowest and 4 the highest grade. The lowest grade of all parameter grades of a scan line is defined as the scan reflectance profile grade. Thus, each scan line has an own grade representing the respective minimal grade of all parameter grades of this scan line. The arithmetic mean of all those scan line grades is then returned as the overall symbol grade.
It is important to note that, even though the implementation is strictly based on the standard, the computation of the print quality grades depends on the decoding algorithm used. Thus, different bar code readers (of different vendors) can potentially produce slightly different results in the print quality assessment.
For simple 1D bar codes the print quality is described in a tuple with nine elements:
The overall quality is the minimum of all individual grades.
The decode grade is set to 4 when the reflectance profile of the symbol could be decoded according to the reference decode algorithm for the symbology and 0, otherwise. Note that HALCON's decode algorithm differs from the reference decode algorithm. Thus, in many cases HALCON can decode the symbol although the decode grade according to the standard is 0.
The symbol contrast is the range between the minimal and the maximal value in the reflectance profile. A strong contrast results in a good grading.
The minimal reflectance grade is set to 4 if the lowest reflectance value in the scan reflectance profile is lower or equal to 0.5 of the maximal reflectance value. Otherwise a value of 0 is assigned.
Edge contrast is the contrast between any two adjacent elements, both bar-to-space or space-to-bar. The minimal edge contrast grades the minimum of the edge contrast values measured in the reflectance profile.
The modulation indicates how strong the amplitudes of the bar code elements are. Big amplitudes make the assignment of the elements to bars or spaces more certain, resulting in a high modulation grade.
Defects is a grading of reflectance irregularities found within elements and quiet zones.
The decodability grade reflects deviations of the element widths from the nominal widths defined for the corresponding symbology.
The additional requirements are bar code symbology specific requirements: mostly regarding the required quiet zones, but sometimes it can be also related to wide/narrow ratio, inter character gaps, guarding patterns or further symbology specific characteristics. For some code types the conformity to the corresponding ISO/IEC standard cannot be guaranteed. This is mainly because the computation of the additional requirements requires the availability of metrical information.
For Code 39 symbols the grade of the inter character gap is dependent on the measured narrow element width given in millimeters. Since in find_bar_code neither metric information is available nor can be calculated, get_bar_code_result will only return the grade for the inter character gap assuming that the measured narrow element width is less than 0.287mm.
ISO/IEC 15420:2009 specifies the magnification factors as an additional criterion . A computation of this criterion is not possible since this would require knowledge of the metrical size of the bar code.
While overall quality is the final symbol grade to be reported, the rest of the grades give information for possible causes for poor quality of a symbol. A detailed list of frequently appearing defects and their effect on the individual grades can be found with the ISO/IEC 15416 standard. Note that the names and the order of the grades can be queried with the convenience option 'quality_isoiec15416_labels' .
For composite bar codes the print quality is described in a tuple with 24 elements, which we organize for better clarity in three groups and one sub group:
OVERALL: COMPOSITE: 0. Overall 11. Decode 1. Overall Linear 12. Rap Overall 2. Overall Composite COMPOSITE RAP: 13. Contrast LINEAR: 14. Minimal Reflectance 3. Decode 15. Minimal Edge Contrast 4. Symbol Contrast 16. Modulation 5. Minimal Reflectance 17. Defects 6. Minimal Edge contrast 18. Decodability 7. Modulation 19. Codeword Yield 8. Defects 20. Unused Error Correction 9. Decodability 21. Modulation 10. Additional Requirements 22. Decodability 23. Defects
For composite bar codes the first entries of the returned tuple are the overall grades that are listed in the group OVERALL. They represent the respective minimum of all individual grades of each group. The following entries of the tuple consist of the grades for the sub symbols listed in the groups LINEAR and COMPOSITE. They give information of possible causes for poor quality of the symbol.
The interpretation of the grades in the LINEAR group correspond to those for simple 1D bar codes. In contrast, the grades in the COMPOSITE group are directly equivalent to the one for a PDF 417 data code 2D symbol (see get_data_code_2d_results). However, for PDF 417 data code 2D symbols a start/stop pattern is used for the evaluation concerning the quality of the reflectance profile whereas for composite bar codes so-called Raw Address Patterns (RAP) are used instead of a start/stop pattern. The grades of the respective RAP sub symbols are organized in the sub group COMPOSITE RAP and are consistent with the grades for simple 1D bar codes.
The definition of the individual elements is as follows:
The overall grade in OVERALL is the final symbol grade to be reported. It is the minimum of the overall grades of the LINEAR and the COMPOSITE sub symbols overall linear and overall composite.
The overall linear grade is the overall grade for the LINEAR sub symbols.
The overall composite grade is the overall grade for the COMPOSITE sub symbols.
The grades in the LINEAR group correspond to those for simple 1D bar codes as described above.
The decode grade corresponds to the one for simple 1D bar codes as described above.
The rap overall grade is the minimum of all individual grades of the sub group COMPOSITE RAP.
The grades for the RAP sub symbols are consistent with the grades for simple 1D bar codes as described above.
The codeword yield grade counts and evaluates the relative number of correct decoded words acquired by the set of scan profiles.
The unused error correction grade counts the relative number of false decoded words within the error correction blocks.
The modulation grade indicates how strong the amplitudes, i.e., the extremal intensities, of the bars and spaces are.
The decodability grade measures the deviation of the nominal length of bars and spaces with respect to their reference length.
And finally, the defects grade refers to a measurement of how perfect the reflectance profiles of bars and spaces are.
Note that the names and the order of the grades can be queried with the convenience option 'quality_isoiec15416_labels' . Also note that the print quality of a bar code can be evaluated only if the bar code was decoded by find_bar_code in 'persistence' mode (see set_bar_code_param for further details).
returns a tuple with the raw values for all 'directly measurable' grades (returned by 'quality_isoiec15416' ). These are the grades, whose definition in the ISO/IEC 15416 standard is a 'direct derivative' of the reflectance (i.e., the gray values) properties of the symbol or grades that are the result of a 'direct counting'.
For simple 1D bar codes the grades are:
Symbol Contrast
Modulation
Minimal Reflectance
Defects
Minimal Edge contrast
Decodability
For composite bar codes the grades are:
Symbol Contrast
Rap Contrast
Minimal Reflectance
Minimal Edge contrast
Modulation
Defects
Decodability
Rap Minimal Reflectance
Rap Minimal Edge Contrast
Rap Modulation
Rap Defects
Rap Decodability
Codeword Yield
Unused Error Correction
The returned tuple has the same order of elements as the corresponding result by 'quality_isoiec15416' . For the grades, which are excluded from these lists the operator reports 'N/A' . In the case of simple 1D bar codes Decode, Overall, Additional Requirements do not have any interpretation in the reflectance profile and the respectively returned value is 'N/A' . For composite bar codes this is the case with all Overall and Decode grades. Note that although the grades Composite Modulation, Composite Decodability, Composite Defects are grading the gray value reflectance profile of a composite symbol, 'quality_isoiec15416_values' reports 'N/A' for them as well. Since they are computed in a complicated scheme involving the symbology decoding routine and the error correction mechanism, they do not have a direct raw measurement interpretation.
All values are normalized between 0.0 and 1.0. Hence, for example, a Symbol Contrast value of 0.75 will correspond to a gray value of 191.25 (for BYTE images).
returns convenience grade labels of the elements of the tuple returned when calling get_bar_code_result with 'quality_isoiec15416' . Note, that in order to be able to discriminate the composite from the linear grading case, the operator needs a handle of a valid result to be passed in CandidateHandle.
determines and returns additional information about scanlines of a given candidate region in a human-readable format. Here, CandidateHandle can take numbers from 0 to (m-1), where m is the total number of candidates. Note that the status of the scanlines of a bar code can be evaluated only if the operator find_bar_code or decode_bar_code_rectangle2 was called before while in 'persistence' mode (see set_bar_code_param for further details). No changes in any parameters of the bar code reader must occur between the last call of find_bar_code and this status query. Determining the status is computationally expensive and should be queried only if additional debugging information is needed.
Each candidate region contains a certain number of scanlines which depends on the type of bar code and could be changed with set_bar_code_param with the parameter 'num_scanlines' . Normally, the bar code scanner exits as soon as it has found enough scanlines that could be decoded - the default is one successfully decoded scanline, but this can be changed with set_bar_code_param with the parameter 'min_identical_scanlines' . When using 'status' in get_bar_code_result , the given candidate region is scanned again but this time all scanlines of the specified candidate region are being evaluated. Then the operator returns status information for every scanline of the candidate region in the same order as the scanlines themselves are returned by get_bar_code_object with the parameter 'scanlines_all' .
The following list shows the possible status messages grouped into stages in which the message can appear. The numbers in parentheses are the corresponding status codes returned by 'status_id' (see below).
The status of this scanline is unknown. The scanline will be ignored.
The scanline could be decoded successfully.
The number of edges in this scanline is too low for this bar code type.
The number of edges in this scanline is too low to find at least the start pattern, the stop pattern and a data character.
The number of edges in this scanline is too high for this bar code type
The symbology specific stop character could not be found.
The symbology specific start and stop characters could not be found.
Internal error.
Internal error.
For bar code types '2/5 Industrial' and '2/5 Interleaved' , the number of wide bars in a single character must be two.
The encoding pattern does not correspond to a character in the symbology specific look-up table.
For bar code types 'EAN-13' and 'UPC-A' , the left half of the symbol contains an invalid mix of the number sets A and B.
For example, this could happen if not enough characters ( depending on whether a check character is expected) could be found.
For bar code types 'EAN-13' , 'EAN-8' , and 'UPC-A' (including add-on variants) the obligatory center guard pattern could not be found.
For bar code types 'EAN-13' , 'EAN-8' , and 'UPC-A' (including add-on variants) either the obligatory left or right normal guard patterns could not be found. For bar code types 'UPC-E' (including add-on variants) either the left normal or right special guard patterns could not be found.
For bar code types 'EAN-13' , 'EAN-8' , 'UPC-A' , and 'UPC-E' containing add-on symbols, the obligatory add-on guard pattern could not be found.
For bar code types of the GS1 DataBar family, not enough finder patterns could be found.
For stacked bar code types no segment could be found.
The check character test failed. For bar codes with an optional check character, it is possible to disable the check character testing with 'check_char' in set_bar_code_param.
For bar code types 'EAN-13' , 'EAN-8' , 'UPC-A' , and 'UPC-E' containing add-on symbols, the mix of the number sets A and B does not match the implicit check digit.
For the bar code type 'UPC-A' and its add-on variants, the left half of the symbol must consist of six symbol characters of number set A, but a 'EAN-13' compatible mix of number sets A and B has been found instead. Try decoding the bar code as 'EAN-13' .
The bar code could be decoded, but its symbol region intersects with the symbol region of another successfully decoded symbol.
While scanning a candidate region in autodiscrimination mode (see find_bar_code with CodeType='auto' ), the decoder was unable to detect which bar code type the symbol belongs to.
A bar code could be decoded, but the resulting symbol region does not intersect the original candidate region. This is an indication that random clutter or another candidate was detected by accident by the scanlines used to scan the original candidate.
Warning messages:
The following messages are warnings only, not errors. They can appear in combination with a status message and are then added to the status message string. These messages are returned if the bar code reader detects possible quality issues in the input image. The messages 1000 to 1003 can appear only for successfully decoded scanlines and only for the following bar code types: 'Codabar' , '2/5 Industrial' , '2/5 Interleaved' , 'Code 39' , 'Code 93' , 'GS1-128' , 'Code 128' , 'MSI' , all 'EAN' -, 'UPC-A' - and 'UPC-E' -variants. Note that in cases where scanlines were already decoded incorrectly but not recognized as invalid by the bar code reader, these warnings will be wrong and must be ignored.
The measured width of the white spaces is bigger than internally expected. This is not a decoding error, but a warning that increasing white spaces could lead to undecodable symbols.
The measured width of the white spaces is smaller than internally expected. This is not a decoding error, but a warning that decreasing white spaces could lead to undecodable symbols.
The measured width of the bars is bigger than internally expected. This is not a decoding error, but a warning that increasing the width of the bars could lead to undecodable symbols.
The measured width of the bars is smaller than internally expected. This is not a decoding error, but a warning that decreasing the width of the bars could lead to undecodable symbols.
Internal algorithms show that the white pixels in the symbol region could be saturated. This warning is not bar code type specific. This warning is returned for each scanline. For example, the combination of the status messages 1001/1004 or 1003/1004 is a hint, that the input images might be overexposured.
The linkage flag in the linear bar code component indicates that there should be a composite component, but the composite component could not be found. The decoder returned the linear component only. This warning is returned for each scanline.
This message is an information that some edges of the current scanline were used to compute the merged scanline.
returns additional information about scanlines in a numeric format that can be easily parsed. The description of this functionality and the message numbers are described with the parameter 'status' above. The numbers of the warnings can be returned together with other status numbers. The single status message and warning numbers for each scanline are returned as a string, separated by a semicolon, e.g. '1;1000;1004'.
Handle of the bar code model.
Indicating the bar code results respectively candidates for which the data is required.
Default value: 'all'
Suggested values: 0, 1, 2, 'all'
Names of the resulting data to return.
Default value: 'decoded_types'
Suggested values: 'decoded_types' , 'decoded_strings' , 'decoded_data' , 'decoded_reference' , 'element_size' , 'orientation' , 'composite_strings' , 'composite_reference' , 'aborted' , 'quality_isoiec15416' , 'quality_isoiec15416_labels' , 'quality_isoiec15416_values' , 'status' , 'status_id'
List with the results.
The operator get_bar_code_result returns the value 2 (H_MSG_TRUE) if the given parameters are correct and the requested results are available for the last symbol search. Otherwise, an exception will be raised.
Bar Code
Operators |