CN110874538A - Method and device for evaluating decoding result of bar code and electronic equipment - Google Patents
Method and device for evaluating decoding result of bar code and electronic equipment Download PDFInfo
- Publication number
- CN110874538A CN110874538A CN201810994954.7A CN201810994954A CN110874538A CN 110874538 A CN110874538 A CN 110874538A CN 201810994954 A CN201810994954 A CN 201810994954A CN 110874538 A CN110874538 A CN 110874538A
- Authority
- CN
- China
- Prior art keywords
- bar code
- target
- determining
- bar
- character
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/0008—General problems related to the reading of electronic memory record carriers, independent of its reading method, e.g. power transfer
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Character Discrimination (AREA)
- Image Processing (AREA)
Abstract
The embodiment of the invention provides a method, a device and electronic equipment for evaluating a decoding result of a bar code, wherein the method comprises the steps of obtaining position information corresponding to each bar and each space in a target bar code; determining a target confidence coefficient corresponding to the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, wherein the target confidence coefficient is used for: and characterizing the accuracy of the decoding result of the target bar code. So as to evaluate the accuracy of the decoding result of the bar code.
Description
Technical Field
The present invention relates to the field of barcode identification technologies, and in particular, to a method and an apparatus for evaluating a decoding result of a barcode, and an electronic device.
Background
The bar code is composed of bars (black bars) and spaces (white bars) arranged in a predetermined rule determined by a code system corresponding to the bar code. Currently, the related barcode decoding process is: scanning to obtain a bar code, determining position information of each bar and each space in the bar code, and identifying a decoding result of the bar code based on the position information of the bars and the spaces, wherein the decoding result of the bar code can be a string of characters containing a plurality of characters.
In the related bar code decoding process, the success rate of decoding the bar code is paid more attention, and when the decoding result of the bar code is identified, the decoding result is directly output after the decoding result of the bar code is considered to be successful. But neglects the influence of environmental factors on the accuracy of the decoding result of the bar code, such as: when the bar code is wrinkled, namely distorted, blurred, and/or contaminated, the determined bar and space position information may be erroneous, and the decoding result of the identified bar code may be erroneous. Fig. 1A-1E are exemplary diagrams of distorted, blurred, speckled, and/or smeared barcodes, respectively, where fig. 1A is an exemplary diagram of a distorted barcode, fig. 1B is an exemplary diagram of a blurred barcode, fig. 1C is an exemplary diagram of a speckled barcode, fig. 1D is an exemplary diagram of an smeared barcode, and fig. 1E is an exemplary diagram of a speckled and blurred barcode. In the related bar code decoding process, the decoding result with low accuracy is directly output, and the user experience is influenced.
Therefore, how to evaluate the accuracy of the decoding result of the barcode before outputting the decoding result of the identified barcode becomes an urgent problem to be solved.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for evaluating a decoding result of a bar code and electronic equipment, so as to evaluate the accuracy of the decoding result of the bar code. The specific technical scheme is as follows:
in one aspect, an embodiment of the present invention provides a method for evaluating a decoding result of a barcode, where the method includes:
acquiring the position information corresponding to each bar and each space in the target bar code;
determining a target confidence corresponding to the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, wherein the target confidence is used for: and characterizing the accuracy of the decoding result of the target bar code.
On the other hand, an embodiment of the present invention provides an evaluation apparatus for a decoding result of a barcode, where the apparatus includes:
the first acquisition module is used for acquiring the position information corresponding to each bar and each space in the target bar code;
a determining module, configured to determine a target confidence corresponding to the target barcode based on a preset accuracy evaluation rule and respective corresponding location information of each bar and each space in the target barcode, where the target confidence is used to: and characterizing the accuracy of the decoding result of the target bar code.
On the other hand, the embodiment of the invention provides electronic equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
the processor is used for implementing any of the method steps for evaluating the decoding result of the barcode provided by the embodiments of the present invention when executing the computer program stored in the memory.
On the other hand, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method for evaluating a decoding result of a barcode provided in any one of the embodiments of the present invention is implemented.
In the embodiment of the invention, the position information corresponding to each bar and each space in the target bar code is obtained; determining a target confidence coefficient corresponding to the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, wherein the target confidence coefficient is used for: and characterizing the accuracy of the decoding result of the target bar code.
In the embodiment of the invention, the target confidence corresponding to the target bar code can be determined based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, namely, the accuracy of the decoding result of the target bar code can be evaluated. And the misidentification rate of the decoding result of the bar code can be controlled to a certain extent. Of course, it is not necessary for any product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without any creative effort.
FIGS. 1A-1E are exemplary diagrams of distorted, blurred, speckled, and/or smeared barcodes, respectively;
fig. 2 is a schematic flowchart of a method for evaluating a decoding result of a barcode according to an embodiment of the present invention;
FIG. 3A is a schematic diagram of a bar code with a code of 128 codes;
fig. 3B is a gray level histogram respectively corresponding to bars corresponding to a character when no light spot appears in the bar corresponding to the character and a light spot appears in the bar;
FIG. 4 is a schematic diagram of a character with bars and spaces undistorted;
fig. 5 is another schematic flow chart of a method for evaluating a decoding result of a barcode according to an embodiment of the present invention;
fig. 6 is another schematic flow chart of a method for evaluating a decoding result of a barcode according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an evaluation device for decoding results of a barcode according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
fig. 9 is another schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Before describing the method for evaluating the decoding result of the barcode according to the present invention in detail, the terms related to the present invention will be briefly described.
The terms of the present invention are explained as follows:
bar code: or bar code, is a graphic identifier in which a plurality of bars and spaces having different widths are arranged according to a certain encoding rule to express a group of information.
The bars indicate black bars in the bar code.
Null, refers to the white band in the barcode.
The position information corresponding to a bar, which refers to the position of the bar in the bar code, may be identified by the offset of the bar from the start position of the bar code where it is located, in one case, the start position of the bar code may be identified by the location of the quiet zone of the bar code.
The location information corresponding to a null, which refers to the location of the null in the bar code, may be identified by the offset of the null from the starting location of the bar code in which it is located, in one case, the starting location of the bar code may be identified by the location of the quiet zone of the bar code.
Confidence, also called reliability, or confidence level, confidence coefficient, i.e. when a sample estimates an overall parameter, the conclusion is always uncertain due to the randomness of the sample. Therefore, a probabilistic statement method, i.e. interval estimation in mathematical statistics, is used, i.e. how large the corresponding probability of the estimated value and the overall parameter are within a certain allowable error range, and this corresponding probability is called confidence. In the embodiment of the present invention, the target confidence corresponding to the barcode may represent the accuracy of the decoding result of the barcode, where the higher the value of the target confidence corresponding to the barcode is, the higher the accuracy of the decoding result of the barcode is.
And (3) decoding results: and scanning and decoding the bar code to obtain the result.
The invention concept of the invention is as follows:
when the decoding result of the target bar code is determined, the position information corresponding to each bar and each space in the target bar code is determined. Acquiring each bar in the target bar code and position information corresponding to each bar in the target bar code; and then determining a target confidence coefficient corresponding to the target bar code and representing the accuracy of the decoding result of the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code. The method and the device can evaluate the accuracy of the decoding result of the target bar code and control the misidentification rate of the decoding result of the bar code in a certain degree.
The preset accuracy evaluation rule can be set based on problems which may occur to the bar code in actual conditions. In one implementation, the preset accuracy evaluation rule includes a rule for evaluating the accuracy of the decoding result of the barcode based on at least one of the spot information, the degree of ambiguity, the degree of contamination, and the degree of distortion corresponding to the barcode. Furthermore, the target confidence corresponding to the target bar code can be determined based on different preset accuracy evaluation rules and the respective corresponding position information of each bar and each space in the target bar code, so that the accuracy of the decoding result of the target bar code can be evaluated, and the misidentification rate of the decoding result of the bar code can be controlled to a certain extent.
Based on the same inventive concept, the embodiment of the invention provides a method and a device for evaluating a decoding result of a bar code and electronic equipment, so as to evaluate the accuracy of the decoding result of the bar code.
As shown in fig. 2, an embodiment of the present invention provides a method for evaluating a decoding result of a barcode, which may include the following steps:
s201: acquiring the position information corresponding to each bar and each space in the target bar code;
it can be understood that the method for evaluating the decoding result of the barcode provided by the embodiment of the present invention can be applied to electronic devices, and the electronic devices can be computers, smart phones, barcode identification devices, and the like.
In one case, the target barcode may be: the bar code of the decoding result has been determined. For the barcode with the determined decoding result, the position information corresponding to each bar and each space included in the barcode is determined, and the electronic device can directly acquire the position information corresponding to each bar and each space in the target barcode.
In an implementation manner, the electronic device may implement a function of identifying a barcode, and at this time, after the electronic device scans the barcode and determines position information of a bar space included in the barcode, or identifies a decoding result of the barcode, the evaluation flow of the decoding result of the barcode provided by the embodiment of the present invention is triggered.
In another implementation manner, the electronic device may not implement the function of identifying the barcode, at this time, the electronic device may monitor the barcode recognition device in real time or periodically, and trigger the evaluation process of the decoding result of the barcode provided by the embodiment of the present invention after the barcode recognition device determines the position information of a bar space included in the barcode, or after the barcode recognition device recognizes the decoding result of the barcode. It can be understood that the evaluation process of the decoding result of the barcode provided by the embodiment of the present invention is applied before the electronic device or the barcode recognition apparatus performs the step of outputting the decoding result of the target barcode. Wherein, the bar code recognition device is: and the equipment realizes the identification function of the bar code.
As shown in fig. 3A, a barcode with a code system of 128 codes is illustrated, wherein the barcode with the code system of 128 codes sequentially includes a quiet area, a start symbol area, a data symbol area, a terminator area and the quiet area from the left side. In addition, for other bar codes, in addition to the above-mentioned regions, the bar code may include an intermediate separator region, and/or a check symbol region.
S202: and determining a target confidence corresponding to the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code.
Wherein the target confidence is used to: and characterizing the accuracy of the decoding result of the target bar code. In one case, the greater the value of the target confidence corresponding to the target barcode, the greater the accuracy of the decoding result of the target barcode.
In the embodiment of the present invention, the preset accuracy evaluation rule may be: rules are set based on the problems that the barcode may have in practice. For example: aiming at the problem of light spots in the bar code, the rule of evaluating the accuracy of the decoding result of the bar code based on the light spot information corresponding to the bar code can be set; aiming at the problem that the bar code is fuzzy, a rule for evaluating the accuracy of a decoding result of the bar code based on the fuzzy degree corresponding to the bar code can be set; aiming at the problem that the bar code is stained, a rule for evaluating the accuracy of a decoding result of the bar code based on the staining degree corresponding to the bar code can be set; aiming at the problem that the bar code is distorted, a rule for evaluating the accuracy of the decoding result of the bar code based on the distortion degree corresponding to the bar code can be set. It should be understood that the above is only an illustration of the problem occurring in the barcode, and does not limit the structure of the type of the problem occurring in the barcode in the embodiment of the present invention, and further, does not limit the structure of the preset accuracy evaluation rule in the embodiment of the present invention.
In one case, the respective position information of each bar and each space in the target bar code may represent the respective shapes of each bar and each space in the target bar code. The electronic equipment can determine whether the target bar code has wrinkles or not, namely has distortion or not through the respective shapes of each bar and each space in the target bar code and a preset accuracy evaluation rule, and can further determine the distortion degree of the target bar code. It can be understood that the distortion of the barcode may affect the accuracy of the decoding result of the identified barcode to some extent, and the greater the distortion may have a greater effect on the accuracy of the decoding result of the barcode, specifically, the greater the distortion of the barcode, the lower the confidence of the barcode.
Based on the principle, in the embodiment of the invention, the electronic device can determine the distortion degree of the target bar code based on the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, and further determine the corresponding confidence coefficient of the target bar code based on the determined distortion degree. The process of determining the confidence corresponding to the target barcode based on the determined distortion degree may be: the electronic device stores the corresponding relationship between each distortion degree and the confidence degree locally or in a storage device connected with the electronic device, and the electronic device can match the determined distortion degree with the corresponding relationship, and determine the confidence degree corresponding to the distortion degree successfully matched with the determined distortion degree in the corresponding relationship as the target confidence degree corresponding to the target bar code. The preset accuracy evaluation rule is as follows: the rule can be a rule for evaluating the accuracy of the decoding result of the bar code based on the distortion degree corresponding to the bar code.
In another case, the electronic device may determine, from the target barcode, a gray value of a pixel point corresponding to each bar and/or a gray value of a pixel point corresponding to each space based on the respective position information of each bar and each space in the target barcode, and may further determine the confidence corresponding to the target barcode based on the gray value of the pixel point corresponding to each bar and/or the gray value of the pixel point corresponding to each space, and a preset accuracy evaluation rule.
It can be understood that when the target barcode has a light spot, the pixel point at the position of the light spot is closer to white, and the gray value of the pixel point at the position is relatively larger. When the target bar code is not blurred, the gray value of the pixel point corresponding to the bar is 0, the gray value of the pixel point corresponding to the space is 255, when the target bar code is blurred, the gray value of the pixel point corresponding to the bar is relatively increased and is larger than 0, and the gray value of the pixel point corresponding to the space is relatively decreased and is smaller than 255. When the target barcode is contaminated, the gray value of the pixel point at the contaminated position may also be changed, for example, the pixel value of the pixel point corresponding to the empty barcode may be decreased. Whether light spots appear in the target bar code, whether blurring appears in the target bar code, whether pollution damage appears in the target bar code and the like can be determined through the gray value of the pixel point corresponding to each bar and/or the gray value of the pixel point corresponding to each space, and then the target confidence coefficient corresponding to the target bar code can be determined based on the determined result.
The more serious the light spot appears in the target bar code, the more possible the influence on the accuracy of the decoding result of the bar code is; the more serious the situation of the blur in the target bar code is, namely the greater the blur degree, the greater the influence on the accuracy of the decoding result of the bar code is possibly; the more severe the presence of a smear in a target bar code, the greater the effect on the accuracy of the decoded result of that bar code may be.
Specifically, the method comprises the following steps: when only the condition that light spots appear in the target bar code is considered, the more serious the condition that the light spots appear in the target bar code is, the lower the numerical value of the target confidence coefficient corresponding to the bar code is; when only the situation that the target bar code is fuzzy is considered, the more serious the situation that the target bar code is fuzzy, the lower the value of the target confidence coefficient corresponding to the bar code is; when only the occurrence of an artifact in the target barcode is considered, the more severe the occurrence of an artifact in the target barcode, the lower the value of the target confidence for that barcode.
In an implementation manner, after the electronic device determines a target confidence corresponding to the target barcode, the electronic device may output a decoding result of the target barcode and output the target confidence for a user to refer to, so as to determine whether the decoding result of the target barcode is reliable. Alternatively, the electronic device may send the determined target confidence corresponding to the target barcode to the barcode recognition apparatus, so that the barcode recognition apparatus outputs the target confidence while outputting the decoding result of the target barcode.
In another implementation manner, after the electronic device determines the target confidence corresponding to the target barcode, it may also determine whether the determined target confidence exceeds a preset confidence threshold, and when the determination exceeds the preset confidence threshold, output a decoding result of the target barcode, or control the barcode recognition device to output the decoding result of the target barcode; when the judgment result is not exceeded, the decoding result of the target bar code is not output, or the bar code identification device is controlled not to output the decoding result of the target bar code; or prompting the user to re-identify the target bar code; alternatively, the target bar code may be directly input to a bar code recognition device and re-recognized.
In the embodiment of the invention, the target confidence corresponding to the target bar code can be determined based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, namely, the accuracy of the decoding result of the target bar code can be evaluated. And the misidentification rate of the decoding result of the bar code can be controlled to a certain extent.
In one implementation, the preset accuracy evaluation rule may include a rule for evaluating accuracy of a decoding result of the barcode based on at least one of the light spot information, the degree of blur, the degree of contamination, and the degree of distortion corresponding to the barcode.
In the embodiment of the invention, factors for determining the preset accuracy evaluation rule, such as at least one of the spot information, the fuzzy degree, the fouling degree and the distortion degree corresponding to the bar code, can be selected based on the requirements of the user, and the decoding result of the target bar code is evaluated based on the determined preset accuracy evaluation rule. When the number of the factors determining the preset accuracy evaluation rule is at least two, the decoding result of the target bar code can be evaluated by utilizing different factors determining the preset accuracy evaluation rule based on the preset sequence.
In an implementation manner, the step of determining the target confidence corresponding to the target barcode based on the preset accuracy evaluation rule and the respective corresponding location information of each bar and each space in the target barcode may include:
determining the gray value of each pixel point corresponding to each bar in the target bar code as the bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as a space gray value based on the position information corresponding to each space in the target bar code;
and determining a target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule.
It can be understood that each bar in the target bar code may correspond to a plurality of pixels, and each space may correspond to a plurality of pixels. After the electronic device obtains the respective corresponding position information of each bar and each space in the target bar code, the gray value of each corresponding pixel point of each bar can be determined from the target bar code based on the corresponding position information of each bar and is used as a bar gray value; and/or determining the gray value of each pixel point corresponding to each space from the target bar code based on the position information corresponding to each space as a space gray value.
The electronic equipment can determine whether light spots appear in the target bar code, whether blurring appears in the target bar code, whether fouling appears in the target bar code and other problems through the bar gray value corresponding to each bar and/or the empty gray value corresponding to each empty bar code and a preset accuracy evaluation rule, further determine the condition, the blurring degree and/or the fouling degree of the light spots, and then determine the target confidence coefficient corresponding to the target bar code based on the determination result.
In one implementation, the target barcode is: the bar code for which the decoding result has been determined; the decoding result of the target bar code comprises a plurality of characters;
each character can correspond to a plurality of bars and a plurality of spaces, and the bar and the space corresponding to each character are determined on the premise that the decoding result of the target bar code is determined;
when the preset accuracy evaluation rule comprises the following steps: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code,
determining a gray value of each pixel point corresponding to each bar from the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining a gray value of each pixel point corresponding to each space from the target bar code based on the position information corresponding to each space in the target bar code, wherein the step of determining the gray value as the space gray value may include:
aiming at each character corresponding to the target bar code, determining the gray value of a pixel point corresponding to each bar corresponding to the character from the target bar code as a bar gray value based on the position information corresponding to each bar corresponding to the character;
the step of determining the target confidence corresponding to the target barcode based on the barcode value and/or the empty barcode value and the preset accuracy evaluation rule may include:
aiming at each character corresponding to the target bar code, determining whether pixel points with corresponding bar gray values exceeding a preset light spot threshold exist in pixel points corresponding to the character;
when it is determined that pixel points with the corresponding gray value exceeding a preset light spot threshold exist in the pixel points corresponding to the character, determining the number of the pixel points with the corresponding gray value exceeding the preset light spot threshold in the pixel points corresponding to the character as a first number;
determining the number of pixel points of which the corresponding gray value does not exceed a preset light spot threshold value in pixel points corresponding to the character as a second number;
determining a confidence coefficient corresponding to each character corresponding to the target bar code as an initial confidence coefficient based on the first number and the second number corresponding to the character;
and determining the target confidence corresponding to the target bar code based on the initial confidence corresponding to each character corresponding to the target bar code.
It can be understood that the electronic device may determine, based on the gray value of the pixel point corresponding to the bar in the target barcode, the light spot information corresponding to the target barcode, that is, whether a light spot occurs in the target barcode, and when it is determined that the light spot occurs, the light spot occurs. Specifically, the larger the gray value of the pixel points corresponding to the bars in the target bar code is, and the larger the number of the pixel points larger than 0 is, the more serious the light spots appear in the target bar code.
The electronic equipment can count whether pixel points with corresponding bar gray values exceeding a preset light spot threshold exist in pixel points corresponding to a target bar code or not aiming at each character corresponding to the target bar code, namely whether pixel points with corresponding bar gray values exceeding the preset light spot threshold exist in the pixel points corresponding to the bar code corresponding to the character or not, and when the pixel points exist, the number of the pixel points with the corresponding bar gray values exceeding the preset light spot threshold is determined to serve as a first number; and determining the number of pixel points of which the corresponding gray value does not exceed the preset light spot threshold value as a second number. Further, the process of determining the confidence corresponding to the character based on the determined first number and second number as the initial confidence may be: determining a confidence corresponding to the character as an initial confidence based on a preset initial confidence calculation formula, the determined first number and the second number, wherein the preset initial confidence calculation formula may be:
wherein, Z isiAnd identifying an initial confidence corresponding to the ith character corresponding to the target bar code, wherein A identifies a first number corresponding to the ith character, and B identifies a second number corresponding to the ith character. Wherein the severity of the occurrence of the light spot by the bar space corresponding to the character is inversely proportional to the initial confidence level corresponding to the character, whereinThe severity of the occurrence of flare in the target bar code: the first number can be used to characterize the target bar code, and the larger the first number, the more severe the light spot appears on the target bar code.
The preset light spot threshold may be a value set according to an actual situation. It will be appreciated that the barcode will have a light spot that is relatively bright at a location where the pixel point is closer to white, and in one case, the predetermined light spot threshold may be 200.
In one case, a gray level histogram corresponding to the character can be drawn based on the determined first number and the second number corresponding to the character; the number of the gray level histograms can be identified on the vertical axis, the gray level values can be identified on the horizontal axis, and the gray level histograms can identify: the number of pixels having a certain gray scale value among the pixels corresponding to the characters.
When no light spot appears in the bar corresponding to the character, no pixel exceeding a preset light spot threshold exists in the pixel corresponding to the bar corresponding to the character, and the corresponding gray histogram can show unimodal property, as shown in the left diagram in fig. 3B. When light spots appear in the bars corresponding to the characters, pixel points exceeding a preset light spot threshold exist in the pixel points corresponding to the bars corresponding to the characters, and the corresponding gray level histogram can show double peaks, as shown in the right graph in fig. 3B.
In the embodiment of the present invention, after the electronic device determines the initial confidence corresponding to each character corresponding to the target barcode, the electronic device may determine the target confidence corresponding to the target barcode based on the initial confidence corresponding to each character corresponding to the target barcode. In one case, the electronic device may determine the target confidence corresponding to the target barcode based on a preset first target confidence calculation formula and the initial confidence corresponding to all characters corresponding to the target barcode, and specifically, may calculate an average value of the initial confidence corresponding to all characters, and use the calculated average value as the target confidence. The first target confidence calculation formula may be:
wherein, Q is1Identifying a target confidence level corresponding to the target bar code, Z aboveiAnd identifying the initial confidence corresponding to the ith character corresponding to the target bar code, wherein n identifies the number of the characters corresponding to the target bar code.
In another case, the electronic device may filter out, from the determined initial confidence degrees corresponding to all characters corresponding to the target barcode, an initial confidence degree with a minimum or maximum corresponding value as a target confidence degree corresponding to the target barcode based on the user's requirement.
In another case, the electronic device may use the initial confidence level with the largest number as the target confidence level corresponding to the target barcode based on the determined initial confidence levels corresponding to all characters corresponding to the target barcode, the number of initial confidence levels with the same statistics, and the target confidence level corresponding to the target barcode.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the fuzzy degree corresponding to the bar code,
the electronic device can determine the fuzzy degree of the target bar code through the bar gray values corresponding to all the bars corresponding to the target bar code and the preset accuracy evaluation rule, and further determine the target confidence coefficient corresponding to the target bar code based on the determined fuzzy degree of the target bar code. Specifically, the step of determining the target confidence corresponding to the target barcode based on the bar gray value and/or the empty gray value and the preset accuracy evaluation rule may include:
calculating an average value of the bar gray values, namely a first average value;
counting the number of pixel points corresponding to all bars in the target bar code as a third number;
and counting the number of pixel points of the corresponding gray value in a first preset range as a fourth number, wherein the first preset range is as follows: a range determined based on the first average;
and determining the target confidence corresponding to the target bar code based on the third number and the fourth number.
The upper limit of the first predetermined range may be greater than the first average value, and the lower limit of the first predetermined range may be less than the first average value. In one case, the first predetermined range may be [ ae ]1,be1]Wherein a and b respectively identify preset coefficients, and e1Identifying a first average value, a being a positive number less than 1 and b being greater than 1, for example: a is 0.9 and b is 1.1.
In the embodiment of the present invention, the electronic device may first calculate an average value of all the gray values as a first average value, and then determine a first preset range based on the first average value; counting the number of pixel points corresponding to all bars in the target bar code to be used as a third number, counting the number of pixel points corresponding to all bars in the target bar code, wherein the gray value of the corresponding bar is within a first preset range, and the number is used as a fourth number, and further determining the target confidence coefficient corresponding to the target bar code based on the third number and the fourth number, wherein the third number and the fourth number can represent the fuzzy degree of the target bar code, and the larger the ratio of the fourth number to the third number is, the smaller the fuzzy degree of the target bar code is.
In one case, the process of determining the target confidence corresponding to the target barcode based on the third number and the fourth number may be: and determining the target confidence corresponding to the target bar code based on a preset second target confidence calculation formula, the third number and the fourth number. The second target confidence coefficient calculation formula may be:
wherein, Q is2Identifying a target confidence level corresponding to the target barcode, C above1Identifying a third number, C2A fourth number is identified. Wherein the degree of blurring of the target barcode is inversely proportional to the target confidence corresponding to the target barcode.
Theoretically, the degree of blurring of the target barcode may also be determined by the blank gray values corresponding to all the blanks corresponding to the target barcode. The specific determination process is similar to the determination process for determining the blur degree of the target barcode based on the bar gray values corresponding to all the bars corresponding to the target barcode, and is not described herein again.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the contamination degree corresponding to the bar code,
determining a gray value of each pixel point corresponding to each bar from the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining a gray value of each pixel point corresponding to each space from the target bar code based on the position information corresponding to each space in the target bar code, wherein the step of determining the gray value as the space gray value may include:
aiming at each bar in the target bar code, determining a pixel point at the central position from the pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the pixel point as a bar central pixel point;
aiming at each bar in the target bar code, determining the gray value of the pixel point in the row where the central pixel point of the bar corresponding to the bar is located from the pixel point corresponding to the bar based on the position information corresponding to the bar, and taking the gray value as a first gray value;
aiming at each space in the target bar code, determining a pixel point at the central position from pixel points corresponding to the space based on the position information corresponding to the space, and taking the pixel point as a hollow central pixel point;
aiming at each space in the target bar code, determining the gray value of the pixel point in the row where the hollow center pixel point corresponding to the space is located from the pixel point corresponding to the bar based on the position information corresponding to the space, and taking the gray value as a second gray value;
the step of determining the target confidence corresponding to the target barcode based on the barcode value and/or the empty barcode value and the preset accuracy evaluation rule may include:
calculating the average value of the gray values corresponding to each column in the target bar code as a second average value; wherein, when the column is: when the strip center pixel points corresponding to the strips are in the row, the gray value is as follows: a first gray value of a pixel point in a row where a strip center pixel point corresponding to the strip is located; when the column is: when the empty corresponding empty center pixel point is in the column, the gray value is: a second gray value of a pixel point in the row where the empty center pixel point corresponding to the space is located;
counting the number of pixel points corresponding to each column in the target bar code as a fifth number; and counting the number of pixel points of which the corresponding gray values are within a second preset range in the pixel points corresponding to the row as a sixth number, wherein the second preset range is as follows: a range determined based on the second average value corresponding to the column;
determining the confidence degree corresponding to each column in the target bar code as a standby confidence degree based on the fifth number and the sixth number;
and determining the target confidence corresponding to the target bar code based on the standby confidence corresponding to each column.
The electronic equipment can determine whether the target bar code is stained or not through gray values of pixel points corresponding to bars and spaces in the target bar code and a preset accuracy evaluation rule, determines the stained degree of the stained when the stained degree is determined to appear, and further determines the target confidence coefficient corresponding to the target bar code according to the determined stained degree. In one case, in order to save the operation burden of the electronic device, it may be determined whether the target barcode is contaminated based on the gray scale value of the column pixel point where the center pixel point corresponding to the bar is located, the gray scale value of the column pixel point where the center pixel point corresponding to the empty column pixel point is located, and the preset accuracy evaluation rule, and when it is determined that contamination occurs, it is also possible to determine the contamination degree of the contamination that occurs.
In the embodiment of the invention, for convenience of description, the central pixel point corresponding to the bar in the target bar code is called a bar central pixel point, and the gray value of the pixel point in the column where the bar central pixel point is located is called a first gray value. And (3) the central pixel point corresponding to the space in the target bar code is called a space central pixel point, and the gray value of the pixel point in the column where the space central pixel point is located is called a second gray value.
The electronic device may calculate, for each column in the target barcode, an average value of the gray values corresponding to the column as a second average value; wherein the column may be: the row of the strip center pixel points corresponding to the strip or the row of the empty center pixel points corresponding to the empty center pixel points;
the electronic equipment determines a second preset range corresponding to each column based on the second average value calculated for each column; wherein the second preset range is as follows: a range determined based on the second average value corresponding to the column; the upper limit of the second predetermined range may be greater than the second average value, and the lower limit of the second predetermined range may be less than the second average value. In one case, the second predetermined range may be [ e ]2-ε1,e2+ε2]Wherein, the above-mentioned ε1And ε2Respectively identify preset constant values, e2Identifying a second mean value, e1And ε2Are all positive numbers;
further, the electronic device counts the number of the pixel points corresponding to each column, namely the number of the pixel points contained in the column, as a fifth number; counting the number of pixel points with the corresponding gray value within a second preset range in the corresponding pixel points in the row as a sixth number;
the electronic equipment determines the standby confidence corresponding to each column based on the fifth number and the sixth number; wherein the fifth and sixth numbers are indicative of the degree of insult presented by the list; in one case, the process of determining the backup confidence corresponding to the column based on the fifth number and the sixth number may be: and determining the spare confidence corresponding to the column based on a preset spare confidence calculation formula, the fifth number and the sixth number. The spare confidence calculation formula may be:
wherein, Z isjIdentifying the alternate confidence corresponding to the jth column in the target bar code, D above1Identify the fifth number, D2The sixth number is identified. Wherein the degree of blurring of each column in the target bar code is inversely proportional to the backup confidence level corresponding to that column.
Subsequently, after the electronic device determines the spare confidence corresponding to each column in the target barcode, the target confidence corresponding to the target barcode may be determined based on the spare confidence corresponding to each column in the target barcode. In one case, the electronic device may calculate an average of the backup confidences for each column, and take the calculated average as the target confidence. In another case, the electronic device may filter out the backup confidence corresponding to each column in the determined target barcode from the backup confidence corresponding to each column in the target barcode as the target confidence corresponding to the target barcode. In another case, the electronic device may determine the backup confidence corresponding to each column in the target barcode, count the number of backup confidences with the same statistics, and use the highest number of backup confidences as the target confidence corresponding to the target barcode.
In one implementation, the respective position information of each bar and each space in the target barcode may represent respective shapes of each bar and each space in the target barcode. The electronic equipment can determine whether the target bar code is distorted or not based on the respective shapes of each bar and each space in the target bar code and a preset accuracy evaluation rule, and determine the distortion degree of the target bar code with distortion. And then the electronic equipment carries out accuracy evaluation on the decoding result of the bar code based on the determined distortion degree of the target bar code, namely, the target confidence coefficient corresponding to the target bar code is determined.
Specifically, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the distortion degree corresponding to the bar code,
the step of determining the target confidence corresponding to the target barcode based on the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target barcode may include:
determining whether the target bar code is distorted or not based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, and determining the distortion degree of the target bar code when the distortion of the target bar code is determined;
and determining the target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code.
In one implementation, the target barcode is: the bar code for which the decoding result has been determined; the target bar code comprises N rows of sub bar codes, wherein N is a positive integer; the decoding result of the target bar code comprises a plurality of characters;
each character can correspond to a plurality of bars and a plurality of spaces, and the bar and the space corresponding to each character are determined on the premise that the decoding result of the target bar code is determined;
the above-mentioned step of determining whether the target barcode has distortion or not based on the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target barcode, and determining the distortion degree of the target barcode having distortion when determining that the target barcode has distortion may include:
aiming at each character corresponding to each row of sub-bar codes in the target bar code, determining a starting position and an ending position corresponding to each character in the sub-bar codes based on the position information corresponding to each bar and each space corresponding to the character;
determining the width corresponding to each character corresponding to each row of sub-bar codes in the target bar code as an initial width based on the starting position and the ending position corresponding to the character in the sub-bar codes;
calculating the average value of the initial widths corresponding to the characters corresponding to the N rows of sub-barcodes as the average width corresponding to the characters aiming at each character corresponding to the target barcode;
for each character corresponding to the target bar code, determining a variance corresponding to the character based on the average width corresponding to the character and the initial width corresponding to the character in the N rows of sub bar codes;
the variance corresponding to the character can represent the distortion degree of the distortion of the bar space corresponding to the character, and the variance corresponding to the character is in direct proportion to the distortion degree of the distortion of the bar space corresponding to the character;
the step of determining the target confidence level corresponding to the target barcode based on the determined distortion degree of the target barcode includes:
for each character corresponding to the target bar code, determining a confidence corresponding to the character based on a preset corresponding relationship and the determined variance corresponding to the character, wherein the preset corresponding relationship comprises: corresponding relations between the variances and preset confidence degrees;
and determining a target confidence corresponding to the target bar code based on the determined confidence corresponding to each character.
In the embodiment of the present invention, the electronic device may first determine a distortion degree of each character for each character corresponding to the target barcode, and then determine a confidence degree corresponding to each character based on the determined distortion degree corresponding to each character, and further determine a target confidence degree corresponding to the target barcode based on the confidence degree corresponding to each character. The distortion degree of all the characters corresponding to the target bar code can represent the distortion degree of the target bar code.
It can be understood that when the target barcode is not distorted, each row of the bar code in the target barcode is the same, that is, each row of the bar code corresponds to the same character, and the width of each row of the bar code is the same, and in more detail, the width of the bar space corresponding to the character corresponding to each row of the bar code is the same. As shown in fig. 4, the bar space corresponding to a character is not distorted, wherein edge lines of the bar space corresponding to the character are parallel to each other, a barcode in which the bar space corresponding to the character is located is encoded into 128 codes, and in the barcode encoded into 128 codes, each character may correspond to 3 bars and 3 spaces.
The electronic equipment can determine a starting position and an ending position corresponding to each character corresponding to each row of sub-barcodes in the target barcode based on the position information corresponding to each bar and each space corresponding to the character; subsequently, the width corresponding to the character corresponding to the sub-barcode may be determined as the initial width based on the starting position and the ending position corresponding to the character; furthermore, the electronic device may calculate, for each character corresponding to the target barcode, an average value of initial widths corresponding to the character in the N rows of sub-barcodes as an average width corresponding to the character. For example, the initial widths corresponding to the characters X corresponding to the N rows of the sub-bar codes are W respectively1、W2……WN(ii) a The average width W corresponding to the character Xage=(W1+W2+……+WN)/N。
The electronic equipment determines the variance corresponding to each character corresponding to the target bar code based on the average width corresponding to the character and the initial width corresponding to the character in the N rows of sub bar codes. The above example is followed: variance corresponding to character X:
subsequently, the electronic equipment determines the confidence corresponding to each character corresponding to the target bar code based on the preset corresponding relation and the determined variance corresponding to the character; and further determining a target confidence corresponding to the target bar code based on the determined confidence corresponding to each character. The correspondence between each variance included in the preset correspondence and the preset confidence may be a one-to-one correspondence or a many-to-one correspondence.
In one case, the above process of determining the target confidence corresponding to the target barcode based on the determined confidence corresponding to each character may be: the electronic equipment calculates the average value of the confidence degrees corresponding to all the characters, and takes the calculated average value as the target confidence degree. Or, the electronic device may filter out the initial confidence coefficient corresponding to the smallest or largest numerical value from the determined initial confidence coefficients corresponding to all characters corresponding to the target barcode as the target confidence coefficient corresponding to the target barcode based on the user's requirement. Or, the electronic device may use the initial confidence coefficient with the largest number as the target confidence coefficient corresponding to the target barcode based on the determined initial confidence degrees corresponding to all characters corresponding to the target barcode, the number of initial confidence coefficients with the same statistics, and the target confidence coefficient corresponding to the target barcode.
In one implementation, when the preset accuracy evaluation rule includes: the rule is that the accuracy evaluation is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code; a rule for evaluating the accuracy of the decoding result of the bar code based on the fuzzy degree corresponding to the bar code; the rule is used for evaluating the accuracy of the decoding result of the bar code based on the fouling degree corresponding to the bar code; and, based on the degree of distortion corresponding to the bar code, at least two types of rules in the rules for evaluating the accuracy of the decoding result of the bar code;
as shown in fig. 5, the method for evaluating the decoding result of the barcode according to the embodiment of the present invention may include the steps of:
s501: acquiring the position information corresponding to each bar and each space in the target bar code;
here, S501 is the same as S201 shown in fig. 2.
S502: acquiring a weight value corresponding to each rule included in a preset accuracy evaluation rule;
s503: determining a confidence coefficient corresponding to the target bar code as an intermediate confidence coefficient based on each type of rule included in the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code;
s504: and determining a target confidence corresponding to the target bar code based on the intermediate confidence corresponding to each type of rule and the obtained weight value corresponding to each type of rule.
Wherein the target confidence is used to: and characterizing the accuracy of the decoding result of the target bar code.
It will be appreciated that in practice, many types of problems in the target barcode are not avoided, such as: and at least two problems of light spots, blurring, distortion and fouling are caused, at the moment, the accuracy of the decoding result of the target bar code can be evaluated based on multiple types of rules respectively, and further, the target confidence corresponding to the target bar code is calculated based on the evaluation result corresponding to each type of rule, namely the determined intermediate confidence corresponding to the target bar code.
Subsequently, the electronic device may determine whether to output a decoding result of the target barcode based on the determined target confidence corresponding to the target barcode.
In an implementation manner, as shown in fig. 6, the method for evaluating a decoding result of a barcode according to an embodiment of the present invention may include:
s601: acquiring the position information corresponding to each bar and each space in the target bar code;
here, S601 is the same as S201 shown in fig. 2.
S602: determining a target confidence coefficient corresponding to the target bar code based on a preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code;
wherein the target confidence is used to: and characterizing the accuracy of the decoding result of the target bar code.
S603: judging whether the target confidence coefficient is higher than a preset confidence coefficient threshold value;
s604: and when the target confidence coefficient is judged to be higher than the preset confidence coefficient threshold value, outputting a decoding result of the target bar code.
The preset confidence threshold is a value set according to actual requirements.
In the embodiment of the invention, when the electronic equipment has the function of identifying the bar code, the electronic equipment can control whether the decoding result of the target bar code is output or not through the target confidence coefficient, and when the target confidence coefficient is judged to be higher than the preset confidence coefficient threshold value, the electronic equipment outputs the decoding result of the target bar code. To a certain extent, the balance between the recognition success rate and the misrecognition rate of the target bar code can be realized. The experience of the user is better improved. In one case, the electronic device may also output a target confidence corresponding to the target barcode for reference by the user.
In one case, the preset accuracy evaluation rule includes at least two types of rules in the rules, and at this time, the electronic device may determine an evaluation result corresponding to each type of rule, that is, an intermediate confidence corresponding to the determined target barcode; judging whether the intermediate confidence coefficient is higher than a preset confidence coefficient threshold value or not aiming at each intermediate confidence coefficient; and outputting the decoding result of the target bar code only when the electronic equipment judges that all the intermediate confidence coefficients are higher than the preset confidence coefficient threshold value. So as to better realize the balance of the identification success rate and the misidentification rate of the bar code.
In one case, when the electronic device does not have a function of recognizing the barcode, the electronic device may control whether the barcode recognition apparatus outputs a decoding result of the barcode or not by the above-described target confidence. Specifically, when the target confidence is judged to be higher than the preset confidence threshold, the electronic device may control the barcode recognition device to output the decoding result of the barcode. In one case, the barcode recognition device may be further controlled to output the target confidence corresponding to the target barcode for the user to refer to.
In an implementation manner, the method for evaluating a decoding result of a barcode according to an embodiment of the present invention may further include:
when the target confidence coefficient is judged to be not higher than the preset confidence coefficient threshold value, discarding the decoding result of the target bar code; or the like, or, alternatively,
and outputting prompt information to prompt the user that the accuracy of the decoding result of the target bar code is low.
When the electronic device judges that the target confidence coefficient is not higher than the preset confidence coefficient threshold value, it can be determined that the accuracy of the decoding result of the target bar code is not high and the decoding result is not credible. In the embodiment of the invention, the electronic equipment can directly discard the decoding result of the target bar code without outputting the decoding result of the target bar code, or the electronic equipment can output prompt information to prompt a user that the accuracy of the decoding result of the target bar code is low. At this time, the user may perform corresponding operations on the target barcode, such as: and manually detecting whether the target bar code has distortion, adjusting the target bar code when the distortion is determined, or not, easily enabling the target bar code to have light spots when the target bar code is manually detected, scanned and identified, and if so, correspondingly adjusting, and the like. Through the implementation mode of the embodiment of the invention, the misrecognition rate of the bar code can be reduced to a certain extent.
Corresponding to the above method embodiment, an embodiment of the present invention further provides an evaluation apparatus for a decoding result of a barcode, and as shown in fig. 7, the apparatus may include:
a first obtaining module 710, configured to obtain respective corresponding position information of each bar and each space in the target barcode;
a determining module 720, configured to determine a target confidence corresponding to the target barcode based on a preset accuracy evaluation rule and the respective corresponding location information of each bar and each space in the target barcode, where the target confidence is used to: and characterizing the accuracy of the decoding result of the target bar code.
In the embodiment of the invention, the target confidence corresponding to the target bar code can be determined based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, namely, the accuracy of the decoding result of the target bar code can be evaluated. And the misidentification rate of the decoding result of the bar code can be controlled to a certain extent.
In one implementation, the preset accuracy evaluation rule includes: and (3) carrying out accuracy evaluation on the decoding result of the bar code based on at least one of the light spot information, the fuzzy degree, the fouling degree and the distortion degree corresponding to the bar code.
In one implementation, the determining module 720 includes
The first determining unit is used for determining the gray value of each pixel point corresponding to each bar in the target bar code as the bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as a space gray value based on the position information corresponding to each space in the target bar code;
and the second determining unit is used for determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule.
In one implementation, the target barcode is: the bar code for which the decoding result has been determined; the decoding result of the target bar code comprises a plurality of characters;
when the preset accuracy evaluation rule comprises the following steps: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code,
the first determination unit is specifically configured to
For each character corresponding to the target bar code, determining a gray value of a pixel point corresponding to each bar corresponding to the character from the target bar code as a bar gray value based on the position information corresponding to each bar corresponding to the character;
the second determination unit is specifically configured to
Determining whether pixel points with corresponding bar gray values exceeding a preset light spot threshold exist in pixel points corresponding to the characters aiming at each character corresponding to the target bar code;
when determining that pixel points with the corresponding gray value exceeding a preset light spot threshold exist in the pixel points corresponding to the character, determining the number of the pixel points with the corresponding gray value exceeding the preset light spot threshold in the pixel points corresponding to the character as a first number;
determining the number of pixel points of which the corresponding gray values do not exceed the preset light spot threshold value in the pixel points corresponding to the character as a second number;
determining a confidence coefficient corresponding to each character corresponding to the target bar code as an initial confidence coefficient based on the first number and the second number corresponding to the character;
and determining a target confidence corresponding to the target bar code based on the initial confidence corresponding to each character corresponding to the target bar code.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the fuzzy degree corresponding to the bar code,
the second determination unit is specifically configured to
Calculating an average value of the gray values, namely a first average value;
counting the number of pixel points corresponding to all the bars in the target bar code to be used as a third number;
and counting the number of pixel points of the corresponding gray value in a first preset range as a fourth number, wherein the first preset range is as follows: a range determined based on the first average;
and determining a target confidence degree corresponding to the target bar code based on the third number and the fourth number.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the contamination degree corresponding to the bar code,
the first determination unit is specifically configured to
Aiming at each bar in the target bar code, determining a pixel point at the central position from pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the pixel point as a bar central pixel point;
for each bar in the target bar code, determining the gray value of the pixel point in the column where the bar center pixel point corresponding to the bar is located from the pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the gray value as a first gray value;
aiming at each space in the target bar code, determining a pixel point at a central position from pixel points corresponding to the space based on the position information corresponding to the space, and taking the pixel point as a hollow central pixel point;
aiming at each space in the target bar code, determining the gray value of the pixel point in the row where the hollow center pixel point corresponding to the space is located from the pixel point corresponding to the bar based on the position information corresponding to the space, and taking the gray value as a second gray value;
the second determination unit is specifically configured to
Calculating the average value of the gray values corresponding to each column in the target bar code as a second average value; wherein, when the column is: when the strip center pixel points corresponding to the strips are in the row, the gray value is as follows: a first gray value of a pixel point in a row where a strip center pixel point corresponding to the strip is located; when the column is: when the empty center pixel points corresponding to the empty pixel points are in the row, the gray value is as follows: a second gray value of the pixel point of the row where the empty center pixel point corresponding to the space is located;
counting the number of pixel points corresponding to each column in the target bar code as a fifth number; and counting the number of pixel points of which the corresponding gray values are within a second preset range in the pixel points corresponding to the row as a sixth number, wherein the second preset range is as follows: a range determined based on the second average value corresponding to the column;
for each column in the target bar code, determining a confidence coefficient corresponding to the column based on the fifth number and the sixth number, and taking the confidence coefficient as a standby confidence coefficient;
and determining the target confidence corresponding to the target bar code based on the standby confidence corresponding to each column.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the distortion degree corresponding to the bar code,
the determining module 720 comprises
A third determining unit, configured to determine whether the target barcode is distorted based on a preset accuracy evaluation rule and respective corresponding position information of each bar and each space in the target barcode, and determine a distortion degree of the target barcode when the target barcode is determined to be distorted;
and the fourth determining unit is used for determining the target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code.
In one implementation, the target barcode is: the bar code for which the decoding result has been determined; the target bar code comprises N rows of sub-bar codes, wherein N is a positive integer; the decoding result of the target bar code comprises a plurality of characters;
the third determination unit is specifically configured to
For each character corresponding to each row of sub-barcodes in the target barcode, determining a starting position and an ending position corresponding to each character corresponding to the sub-barcode based on the position information corresponding to each bar and each space corresponding to the character;
for each character corresponding to each row of sub-bar codes in the target bar code, determining the width corresponding to the character corresponding to the sub-bar code as an initial width based on the starting position and the ending position corresponding to the character in the sub-bar code;
calculating the average value of the initial widths corresponding to the characters in the N rows of sub-bar codes as the average width corresponding to the characters aiming at each character corresponding to the target bar code;
for each character corresponding to the target bar code, determining a variance corresponding to the character based on the average width corresponding to the character and the initial width corresponding to the character in the N rows of sub bar codes, wherein the variance corresponding to the character is in direct proportion to the distortion degree of the bar space corresponding to the character;
the fourth determination unit is specifically configured to
For each character corresponding to the target bar code, determining a confidence corresponding to the character based on a preset corresponding relationship and the determined variance corresponding to the character, wherein the preset corresponding relationship comprises: corresponding relations between the variances and preset confidence degrees;
and determining the target confidence corresponding to the target bar code based on the determined confidence corresponding to each character.
In one implementation, when the preset accuracy evaluation rule includes: the rule is that the accuracy evaluation is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code; a rule for evaluating the accuracy of the decoding result of the bar code based on the fuzzy degree corresponding to the bar code; the rule is used for evaluating the accuracy of the decoding result of the bar code based on the fouling degree corresponding to the bar code; and, based on the degree of distortion corresponding to the bar code, at least two types of rules in the rules for evaluating the accuracy of the decoding result of the bar code;
the device further comprises:
a second obtaining module, configured to obtain a weight value corresponding to each type of rule included in the preset accuracy evaluation rule before determining a target confidence level corresponding to the target barcode based on the preset accuracy evaluation rule and the respective corresponding location information of each bar and each space in the target barcode;
the determining module 720 is used for
Determining a confidence coefficient corresponding to the target bar code as an intermediate confidence coefficient based on each type of rule included in the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code;
and determining the target confidence corresponding to the target bar code based on the intermediate confidence corresponding to each type of rule and the obtained weight value corresponding to each type of rule.
In one implementation, the apparatus further comprises:
the judging module is used for judging whether the target confidence coefficient is higher than a preset confidence coefficient threshold value or not after the target confidence coefficient corresponding to the target bar code is determined based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code;
and the first output module is used for outputting the decoding result of the target bar code when the target confidence coefficient is judged to be higher than the preset confidence coefficient threshold value.
In one implementation, the apparatus further comprises:
the discarding module is used for discarding the decoding result of the target bar code when the target confidence coefficient is judged not to be higher than the preset confidence coefficient threshold value; or the like, or, alternatively,
and the second output module is used for outputting prompt information to prompt a user that the accuracy of the decoding result of the target bar code is low.
Corresponding to the above method embodiments, the embodiment of the present invention further provides an electronic device, as shown in fig. 8, including a processor 810, a communication interface 820, a memory 830 and a communication bus 840, where the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840,
a memory 830 for storing a computer program;
the processor 810, when executing the computer program stored in the memory 830, may be configured to implement any method for evaluating a decoding result of a barcode provided by the embodiment of the present invention, and may include the steps of:
acquiring the position information corresponding to each bar and each space in the target bar code;
determining a target confidence corresponding to the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, wherein the target confidence is used for: and characterizing the accuracy of the decoding result of the target bar code.
In the embodiment of the invention, the target confidence corresponding to the target bar code can be determined based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, namely, the accuracy of the decoding result of the target bar code can be evaluated. And the misidentification rate of the decoding result of the bar code can be controlled to a certain extent.
In one implementation, as shown in fig. 9, the method further includes
A camera 850 for scanning a target bar code;
and a display 860 for displaying the decoding result of the target bar code.
In one implementation, the preset accuracy evaluation rule includes: and (3) carrying out accuracy evaluation on the decoding result of the bar code based on at least one of the light spot information, the fuzzy degree, the fouling degree and the distortion degree corresponding to the bar code.
In one implementation manner, the step of determining the target confidence level corresponding to the target barcode based on a preset accuracy evaluation rule and the respective corresponding location information of each bar and each space in the target barcode includes:
determining the gray value of each pixel point corresponding to each bar in the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as a space gray value based on the position information corresponding to each space in the target bar code;
and determining a target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule.
In one implementation, the target barcode is: the bar code for which the decoding result has been determined; the decoding result of the target bar code comprises a plurality of characters;
when the preset accuracy evaluation rule comprises the following steps: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code,
determining a gray value of each pixel point corresponding to each bar from the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as the space gray value based on the position information corresponding to each space in the target bar code, wherein the step of determining the gray value of each pixel point corresponding to each space as the space gray value comprises the following steps:
for each character corresponding to the target bar code, determining a gray value of a pixel point corresponding to each bar corresponding to the character from the target bar code as a bar gray value based on the position information corresponding to each bar corresponding to the character;
the step of determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule comprises:
determining whether pixel points with corresponding bar gray values exceeding a preset light spot threshold exist in pixel points corresponding to the characters aiming at each character corresponding to the target bar code;
when determining that pixel points with the corresponding gray value exceeding a preset light spot threshold exist in the pixel points corresponding to the character, determining the number of the pixel points with the corresponding gray value exceeding the preset light spot threshold in the pixel points corresponding to the character as a first number;
determining the number of pixel points of which the corresponding gray values do not exceed the preset light spot threshold value in the pixel points corresponding to the character as a second number;
determining a confidence coefficient corresponding to each character corresponding to the target bar code as an initial confidence coefficient based on the first number and the second number corresponding to the character;
and determining a target confidence corresponding to the target bar code based on the initial confidence corresponding to each character corresponding to the target bar code.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the fuzzy degree corresponding to the bar code,
the step of determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule comprises:
calculating an average value of the gray values, namely a first average value;
counting the number of pixel points corresponding to all the bars in the target bar code to be used as a third number;
and counting the number of pixel points of the corresponding gray value in a first preset range as a fourth number, wherein the first preset range is as follows: a range determined based on the first average;
and determining a target confidence degree corresponding to the target bar code based on the third number and the fourth number.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the contamination degree corresponding to the bar code,
determining a gray value of each pixel point corresponding to each bar from the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as the space gray value based on the position information corresponding to each space in the target bar code, wherein the step of determining the gray value of each pixel point corresponding to each space as the space gray value comprises the following steps:
aiming at each bar in the target bar code, determining a pixel point at the central position from pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the pixel point as a bar central pixel point;
for each bar in the target bar code, determining the gray value of the pixel point in the column where the bar center pixel point corresponding to the bar is located from the pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the gray value as a first gray value;
aiming at each space in the target bar code, determining a pixel point at a central position from pixel points corresponding to the space based on the position information corresponding to the space, and taking the pixel point as a hollow central pixel point;
aiming at each space in the target bar code, determining the gray value of the pixel point in the row where the hollow center pixel point corresponding to the space is located from the pixel point corresponding to the bar based on the position information corresponding to the space, and taking the gray value as a second gray value;
the step of determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule comprises:
calculating the average value of the gray values corresponding to each column in the target bar code as a second average value; wherein, when the column is: when the strip center pixel points corresponding to the strips are in the row, the gray value is as follows: a first gray value of a pixel point in a row where a strip center pixel point corresponding to the strip is located; when the column is: when the empty center pixel points corresponding to the empty pixel points are in the row, the gray value is as follows: a second gray value of the pixel point of the row where the empty center pixel point corresponding to the space is located;
counting the number of pixel points corresponding to each column in the target bar code as a fifth number; and counting the number of pixel points of which the corresponding gray values are within a second preset range in the pixel points corresponding to the row as a sixth number, wherein the second preset range is as follows: a range determined based on the second average value corresponding to the column;
for each column in the target bar code, determining a confidence coefficient corresponding to the column based on the fifth number and the sixth number, and taking the confidence coefficient as a standby confidence coefficient;
and determining the target confidence corresponding to the target bar code based on the standby confidence corresponding to each column.
In one implementation, when the preset accuracy evaluation rule includes: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the distortion degree corresponding to the bar code,
the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code comprises the following steps:
determining whether the target bar code is distorted or not based on a preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, and determining the distortion degree of the target bar code when the target bar code is determined to be distorted;
and determining a target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code.
In one implementation, the target barcode is: the bar code for which the decoding result has been determined; the target bar code comprises N rows of sub-bar codes, wherein N is a positive integer; the decoding result of the target bar code comprises a plurality of characters;
the step of determining whether the target bar code is distorted or not based on a preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, and determining the distorted distortion degree of the target bar code when the target bar code is determined to be distorted, comprises the following steps of:
for each character corresponding to each row of sub-barcodes in the target barcode, determining a starting position and an ending position corresponding to each character corresponding to the sub-barcode based on the position information corresponding to each bar and each space corresponding to the character;
for each character corresponding to each row of sub-bar codes in the target bar code, determining the width corresponding to the character corresponding to the sub-bar code as an initial width based on the starting position and the ending position corresponding to the character in the sub-bar code;
calculating the average value of the initial widths corresponding to the characters in the N rows of sub-bar codes as the average width corresponding to the characters aiming at each character corresponding to the target bar code;
for each character corresponding to the target bar code, determining a variance corresponding to the character based on the average width corresponding to the character and the initial width corresponding to the character in the N rows of sub bar codes, wherein the variance corresponding to the character is in direct proportion to the distortion degree of the bar space corresponding to the character;
the step of determining a target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code comprises:
for each character corresponding to the target bar code, determining a confidence corresponding to the character based on a preset corresponding relationship and the determined variance corresponding to the character, wherein the preset corresponding relationship comprises: corresponding relations between the variances and preset confidence degrees;
and determining the target confidence corresponding to the target bar code based on the determined confidence corresponding to each character.
In one implementation, when the preset accuracy evaluation rule includes: the rule is that the accuracy evaluation is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code; a rule for evaluating the accuracy of the decoding result of the bar code based on the fuzzy degree corresponding to the bar code; the rule is used for evaluating the accuracy of the decoding result of the bar code based on the fouling degree corresponding to the bar code; and, based on the degree of distortion corresponding to the bar code, at least two types of rules in the rules for evaluating the accuracy of the decoding result of the bar code;
the memory 830 is further configured to implement the steps of: before the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, acquiring a weight value corresponding to each type of rule included in the preset accuracy evaluation rule;
the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code comprises the following steps:
determining a confidence coefficient corresponding to the target bar code as an intermediate confidence coefficient based on each type of rule included in the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code;
and determining the target confidence corresponding to the target bar code based on the intermediate confidence corresponding to each type of rule and the obtained weight value corresponding to each type of rule.
In one implementation, the memory 830 is further configured to implement the following steps: after the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code, judging whether the target confidence is higher than a preset confidence threshold value;
and when the target confidence coefficient is judged to be higher than the preset confidence coefficient threshold value, outputting a decoding result of the target bar code.
In one implementation, the memory 830 is further configured to implement the following steps:
when the target confidence is judged not to be higher than the preset confidence threshold, discarding the decoding result of the target bar code; or the like, or, alternatively,
and outputting prompt information to prompt a user that the accuracy of the decoding result of the target bar code is low.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
Corresponding to the above method embodiments, the embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method for evaluating a decoding result of a barcode according to any one of the steps provided in the embodiment of the present invention is implemented.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and similar parts between the embodiments may be referred to each other, and each embodiment focuses on differences from other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Claims (25)
1. A method for evaluating a decoding result of a barcode, the method comprising:
acquiring the position information corresponding to each bar and each space in the target bar code;
determining a target confidence coefficient corresponding to the target bar code based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, wherein the target confidence coefficient is used for: and characterizing the accuracy of the decoding result of the target bar code.
2. The method according to claim 1, wherein the preset accuracy evaluation rule comprises: and the rule is used for evaluating the accuracy of the decoding result of the bar code based on at least one of the spot information, the fuzzy degree, the fouling degree and the distortion degree corresponding to the bar code.
3. The method according to claim 1 or 2, wherein the step of determining the target confidence corresponding to the target barcode based on a preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target barcode comprises:
determining the gray value of each pixel point corresponding to each bar in the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as a space gray value based on the position information corresponding to each space in the target bar code;
and determining a target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule.
4. The method of claim 3, wherein the target barcode is: the bar code for which the decoding result has been determined; the decoding result of the target bar code comprises a plurality of characters;
when the preset accuracy evaluation rule comprises the following steps: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code,
determining a gray value of each pixel point corresponding to each bar from the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as the space gray value based on the position information corresponding to each space in the target bar code, wherein the step of determining the gray value of each pixel point corresponding to each space as the space gray value comprises the following steps:
for each character corresponding to the target bar code, determining a gray value of a pixel point corresponding to each bar corresponding to the character from the target bar code as a bar gray value based on the position information corresponding to each bar corresponding to the character;
the step of determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule comprises:
determining whether pixel points with corresponding bar gray values exceeding a preset light spot threshold exist in pixel points corresponding to the characters aiming at each character corresponding to the target bar code;
when determining that pixel points with the corresponding gray value exceeding a preset light spot threshold exist in the pixel points corresponding to the character, determining the number of the pixel points with the corresponding gray value exceeding the preset light spot threshold in the pixel points corresponding to the character as a first number;
determining the number of pixel points of which the corresponding gray values do not exceed the preset light spot threshold value in the pixel points corresponding to the character as a second number;
for each character corresponding to the target bar code, determining a confidence coefficient corresponding to the character as an initial confidence coefficient based on a first number and a second number corresponding to the character;
and determining a target confidence corresponding to the target bar code based on the initial confidence corresponding to each character corresponding to the target bar code.
5. The method according to claim 3, wherein when the preset accuracy evaluation rule comprises: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the fuzzy degree corresponding to the bar code,
the step of determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule comprises:
calculating an average value of the gray values, namely a first average value;
counting the number of pixel points corresponding to all the bars in the target bar code to be used as a third number;
and counting the number of pixel points of the corresponding gray value in a first preset range as a fourth number, wherein the first preset range is as follows: a range determined based on the first average;
and determining a target confidence corresponding to the target bar code based on the third number and the fourth number.
6. The method according to claim 3, wherein when the preset accuracy evaluation rule comprises: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the contamination degree corresponding to the bar code,
determining a gray value of each pixel point corresponding to each bar from the target bar code as a bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as the space gray value based on the position information corresponding to each space in the target bar code, wherein the step of determining the gray value of each pixel point corresponding to each space as the space gray value comprises the following steps:
aiming at each bar in the target bar code, determining a pixel point at the central position from pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the pixel point as a bar central pixel point;
for each bar in the target bar code, determining the gray value of the pixel point in the column where the bar center pixel point corresponding to the bar is located from the pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the gray value as a first gray value;
aiming at each space in the target bar code, determining a pixel point at a central position from pixel points corresponding to the space based on the position information corresponding to the space, and taking the pixel point as a hollow central pixel point;
aiming at each space in the target bar code, determining the gray value of the pixel point in the row where the hollow center pixel point corresponding to the space is located from the pixel points corresponding to the bar based on the position information corresponding to the space, and taking the gray value as a second gray value;
the step of determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule comprises:
calculating the average value of the gray values corresponding to each column in the target bar code as a second average value; wherein, when the column is: when the strip center pixel points corresponding to the strips are in the row, the gray value is as follows: a first gray value of a pixel point in a row where a strip center pixel point corresponding to the strip is located; when the column is: when the empty center pixel points corresponding to the empty pixel points are in the row, the gray value is as follows: a second gray value of a pixel point of the row where the empty center pixel point corresponding to the space is located;
counting the number of pixel points corresponding to each column in the target bar code as a fifth number; and counting the number of pixel points of which the corresponding gray values are within a second preset range in the pixel points corresponding to the row as a sixth number, wherein the second preset range is as follows: a range determined based on the second average value corresponding to the column;
for each column in the target bar code, determining a confidence coefficient corresponding to the column based on the fifth number and the sixth number, and taking the confidence coefficient as a standby confidence coefficient;
and determining the target confidence corresponding to the target bar code based on the standby confidence corresponding to each column.
7. The method according to claim 3, wherein when the preset accuracy evaluation rule comprises: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the distortion degree corresponding to the bar code,
the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code comprises the following steps:
determining whether the target bar code is distorted or not based on a preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, and determining the distortion degree of the target bar code when the distortion of the target bar code is determined;
and determining a target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code.
8. The method of claim 7, wherein the target barcode is: the bar code for which the decoding result has been determined; the target bar code comprises N rows of sub bar codes, wherein N is a positive integer; the decoding result of the target bar code comprises a plurality of characters;
the method comprises the following steps of determining whether the target bar code is distorted or not based on preset accuracy evaluation rules and the position information corresponding to each bar and each space in the target bar code, and determining the distortion degree of the distorted target bar code when the distorted target bar code is determined to be distorted, wherein the steps comprise:
for each character corresponding to each row of sub-barcodes in the target barcode, determining a starting position and an ending position corresponding to each character corresponding to the sub-barcode based on the position information corresponding to each bar and each space corresponding to the character;
for each character corresponding to each row of sub-bar codes in the target bar code, determining the width corresponding to the character corresponding to the sub-bar code as an initial width based on the starting position and the ending position corresponding to the character in the sub-bar code;
calculating the average value of the initial widths corresponding to the characters in the N rows of sub-bar codes as the average width corresponding to the characters aiming at each character corresponding to the target bar code;
for each character corresponding to the target bar code, determining a variance corresponding to the character based on the average width corresponding to the character and the initial width corresponding to the character in the N rows of sub bar codes, wherein the variance corresponding to the character is in direct proportion to the distortion degree of the bar space corresponding to the character;
the step of determining a target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code comprises:
for each character corresponding to the target bar code, determining a confidence corresponding to the character based on a preset corresponding relationship and the determined variance corresponding to the character, wherein the preset corresponding relationship comprises: corresponding relations between the variances and preset confidence degrees;
and determining a target confidence corresponding to the target bar code based on the determined confidence corresponding to each character.
9. The method according to claim 1, wherein when the preset accuracy evaluation rule comprises: the rule is that the accuracy evaluation is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code; based on the fuzzy degree corresponding to the bar code, the accuracy evaluation rule is carried out on the decoding result of the bar code; the rule is used for evaluating the accuracy of the decoding result of the bar code based on the fouling degree corresponding to the bar code; and, based on the distortion degree corresponding to the bar code, at least two types of rules in the rules for evaluating the accuracy of the decoding result of the bar code;
before the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code, the method further includes:
acquiring a weight value corresponding to each rule included in the preset accuracy evaluation rule;
the step of determining the target confidence corresponding to the target bar code based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code comprises the following steps:
determining a confidence coefficient corresponding to the target bar code as an intermediate confidence coefficient based on each type of rule included in the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code;
and determining a target confidence corresponding to the target bar code based on the intermediate confidence corresponding to each type of rule and the obtained weight value corresponding to each type of rule.
10. The method according to claim 1, wherein after the step of determining the target confidence corresponding to the target barcode based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target barcode, the method further comprises:
judging whether the target confidence coefficient is higher than a preset confidence coefficient threshold value;
and when the target confidence coefficient is judged to be higher than the preset confidence coefficient threshold value, outputting a decoding result of the target bar code.
11. The method of claim 10, further comprising:
when the target confidence coefficient is judged not to be higher than the preset confidence coefficient threshold value, discarding the decoding result of the target bar code; or the like, or, alternatively,
and outputting prompt information to prompt a user that the accuracy of the decoding result of the target bar code is low.
12. An apparatus for evaluating a decoding result of a barcode, the apparatus comprising:
the first acquisition module is used for acquiring the position information corresponding to each bar and each space in the target bar code;
a determining module, configured to determine a target confidence corresponding to the target barcode based on a preset accuracy evaluation rule and respective corresponding location information of each bar and each space in the target barcode, where the target confidence is used to: and characterizing the accuracy of the decoding result of the target bar code.
13. The apparatus according to claim 12, wherein the preset accuracy evaluation rule comprises: and the rule is used for evaluating the accuracy of the decoding result of the bar code based on at least one of the spot information, the fuzzy degree, the fouling degree and the distortion degree corresponding to the bar code.
14. The apparatus of claim 12 or 13, wherein the determining means comprises
The first determining unit is used for determining the gray value of each pixel point corresponding to each bar in the target bar code as the bar gray value based on the position information corresponding to each bar in the target bar code; and/or determining the gray value of each pixel point corresponding to each space from the target bar code as a space gray value based on the position information corresponding to each space in the target bar code;
and the second determining unit is used for determining the target confidence corresponding to the target bar code based on the bar gray value and/or the empty gray value and a preset accuracy evaluation rule.
15. The apparatus of claim 14, wherein the target bar code is: the bar code for which the decoding result has been determined; the decoding result of the target bar code comprises a plurality of characters;
when the preset accuracy evaluation rule comprises the following steps: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code,
the first determination unit is specifically configured to
For each character corresponding to the target bar code, determining a gray value of a pixel point corresponding to each bar corresponding to the character from the target bar code as a bar gray value based on the position information corresponding to each bar corresponding to the character;
the second determination unit is specifically configured to
Determining whether pixel points with corresponding bar gray values exceeding a preset light spot threshold exist in pixel points corresponding to the characters aiming at each character corresponding to the target bar code;
when determining that pixel points with the corresponding gray value exceeding a preset light spot threshold exist in the pixel points corresponding to the character, determining the number of the pixel points with the corresponding gray value exceeding the preset light spot threshold in the pixel points corresponding to the character as a first number;
determining the number of pixel points of which the corresponding gray values do not exceed the preset light spot threshold value in the pixel points corresponding to the character as a second number;
for each character corresponding to the target bar code, determining a confidence coefficient corresponding to the character as an initial confidence coefficient based on a first number and a second number corresponding to the character;
and determining a target confidence corresponding to the target bar code based on the initial confidence corresponding to each character corresponding to the target bar code.
16. The apparatus according to claim 14, wherein when the preset accuracy evaluation rule comprises: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the fuzzy degree corresponding to the bar code,
the second determination unit is specifically configured to
Calculating an average value of the gray values, namely a first average value;
counting the number of pixel points corresponding to all the bars in the target bar code to be used as a third number;
and counting the number of pixel points of the corresponding gray value in a first preset range as a fourth number, wherein the first preset range is as follows: a range determined based on the first average;
and determining a target confidence corresponding to the target bar code based on the third number and the fourth number.
17. The apparatus according to claim 14, wherein when the preset accuracy evaluation rule comprises: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the contamination degree corresponding to the bar code,
the first determination unit is specifically configured to
Aiming at each bar in the target bar code, determining a pixel point at the central position from pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the pixel point as a bar central pixel point;
for each bar in the target bar code, determining the gray value of the pixel point in the column where the bar center pixel point corresponding to the bar is located from the pixel points corresponding to the bar based on the position information corresponding to the bar, and taking the gray value as a first gray value;
aiming at each space in the target bar code, determining a pixel point at a central position from pixel points corresponding to the space based on the position information corresponding to the space, and taking the pixel point as a hollow central pixel point;
aiming at each space in the target bar code, determining the gray value of the pixel point in the row where the hollow center pixel point corresponding to the space is located from the pixel points corresponding to the bar based on the position information corresponding to the space, and taking the gray value as a second gray value;
the second determination unit is specifically configured to
Calculating the average value of the gray values corresponding to each column in the target bar code as a second average value; wherein, when the column is: when the strip center pixel points corresponding to the strips are in the row, the gray value is as follows: a first gray value of a pixel point in a row where a strip center pixel point corresponding to the strip is located; when the column is: when the empty center pixel points corresponding to the empty pixel points are in the row, the gray value is as follows: a second gray value of a pixel point of the row where the empty center pixel point corresponding to the space is located;
counting the number of pixel points corresponding to each column in the target bar code as a fifth number; and counting the number of pixel points of which the corresponding gray values are within a second preset range in the pixel points corresponding to the row as a sixth number, wherein the second preset range is as follows: a range determined based on the second average value corresponding to the column;
for each column in the target bar code, determining a confidence coefficient corresponding to the column based on the fifth number and the sixth number, and taking the confidence coefficient as a standby confidence coefficient;
and determining the target confidence corresponding to the target bar code based on the standby confidence corresponding to each column.
18. The apparatus according to claim 14, wherein when the preset accuracy evaluation rule comprises: when the accuracy evaluation rule is carried out on the decoding result of the bar code based on the distortion degree corresponding to the bar code,
the determination module comprises
A third determining unit, configured to determine whether the target barcode is distorted based on a preset accuracy evaluation rule and respective corresponding position information of each bar and each space in the target barcode, and determine a distortion degree of the target barcode when the target barcode is determined to be distorted;
and the fourth determining unit is used for determining the target confidence corresponding to the target bar code based on the determined distortion degree of the target bar code.
19. The apparatus of claim 18, wherein the target bar code is: the bar code for which the decoding result has been determined; the target bar code comprises N rows of sub bar codes, wherein N is a positive integer; the decoding result of the target bar code comprises a plurality of characters;
the third determination unit is specifically configured to
For each character corresponding to each row of sub-barcodes in the target barcode, determining a starting position and an ending position corresponding to each character corresponding to the sub-barcode based on the position information corresponding to each bar and each space corresponding to the character;
for each character corresponding to each row of sub-bar codes in the target bar code, determining the width corresponding to the character corresponding to the sub-bar code as an initial width based on the starting position and the ending position corresponding to the character in the sub-bar code;
calculating the average value of the initial widths corresponding to the characters in the N rows of sub-bar codes as the average width corresponding to the characters aiming at each character corresponding to the target bar code;
for each character corresponding to the target bar code, determining a variance corresponding to the character based on the average width corresponding to the character and the initial width corresponding to the character in the N rows of sub bar codes, wherein the variance corresponding to the character is in direct proportion to the distortion degree of the bar space corresponding to the character;
the fourth determination unit is specifically configured to
For each character corresponding to the target bar code, determining a confidence corresponding to the character based on a preset corresponding relationship and the determined variance corresponding to the character, wherein the preset corresponding relationship comprises: corresponding relations between the variances and preset confidence degrees;
and determining a target confidence corresponding to the target bar code based on the determined confidence corresponding to each character.
20. The apparatus according to claim 12, wherein when the preset accuracy evaluation rule comprises: the rule is that the accuracy evaluation is carried out on the decoding result of the bar code based on the light spot information corresponding to the bar code; based on the fuzzy degree corresponding to the bar code, the accuracy evaluation rule is carried out on the decoding result of the bar code; the rule is used for evaluating the accuracy of the decoding result of the bar code based on the fouling degree corresponding to the bar code; and, based on the distortion degree corresponding to the bar code, at least two types of rules in the rules for evaluating the accuracy of the decoding result of the bar code;
the device further comprises:
a second obtaining module, configured to obtain a weight value corresponding to each type of rule included in the preset accuracy evaluation rule before determining a target confidence corresponding to the target barcode based on the preset accuracy evaluation rule and the respective corresponding location information of each bar and each space in the target barcode;
the determination module is used for
Determining a confidence coefficient corresponding to the target bar code as an intermediate confidence coefficient based on each type of rule included in the preset accuracy evaluation rule and the respective corresponding position information of each bar and each space in the target bar code;
and determining a target confidence corresponding to the target bar code based on the intermediate confidence corresponding to each type of rule and the obtained weight value corresponding to each type of rule.
21. The apparatus of claim 12, further comprising:
the judging module is used for judging whether the target confidence coefficient is higher than a preset confidence coefficient threshold value or not after the target confidence coefficient corresponding to the target bar code is determined based on the preset accuracy evaluation rule and the position information corresponding to each bar and each space in the target bar code;
and the first output module is used for outputting the decoding result of the target bar code when the target confidence coefficient is judged to be higher than the preset confidence coefficient threshold value.
22. The apparatus of claim 21, further comprising:
the discarding module is used for discarding the decoding result of the target bar code when the target confidence coefficient is judged not to be higher than the preset confidence coefficient threshold value; or the like, or, alternatively,
and the second output module is used for outputting prompt information to prompt a user that the accuracy of the decoding result of the target bar code is low.
23. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of evaluating the decoding result of the barcode according to any one of claims 1 to 11 when executing the computer program stored in the memory.
24. The electronic device of claim 23, further comprising
The camera is used for scanning to obtain a target bar code;
and the display is used for displaying the decoding result of the target bar code.
25. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, implements the method steps for evaluating the decoding result of a barcode according to any one of claims 1 to 11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810994954.7A CN110874538B (en) | 2018-08-29 | 2018-08-29 | Method and device for evaluating decoding result of bar code and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810994954.7A CN110874538B (en) | 2018-08-29 | 2018-08-29 | Method and device for evaluating decoding result of bar code and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110874538A true CN110874538A (en) | 2020-03-10 |
CN110874538B CN110874538B (en) | 2023-06-02 |
Family
ID=69714591
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810994954.7A Active CN110874538B (en) | 2018-08-29 | 2018-08-29 | Method and device for evaluating decoding result of bar code and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110874538B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113658164A (en) * | 2021-08-24 | 2021-11-16 | 凌云光技术股份有限公司 | Two-dimensional code information extraction accuracy assessment method and device |
CN114298078A (en) * | 2021-12-29 | 2022-04-08 | 杭州晟元数据安全技术股份有限公司 | Decoding method for stained one-dimensional bar code |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101908125A (en) * | 2010-06-01 | 2010-12-08 | 福建新大陆电脑股份有限公司 | QR (Quick Response) bar code decoding chip and decoding method thereof |
US8079525B1 (en) * | 2011-02-24 | 2011-12-20 | Psion Inc. | System and method for decoding barcodes captured with a color image sensor |
CN105894074A (en) * | 2016-04-15 | 2016-08-24 | 大连声鹭科技有限公司 | Anti-counterfeiting bar code label, anti-counterfeiting bar code label information acquisition device, acquisition method, and anti-counterfeiting verification system |
CN106446732A (en) * | 2015-08-13 | 2017-02-22 | 株式会社理光 | Barcode identification method, device and equipment |
CN106991348A (en) * | 2017-03-21 | 2017-07-28 | 浙江华睿科技有限公司 | A kind of bar code decoding method and device |
CN107016318A (en) * | 2017-03-21 | 2017-08-04 | 浙江华睿科技有限公司 | A kind of bar code decoding method and device |
CN108073848A (en) * | 2016-11-07 | 2018-05-25 | 阿里巴巴集团控股有限公司 | A kind of bar code recognition, equipment and device |
CN108171098A (en) * | 2016-12-07 | 2018-06-15 | 杭州海康威视数字技术股份有限公司 | A kind of code detection method and equipment |
-
2018
- 2018-08-29 CN CN201810994954.7A patent/CN110874538B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101908125A (en) * | 2010-06-01 | 2010-12-08 | 福建新大陆电脑股份有限公司 | QR (Quick Response) bar code decoding chip and decoding method thereof |
US8079525B1 (en) * | 2011-02-24 | 2011-12-20 | Psion Inc. | System and method for decoding barcodes captured with a color image sensor |
CN106446732A (en) * | 2015-08-13 | 2017-02-22 | 株式会社理光 | Barcode identification method, device and equipment |
CN105894074A (en) * | 2016-04-15 | 2016-08-24 | 大连声鹭科技有限公司 | Anti-counterfeiting bar code label, anti-counterfeiting bar code label information acquisition device, acquisition method, and anti-counterfeiting verification system |
CN108073848A (en) * | 2016-11-07 | 2018-05-25 | 阿里巴巴集团控股有限公司 | A kind of bar code recognition, equipment and device |
CN108171098A (en) * | 2016-12-07 | 2018-06-15 | 杭州海康威视数字技术股份有限公司 | A kind of code detection method and equipment |
CN106991348A (en) * | 2017-03-21 | 2017-07-28 | 浙江华睿科技有限公司 | A kind of bar code decoding method and device |
CN107016318A (en) * | 2017-03-21 | 2017-08-04 | 浙江华睿科技有限公司 | A kind of bar code decoding method and device |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113658164A (en) * | 2021-08-24 | 2021-11-16 | 凌云光技术股份有限公司 | Two-dimensional code information extraction accuracy assessment method and device |
CN113658164B (en) * | 2021-08-24 | 2024-05-24 | 凌云光技术股份有限公司 | Evaluation method and device for two-dimensional code information extraction accuracy |
CN114298078A (en) * | 2021-12-29 | 2022-04-08 | 杭州晟元数据安全技术股份有限公司 | Decoding method for stained one-dimensional bar code |
CN114298078B (en) * | 2021-12-29 | 2023-10-24 | 杭州晟元数据安全技术股份有限公司 | Decoding method of stained one-dimensional bar code |
Also Published As
Publication number | Publication date |
---|---|
CN110874538B (en) | 2023-06-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107122806B (en) | Sensitive image identification method and device | |
EP3349140B1 (en) | Fingerprint ridge point recognition method and apparatus | |
CN109241861B (en) | Mathematical formula identification method, device, equipment and storage medium | |
CN111340023B (en) | Text recognition method and device, electronic equipment and storage medium | |
CN111582282A (en) | Text recognition method, device, equipment and storage medium | |
CN109447080B (en) | Character recognition method and device | |
CN111340041B (en) | License plate recognition method and device based on deep learning | |
CN108197638B (en) | Method and device for classifying sample to be evaluated | |
CN111985469B (en) | Method and device for recognizing characters in image and electronic equipment | |
CN106569946B (en) | Mobile terminal performance test method and system | |
CN111612000B (en) | Commodity classification method and device, electronic equipment and storage medium | |
CN111814776B (en) | Image processing method, device, server and storage medium | |
CN110874538A (en) | Method and device for evaluating decoding result of bar code and electronic equipment | |
CN111079480A (en) | Identification method and device of identity card information and terminal equipment | |
CN114495098A (en) | Diaxing algae cell statistical method and system based on microscope image | |
CN114581419A (en) | Transformer insulating sleeve defect detection method, related equipment and readable storage medium | |
CN111178347B (en) | Ambiguity detection method, ambiguity detection device, ambiguity detection equipment and ambiguity detection storage medium for certificate image | |
Romic et al. | Character recognition based on region pixel concentration for license plate identification | |
CN115759964A (en) | Method, system and equipment for verifying universal qualification of bid document | |
CN112084979B (en) | Food ingredient identification method, device, equipment and storage medium | |
CN111814780B (en) | Bill image processing method, device, equipment and storage medium | |
CN108961531B (en) | Method, device and equipment for identifying serial number of paper currency and storage medium | |
CN113343983B (en) | License plate number recognition method and electronic equipment | |
CN117953519B (en) | Quality monitoring method and system for file digital service | |
US20240020998A1 (en) | Character recognition method for dynamic images |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |