CN116432676B - Method and device for decoding bar code and electronic equipment - Google Patents

Method and device for decoding bar code and electronic equipment Download PDF

Info

Publication number
CN116432676B
CN116432676B CN202310687269.0A CN202310687269A CN116432676B CN 116432676 B CN116432676 B CN 116432676B CN 202310687269 A CN202310687269 A CN 202310687269A CN 116432676 B CN116432676 B CN 116432676B
Authority
CN
China
Prior art keywords
decoding
bar code
duration
target maximum
maximum decoding
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.)
Active
Application number
CN202310687269.0A
Other languages
Chinese (zh)
Other versions
CN116432676A (en
Inventor
黄金煌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Unigroup Tsingteng Microsystems Co Ltd
Original Assignee
Beijing Unigroup Tsingteng Microsystems Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Unigroup Tsingteng Microsystems Co Ltd filed Critical Beijing Unigroup Tsingteng Microsystems Co Ltd
Priority to CN202310687269.0A priority Critical patent/CN116432676B/en
Publication of CN116432676A publication Critical patent/CN116432676A/en
Application granted granted Critical
Publication of CN116432676B publication Critical patent/CN116432676B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14131D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The application relates to the technical field of bar codes, and discloses a method for decoding a bar code, which comprises the following steps: determining the image quality grade of the bar code image; determining a target maximum decoding duration according to the image quality level; and decoding the bar code image according to the target maximum decoding time length. Different decoding time lengths for decoding the bar code are determined according to different qualities of the bar code image, so that the decoding operation of the low-quality bar code image can be rapidly exited, the decoding probability of executing the high-quality bar code image is increased, the overall code scanning time of the code scanning device in the bar code decoding process is shortened, and the code scanning experience is better improved. The application also discloses a device for decoding the bar code and electronic equipment.

Description

Method and device for decoding bar code and electronic equipment
Technical Field
The application relates to the technical field of bar codes, in particular to a method and a device for decoding a bar code and electronic equipment.
Background
The code scanning device is also called a code scanner, a code scanning module or a code reader and is used for reading bar code information in the bar code image. The code scanning device is often embedded into various terminal devices, automatically acquires bar code information (such as one-dimensional code information or two-dimensional code information) on paper, mobile phones and other media, decodes and transmits data, and is one of the core hardware indispensable for the terminal devices to realize the code scanning function.
The code scanning device generally comprises a picture taking device and a decoding device, wherein in the process of decoding the bar code, the picture taking device scans and reads the bar code in the bar code image, then the decoding device is utilized for decoding, and correct characters represented by the bar code are returned to finish the decoding of the bar code. And when the bar code decoding task is executed by the bar code scanning equipment, the operations of capturing the bar code image and decoding the bar code are circularly executed until the bar code is successfully decoded.
In the process of implementing the embodiments of the present disclosure, it is found that at least the following problems exist in the related art:
the whole code scanning time of the code scanning equipment in the code decoding process is longer.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the application and thus may include information that does not form the prior art that is already known to those of ordinary skill in the art.
Disclosure of Invention
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview, and is intended to neither identify key/critical elements nor delineate the scope of such embodiments, but is intended as a prelude to the more detailed description that follows.
The embodiment of the disclosure provides a method and a device for decoding a bar code and electronic equipment, so as to shorten the overall code scanning time of code scanning equipment in the process of decoding the bar code.
In some embodiments, a method for barcode decoding includes: determining the image quality grade of the bar code image; determining a target maximum decoding duration according to the image quality level; and decoding the bar code image according to the target maximum decoding time length.
In some embodiments, an apparatus for barcode decoding includes: a processor and a memory storing program instructions, the processor being configured to perform the aforementioned method for barcode decoding when the program instructions are executed.
In some embodiments, an electronic device includes: an electronic device main body; and the aforementioned device for barcode decoding is mounted to the electronic device main body.
The method and the device for decoding the bar code and the electronic equipment provided by the embodiment of the disclosure can realize the following technical effects:
in the technical scheme of the disclosure, in the barcode decoding process, the barcode scanning device determines the image quality grade of the barcode image, then determines the target maximum decoding time according to the image quality grade, and decodes the barcode image according to the target maximum decoding time. Therefore, different decoding time lengths for decoding the bar code are determined according to different qualities of the bar code image, the decoding operation of the low-quality bar code image can be rapidly exited, the decoding probability of executing the high-quality bar code image is increased, the integral code scanning time of the code scanning device in the bar code decoding process is shortened, and the code scanning experience is better improved.
The foregoing general description and the following description are exemplary and explanatory only and are not restrictive of the application.
Drawings
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which like reference numerals refer to similar elements, and in which:
FIG. 1 is a flow chart of a method for bar code decoding provided by an embodiment of the present disclosure;
FIG. 2 is a flow chart of another method for bar code decoding provided by an embodiment of the present disclosure;
FIG. 3 is a flow chart of another method for bar code decoding provided by an embodiment of the present disclosure;
FIG. 4 is a flow chart of another method for bar code decoding provided by an embodiment of the present disclosure;
FIG. 5 is a statistical histogram of gray values of a bar code image provided by an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of an apparatus for bar code decoding according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
So that the manner in which the features and techniques of the disclosed embodiments can be understood in more detail, a more particular description of the embodiments of the disclosure, briefly summarized below, may be had by reference to the appended drawings, which are not intended to be limiting of the embodiments of the disclosure. In the following description of the technology, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the disclosed embodiments. However, one or more embodiments may still be practiced without these details. In other instances, well-known structures and devices may be shown simplified in order to simplify the drawing.
The terms first, second and the like in the description and in the claims of the embodiments of the disclosure and in the above-described figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe embodiments of the present disclosure. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion.
The term "plurality" means two or more, unless otherwise indicated. In the embodiment of the present disclosure, the character "/" indicates that the front and rear objects are an or relationship. For example, A/B represents: a or B. The term "and/or" is an associative relationship that describes an object, meaning that there may be three relationships. For example, a and/or B, represent: a or B, or, A and B. The term "corresponding" may refer to an association or binding relationship, and the correspondence between a and B refers to an association or binding relationship between a and B.
And when the bar code decoding task is executed by the bar code scanning equipment, the operations of capturing the bar code image by the image capturing device and decoding the bar code by the decoding device are circularly executed until the bar code is successfully decoded. When the code scanning equipment is in a scene of motion decoding or unstable illumination decoding, the uncertainty of the image content acquired by the image acquisition device is large, and the probability of capturing a low-quality bar code image is greatly increased. Therefore, the decoding device is easy to decode the low-quality bar code image for a long time, long in execution time and low in success rate, and can block the capturing and decoding of the subsequent high-quality bar code image, so that the whole code scanning time of the code scanning device is long, and the use experience of the code scanning device for scanning the code is poor. Therefore, the embodiment of the disclosure provides a method for decoding a bar code, which determines different decoding time lengths for decoding the bar code according to different qualities of the bar code image, can quickly exit the decoding operation of the low-quality bar code image, increases the decoding probability of executing the high-quality bar code image, shortens the overall code scanning time of code scanning equipment in the process of decoding the bar code, and better improves the code scanning experience.
Referring to fig. 1, an embodiment of the present disclosure provides a method for decoding a barcode, including the steps of:
s101, determining the image quality grade of the bar code image.
Optionally, determining the image quality level to which the barcode image belongs includes: obtaining a maximum gray value and a minimum gray value of the denoising bar code image; determining a gray difference value of the maximum gray value and the minimum gray value; and determining the image quality grade of the bar code image according to the gray level difference value.
The denoising bar code image is a bar code image obtained after denoising the initial bar code image, and the initial bar code image is a bar code image obtained by shooting the bar code by a bar code scanning device or a camera device.
In some practical applications, with reference to fig. 5, a denoised barcode image is obtained as follows: obtaining a histogram HIST function of the initial bar code image; inputting the gray value of the initial bar code image in the histogram HIST function; removing bar code pixels with gray values at the maximum preset proportion and the minimum preset proportion from the initial bar code image; and obtaining a denoising bar code image. For example, the maximum 10% pixels and the minimum 10% pixels in the gray values in the histogram HIST function distribution are removed, and a denoising bar code image is obtained.
After the denoising bar code image is obtained, calculating a gray level difference value (namely image contrast) between a maximum gray level value and a minimum gray level value of the denoising bar code image, and determining the image quality grade of the bar code image according to the gray level difference value. The gray level difference is calculated as follows: contrast = MaxGrey-MinGrey, contrast is the gray difference, maxGrey is the maximum gray value of the denoised barcode image, and MinGrey is the minimum gray value of the denoised barcode image.
In practical application, the image quality levels can be divided into five levels of level1, level2, level3, level4 and level5 which are not overlapped with each other, and each barcode image corresponds to one of the image quality levels.
Dividing the image quality grade of the bar code image according to the gray level difference value:
Level = level1if Contrast<th1;
Level = level2if th1<Contrast<th2;
Level = level3if th2<Contrast<th3;
Level = level4if th3<Contrast<th4;
Level = level5if th4<Contrast<th5。
wherein, th1, th2, th3, th4, th5 are preset gray level difference values, and th1 < th2 < th3 < th4 < th5.
Contrast is the difference between the maximum gray value and the minimum gray value. For an 8-bit sensor, the gray value of a pixel is identified by an 8-bit binary number, with a maximum gray value of 255 and a minimum gray value of 0. The Contrast value range is 0-255. th1, th2, th3, th4, th5 are 5 thresholds determined within the gray difference range, and the barcode image quality can be classified into 5 levels according to the five preset gray differences. th1 has a value in the range of [15, 25], for example 15, 20, 25; th2 has a value in the range of [55, 65], for example 55, 60, 65; th3 has a value in the range of [95, 105], for example 95, 100, 105; th4 has a value in the range of [195, 205], for example 195, 200, 205; th5 has a value in the range of 240, 255, for example 240, 250, 255.
The gray value refers to the luminance value of each pixel in the image, in which the gray value of each pixel represents the luminance of the pixel. The larger the gray value, the higher the brightness of the pixel, and the easier the bar code image of the pixel is identified; the smaller the gray value, the lower the brightness of the pixel, and the more difficult it is to identify the barcode image of the pixel. The image quality grade of the bar code image is determined by using the gray level difference value, and the image quality grade of the bar code image can be better determined from the aspect of the decoding difficulty of the bar code image, so that the overall time of the subsequent bar code decoding is shortened.
S102, determining a target maximum decoding duration according to the image quality grade.
In practical applications, the image quality levels may be divided into five levels of level1, level2, level3, level4, and level5, which are not overlapped with each other. Accordingly, the target maximum decoding duration may be a one-dimensional array a= { T5, T4, T3, T2, T1} of the maximum decoding durations at five image quality levels, the target maximum decoding durations corresponding to the image quality levels one to one. For example, the image quality level1 corresponds to the target maximum decoding period T5, the image quality level2 corresponds to the target maximum decoding period T4, the image quality level3 corresponds to the target maximum decoding period T3, the image quality level4 corresponds to the target maximum decoding period T2, and the image quality level5 corresponds to the target maximum decoding period T1.
Optionally, determining the target maximum decoding duration according to the image quality level includes: under the condition that the code system type of the bar code is known, determining the target maximum decoding time according to the one-dimensional corresponding relation between the target maximum decoding time and the image quality grade; and under the condition that the code system type of the bar code is unknown, determining the target maximum decoding time according to the two-dimensional corresponding relation between the target maximum decoding time and the image quality grade and the code system type.
The target maximum decoding duration is inversely related to the image quality level. The higher the image quality level is, the better the barcode image quality is, and the smaller the target maximum decoding time length is; conversely, the lower the image quality level, the worse the barcode image quality, and the greater the target maximum decoding duration.
Under the condition that the code system type of the bar code is known, the target maximum decoding time length and the image quality grade meet the one-dimensional corresponding relation. In practical application, the one-dimensional correspondence (one-dimensional correspondence of the target maximum decoding duration and the image quality level) includes: t (T) max =k 1 ×T max0 Wherein T is max For a target maximum decoding duration, k 1 For adjusting the coefficients, T, for the image quality level max0 And (5) the maximum decoding duration initial value is the target. Image quality level adjustment coefficient k 1 Inversely related to the image quality level, i.e. the higher the image quality level, the image quality level adjustment factor k 1 The smaller; the lower the image quality level, the image quality level adjustment coefficient k 1 The larger.
Here, the image quality level adjustment coefficient k 1 The range of values of (5) may be [0.800,0.980 ]]For example, 0.800, 0.850, 0.855, 0.900, 0.950, 0.955, 0.980. Initial value T of target maximum decoding time length max0 And a target maximum decoding duration T max In embedded systems, both are on the order of ms (milliseconds).
Under the condition that the code system type of the bar code is unknown, the target maximum decoding time length, the image quality grade and the code system type meet the two-dimensional corresponding relation. In practical application, the two-dimensional correspondence (two-dimensional correspondence of the target maximum decoding duration with the image quality level and the code system type) includes: t (T) max =k 1 ×m 1 ×T max0 Wherein T is max For a target maximum decoding duration, k 1 Adjusting the coefficients, m, for the image quality levels 1 Is of the code system typeRegulating coefficient T max0 And (5) the maximum decoding duration initial value is the target. Image quality level adjustment coefficient k 1 Inversely related to the image quality level, i.e. the higher the image quality level, the image quality level adjustment coefficient k 1 The smaller; the lower the image quality level, the image quality level adjustment coefficient k 1 The larger. Code type adjustment coefficient m 1 Positively correlated with the complexity of the code pattern, i.e. the more complex the code pattern is, the code pattern adjusts the coefficient m 1 The larger the code system type is, the simpler the code system type is, and the code system type is adjusted by the coefficient m 1 The smaller. For example, it may be considered that the complexity of the two-dimensional bar code is greater than the complexity of the one-dimensional bar code, and the code system type adjustment coefficient of the two-dimensional bar code is greater than the code system type adjustment coefficient of the one-dimensional bar code.
Here, the image quality level adjustment coefficient k 1 The range of values of (5) may be [0.800,0.980 ]]For example, 0.800, 0.850, 0.855, 0.900, 0.950, 0.955, 0.980. Code type adjustment coefficient m 1 The range of values of (5) may be [0.900,0.990 ]]For example, 0.900, 0.920, 0.930, 0.955, 0.970, 0.980, 0.990. Initial value T of target maximum decoding time length max0 And a target maximum decoding duration T max In embedded systems, both are on the order of ms (milliseconds).
And the code system type and the image quality grade of the bar code image are introduced, the target maximum decoding duration is set for the code system type and the image quality grade, and if the decoding time exceeds the maximum decoding duration, the image capture and decoding are performed again, so that the overall decoding time of the bar code image can be shortened, and the decoding efficiency of the bar code image is improved.
Optionally, determining the target maximum decoding duration according to the image quality level includes: determining an initial maximum decoding duration according to the image quality level; obtaining average successful decoding time length of the bar code image in a preset time period; and determining the target maximum decoding duration according to the initial maximum decoding duration and the average successful decoding duration.
Optionally, determining the target maximum decoding duration according to the initial maximum decoding duration and the average successful decoding duration includes calculating the target maximum decoding duration according to the following formula:
T max = a×T 0 +b×T ave
wherein T is max For a target maximum decoding duration, T 0 For an initial maximum decoding duration, T ave For the average successful decoding duration, a is the initial maximum decoding duration correction coefficient, b is the average successful decoding duration correction coefficient, a+b=1.
Target maximum decoding duration T max In embedded systems, on the order of ms (milliseconds). 0 < a < 1,0 < b < 1, e.g., a is 0.6, 0.8 or 0.9, and b is 0.4, 0.2 or 0.1, respectively.
In some implementations, a > b. In this way, overcorrection of the average successful decoding duration to the target maximum decoding duration is avoided to some extent.
Here, the initial maximum decoding duration may be obtained according to the following manner: under the condition that the code system type of the bar code is known, determining the initial maximum decoding time according to the one-dimensional corresponding relation between the initial maximum decoding time and the image quality grade; under the condition that the code system type of the bar code is unknown, determining the initial maximum decoding time according to the two-dimensional corresponding relation between the initial maximum decoding time and the image quality grade as well as the code system type.
The initial maximum decoding duration is inversely related to the image quality level. The higher the image quality level, the better the barcode image quality, and the smaller the initial maximum decoding duration; conversely, the lower the image quality level, the worse the barcode image quality, and the greater the initial maximum decoding duration.
Under the condition that the code system type of the bar code is known, the initial maximum decoding time length and the image quality grade meet the one-dimensional corresponding relation. In practical applications, the one-dimensional correspondence (one-dimensional correspondence of the initial maximum decoding duration and the image quality level) includes: t (T) 0max =k 2 ×T 0max0 Wherein T is 0max K is the initial maximum decoding duration 2 For adjusting the coefficients, T, for the image quality level 0max0 An initial value of the initial maximum decoding duration. Image quality level adjustment coefficient k 2 Inversely related to image quality level, i.e. the higher the image quality level, the image qualityRank adjustment coefficient k 2 The smaller; the lower the image quality level, the image quality level adjustment coefficient k 2 The larger.
Here, the image quality level adjustment coefficient k 2 The range of values of (5) may be [0.800,0.980 ]]For example, 0.800, 0.850, 0.855, 0.900, 0.950, 0.955, 0.980. Initial maximum decoding duration initial value T 0max0 And an initial maximum decoding duration T 0max (T 0 ) In embedded systems, both are on the order of ms (milliseconds).
Under the condition that the code system type of the bar code is unknown, the initial maximum decoding time length, the image quality grade and the code system type meet the two-dimensional corresponding relation. In practical application, the two-dimensional correspondence (two-dimensional correspondence of initial maximum decoding duration with image quality level and code system type) includes: t (T) 0max =k 2 ×m 2 ×T 0max0 Wherein T is 0max K is the initial maximum decoding duration 2 Adjusting the coefficients, m, for the image quality levels 2 For adjusting the coefficient of code type, T 0max0 An initial value of the initial maximum decoding duration. Image quality level adjustment coefficient k 2 Inversely related to the image quality level, i.e. the higher the image quality level, the image quality level adjustment coefficient k 2 The smaller; the lower the image quality level, the image quality level adjustment coefficient k 2 The larger. Code type adjustment coefficient m 2 Positively correlated with the complexity of the code pattern, i.e. the more complex the code pattern is, the code pattern adjusts the coefficient m 2 The larger the code system type is, the simpler the code system type is, and the code system type is adjusted by the coefficient m 2 The smaller. For example, it may be considered that the complexity of the two-dimensional bar code is greater than the complexity of the one-dimensional bar code, and the code system type adjustment coefficient of the two-dimensional bar code is greater than the code system type adjustment coefficient of the one-dimensional bar code.
Here, the image quality level adjustment coefficient k 2 The range of values of (5) may be [0.800,0.980 ]]For example, 0.800, 0.850, 0.855, 0.900, 0.950, 0.955, 0.980. Code type adjustment coefficient m 2 The range of values of (5) may be [0.900,0.990 ]]For example, 0.900, 0.920, 0.930, 0.955, 0.970, 0.980, 0.990.Initial maximum decoding duration initial value T 0max0 And an initial maximum decoding duration T 0max (T 0 ) In embedded systems, both are on the order of ms (milliseconds).
S103, decoding the bar code image according to the target maximum decoding time length.
Optionally, decoding the barcode image according to the target maximum decoding duration includes: under the condition that the bar code image is successfully decoded within the target maximum decoding time length, the decoding operation is exited; and re-capturing the bar code image under the condition that the bar code image is not successfully decoded within the maximum decoding time of the target.
And after determining the target maximum decoding duration according to the image quality grade, starting a timing system. And if the bar code image is successfully decoded within the target maximum decoding time length, exiting the decoding operation. If the decoding of the bar code image is not successful within the target maximum decoding time length, the bar code image is captured again when the time of the target maximum decoding time length arrives, the image quality grade of the bar code image is determined again, then the target maximum decoding time length is determined according to the image quality grade, and then the bar code image is decoded according to the target maximum decoding time length, so that the cycle is performed. By timely exiting the decoding operation of the low-quality bar code image, the decoding efficiency of the bar code image can be improved.
By adopting the method for decoding the bar code, which is provided by the embodiment of the disclosure, in the process of decoding the bar code, the bar code scanning device firstly determines the image quality grade to which the bar code image belongs, then determines the target maximum decoding time according to the image quality grade, and then decodes the bar code image according to the target maximum decoding time. Therefore, different decoding time lengths for decoding the bar code are determined according to different qualities of the bar code image, the decoding operation of the low-quality bar code image can be rapidly exited, the decoding probability of executing the high-quality bar code image is increased, the integral code scanning time of the code scanning device in the bar code decoding process is shortened, and the code scanning experience is better improved.
An embodiment of the present disclosure provides a method for decoding a barcode, as shown in fig. 2, including the following steps:
s201, determining the image quality grade of the bar code image.
S202, determining a target maximum decoding duration according to the image quality level.
S203, decoding the bar code image according to the target maximum decoding time length.
S204, obtaining the current successful decoding duration under the condition that the decoding of the bar code image is successful according to the target maximum decoding duration.
S205, correcting the target maximum decoding duration according to the current successful decoding duration to obtain the target maximum decoding correction duration.
Optionally, correcting the target maximum decoding duration according to the current successful decoding duration to obtain the target maximum decoding correction duration, including calculating the target maximum decoding duration according to the following formula:
max = m×T max +n×T suc
wherein, max correcting time length for target maximum decoding, T max For a target maximum decoding duration, T suc For the time length of the next successful decoding, m is the maximum decoding time length correction coefficient, n is the time length correction coefficient of the next successful decoding, and m+n=1.
Target maximum decoding correction duration max In embedded systems, on the order of ms (milliseconds). Likewise, a target maximum decoding duration T max And the time length T of the successful decoding suc In embedded systems, on the order of ms (milliseconds). 0 < m < 1,0 < n < 1, e.g. m is 0.6, 0.8 or 0.9, and correspondingly n is 0.4, 0.2 or 0.1.
In some implementations, m > n. In this way, overcorrection of the target maximum decoding duration by the current successful decoding duration is avoided to some extent.
S206, updating the target maximum decoding time length based on the target maximum decoding correction time length.
After the target maximum decoding correction time length is obtained, updating the target maximum decoding time length by using the target maximum decoding correction time length, and replacing the target maximum decoding time length in the target maximum decoding time length table with the target maximum decoding correction time length. For example, the target maximum decoding period T is determined from the image quality level1 max After obtaining the target maximum decoding correction duration max Then, the target maximum decoding time length T corresponding to the image quality level1 is obtained max Substitution to target maximum decoding modification duration +.> max
In some embodiments, the method for barcode decoding further comprises: under the condition that the decoding of the bar code image is successful according to the target maximum decoding time length, obtaining the current successful decoding time length; correcting the initial maximum decoding time length according to the current successful decoding time length to obtain initial maximum decoding correction time length; the initial maximum decoding duration is updated based on the initial maximum decoding revised duration.
Optionally, correcting the initial maximum decoding duration according to the current successful decoding duration to obtain an initial maximum decoding corrected duration, including calculating the initial maximum decoding duration according to the following formula:
0max = m×T 0max +n×T suc
wherein, 0max correcting the duration for initial maximum decoding, T 0max For an initial maximum decoding duration, T suc For the time length of the next successful decoding, m is the maximum decoding time length correction coefficient, n is the time length correction coefficient of the next successful decoding, and m+n=1.
Initial maximum decoding correction duration 0max In embedded systems, on the order of ms (milliseconds). Also, an initial maximum decoding duration T 0max (T 0 ) And the time length T of the successful decoding suc In embedded systems, on the order of ms (milliseconds). 0 < m < 1,0 < n < 1, e.g. m is 0.6, 0.8 or 0.9, and correspondingly n is 0.4, 0.2 or 0.1.
In some implementations, m > n. In this way, overcorrection of the initial maximum decoding duration by the current successful decoding duration is avoided to some extent.
After the initial maximum decoding correction time length is obtained, updating the initial maximum decoding time length by utilizing the initial maximum decoding correction time length, and replacing the initial maximum decoding time length in the initial maximum decoding time length table with the initial maximum decoding correction time length. For example, the initial maximum decoding period T is determined from the image quality level1 0max After obtaining the target maximum decoding correction duration 0max Then, the initial maximum decoding time length T corresponding to the image quality level1 is obtained 0max Substitution to target maximum decoding modification duration +.> 0max
In the method for decoding the bar code provided by the embodiment of the disclosure, firstly, under the condition that the code system type of the bar code is known, determining the initial maximum decoding duration according to the one-dimensional corresponding relation between the initial maximum decoding duration and the image quality level; under the condition that the code system type of the bar code is unknown, determining the initial maximum decoding time according to the two-dimensional corresponding relation between the initial maximum decoding time and the image quality grade as well as the code system type. Secondly, obtaining average successful decoding time length of the bar code image in a preset time period; and determining the target maximum decoding duration according to the initial maximum decoding duration and the average successful decoding duration. Thirdly, under the condition that the decoding of the bar code image is successful according to the target maximum decoding time length, obtaining the current successful decoding time length; correcting the initial maximum decoding time length according to the current successful decoding time length to obtain initial maximum decoding correction time length; the initial maximum decoding duration is updated based on the initial maximum decoding revised duration.
In this way, the target maximum decoding time length of the bar code decoding is designed, the code system type and the image quality grade of the bar code image are introduced, the initial maximum decoding time length is set for the type without the code system and the image quality grade, then the average successful decoding time length is utilized to correct the initial maximum decoding time length, the target maximum decoding time length is obtained, and after the bar code image is decoded according to the target maximum decoding time length, the current successful decoding time length is utilized to reversely correct the initial maximum decoding time length. Therefore, when the bar code is decoded, the decoding operation of the low-quality bar code image can be better and quickly exited, the decoding probability of executing the high-quality bar code image is increased, the overall code scanning time of the code scanning equipment in the bar code decoding process is shortened, and the code scanning experience is improved.
An embodiment of the present disclosure provides a method for decoding a barcode, as shown in fig. 3, including the following steps:
s301, determining the image quality grade of the bar code image.
S302, determining initial maximum decoding duration according to the image quality level.
S303, obtaining average successful decoding duration of the bar code image in a preset time period.
S304, determining a target maximum decoding duration according to the initial maximum decoding duration and the average successful decoding duration.
S305, decoding the bar code image according to the target maximum decoding time length.
S306, obtaining the current successful decoding duration under the condition that the decoding of the bar code image is successful according to the target maximum decoding duration.
S307, correcting the target maximum decoding time length according to the current successful decoding time length, and obtaining the target maximum decoding correction time length.
S308, updating the initial maximum decoding time period based on the target maximum decoding correction time period, and re-executing the step of S301.
By adopting the method for decoding the bar code, which is provided by the embodiment of the disclosure, different decoding time lengths for decoding the bar code are determined according to different qualities of the bar code image, meanwhile, the average successful decoding time length is utilized to correct the initial maximum decoding time length, the target maximum decoding time length is obtained, and after the bar code image is decoded according to the target maximum decoding time length, the current successful decoding time length is utilized to reversely correct the initial maximum decoding time length. Therefore, when the bar code is decoded, the decoding operation of the low-quality bar code image can be better and quickly exited, the decoding probability of executing the high-quality bar code image is increased, the overall code scanning time of the code scanning equipment in the bar code decoding process is shortened, and the code scanning experience is improved.
An embodiment of the present disclosure provides a method for decoding a barcode, as shown in fig. 4, including the following steps:
s401, acquiring a bar code image.
S402, evaluating the image quality of the bar code image and determining the image quality grade of the bar code image.
S403, determining a target maximum decoding duration according to the image quality level.
S404, decoding the bar code image according to the target maximum decoding time length, and starting a timing system.
S405, obtaining the current successful decoding duration under the condition that the bar code image is successfully decoded within the target maximum decoding duration.
S406, correcting the target maximum decoding time length according to the current successful decoding time length, and obtaining the target maximum decoding correction time length.
S407, updating the target maximum decoding time length based on the target maximum decoding correction time length.
S408, recapturing the bar code image and re-executing the step S401 under the condition that the bar code image is not successfully decoded within the target maximum decoding time.
By adopting the method for decoding the bar code, which is provided by the embodiment of the application, different decoding time lengths for decoding the bar code are determined according to different qualities of the bar code image, and meanwhile, after the bar code image is decoded according to the target maximum decoding time length, the target maximum decoding time length is reversely corrected by utilizing the current successful decoding time length. Therefore, when the bar code is decoded, the decoding operation of the low-quality bar code image can be better and quickly exited, the decoding probability of executing the high-quality bar code image is increased, the overall code scanning time of the code scanning equipment in the bar code decoding process is shortened, and the code scanning experience is improved.
The disclosed embodiment shown in fig. 6 provides an apparatus for bar code decoding, which includes a processor (processor) 60 and a memory (memory) 61, and may further include a communication interface (Communication Interface) 62 and a bus 63. The processor 60, the communication interface 62, and the memory 61 may communicate with each other via the bus 63. The communication interface 62 may be used for information transfer. The processor 60 may invoke logic instructions in the memory 61 to perform the method for barcode decoding of the above-described embodiments.
Further, the logic instructions in the memory 61 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product.
The memory 61 is a computer readable storage medium that may be used to store a software program, a computer executable program, such as program instructions/modules corresponding to the methods in the embodiments of the present disclosure. The processor 60 performs functional applications as well as data processing by running program instructions/modules stored in the memory 61, i.e. implements the method for barcode decoding in the method embodiments described above.
The memory 61 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the terminal device, etc. Further, the memory 61 may include a high-speed random access memory, and may also include a nonvolatile memory.
By adopting the device for decoding the bar code, which is provided by the embodiment of the disclosure, in the process of decoding the bar code, the bar code scanning device firstly determines the image quality grade to which the bar code image belongs, then determines the target maximum decoding time according to the image quality grade, and then decodes the bar code image according to the target maximum decoding time. Therefore, different decoding time lengths for decoding the bar code are determined according to different qualities of the bar code image, the decoding operation of the low-quality bar code image can be rapidly exited, the decoding probability of executing the high-quality bar code image is increased, the integral code scanning time of the code scanning device in the bar code decoding process is shortened, and the code scanning experience is better improved.
As shown in connection with fig. 7, embodiments of the present disclosure provide an electronic device (e.g., computer, server, etc.) comprising an electronic device body 70; and the above-described device 600 for decoding a bar code is mounted to the electronic device main body 70.
Embodiments of the present disclosure provide a computer-readable storage medium storing computer-executable instructions configured to perform the above-described method for barcode decoding.
The disclosed embodiments provide a computer program product comprising a computer program stored on a computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the above-described method for barcode decoding.
The computer readable storage medium may be a transitory computer readable storage medium or a non-transitory computer readable storage medium.
Embodiments of the present disclosure may be embodied in a software product stored on a storage medium, including one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of a method according to embodiments of the present disclosure. And the aforementioned storage medium may be a non-transitory storage medium including: a plurality of media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or a transitory storage medium.
The above description and the drawings illustrate embodiments of the disclosure sufficiently to enable those skilled in the art to practice them. Other embodiments may involve structural, logical, electrical, process, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and features of some embodiments may be included in, or substituted for, those of others. The scope of the embodiments of the present disclosure encompasses the full ambit of the claims, as well as all available equivalents of the claims. When used in the present application, although the terms "first," "second," etc. may be used in the present application to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element. For example, a first element could be termed a second element, and, similarly, a second element could be termed a first element, without changing the meaning of the description, so long as all occurrences of the "first element" are renamed consistently and all occurrences of the "second element" are renamed consistently. The first element and the second element are both elements, but may not be the same element. Moreover, the terminology used in the present application is for the purpose of describing embodiments only and is not intended to limit the claims. As used in the description of the embodiments and the claims, the singular forms "a," "an," and "the" (the) are intended to include the plural forms as well, unless the context clearly indicates otherwise. Similarly, the term "and/or" as used in this disclosure is meant to encompass any and all possible combinations of one or more of the associated listed. Furthermore, when used in the present disclosure, the terms "comprises," "comprising," and/or variations thereof, mean that the recited features, integers, steps, operations, elements, and/or components are present, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method or apparatus comprising such elements. In this context, each embodiment may be described with emphasis on the differences from the other embodiments, and the same similar parts between the various embodiments may be referred to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method sections disclosed in the embodiments, the description of the method sections may be referred to for relevance.
Those of skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. The skilled artisan may use different methods for each particular application to achieve the described functionality, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the embodiments disclosed herein, the disclosed methods, articles of manufacture (including but not limited to devices, apparatuses, etc.) may be practiced in other ways. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the units may be merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form. The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to implement the present embodiment. In addition, each functional unit in the embodiments of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. In the description corresponding to the flowcharts and block diagrams in the figures, operations or steps corresponding to different blocks may also occur in different orders than that disclosed in the description, and sometimes no specific order exists between different operations or steps. For example, two consecutive operations or steps may actually be performed substantially in parallel, they may sometimes be performed in reverse order, which may be dependent on the functions involved. Each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

Claims (9)

1. A method for bar code decoding, comprising:
determining the image quality grade of the bar code image;
determining a target maximum decoding duration according to the image quality level;
decoding the bar code image according to the target maximum decoding time length;
determining a target maximum decoding duration according to the image quality level, including: determining an initial maximum decoding duration according to the image quality level; obtaining average successful decoding time length of the bar code image in a preset time period; and determining the target maximum decoding duration according to the initial maximum decoding duration and the average successful decoding duration.
2. The method of claim 1, wherein determining the image quality level to which the barcode image belongs comprises:
obtaining a maximum gray value and a minimum gray value of the denoising bar code image;
determining a gray difference value of the maximum gray value and the minimum gray value;
and determining the image quality grade of the bar code image according to the gray level difference value.
3. The method of claim 1, wherein determining the target maximum decoding duration based on the image quality level comprises:
under the condition that the code system type of the bar code is known, determining the target maximum decoding time according to the one-dimensional corresponding relation between the target maximum decoding time and the image quality grade;
and under the condition that the code system type of the bar code is unknown, determining the target maximum decoding time according to the two-dimensional corresponding relation between the target maximum decoding time and the image quality grade and the code system type.
4. The method of claim 1, wherein determining the target maximum decoding duration based on the initial maximum decoding duration and the average successful decoding duration comprises calculating the target maximum decoding duration according to the following formula:
T max = a×T 0 +b×T ave
wherein T is max For a target maximum decoding duration, T 0 For an initial maximum decoding duration, T ave For average successful decoding duration, a is the initial maximum decoding duration correction coefficient, b is the average successful decoding duration correction coefficient。
5. The method of claim 1, further comprising, after decoding the barcode image according to the target maximum decoding time period:
under the condition that the decoding of the bar code image is successful according to the target maximum decoding time length, obtaining the current successful decoding time length;
correcting the target maximum decoding duration according to the current successful decoding duration to obtain target maximum decoding correction duration;
updating the target maximum decoding duration based on the target maximum decoding correction duration.
6. The method of claim 5, wherein correcting the target maximum decoding duration based on the current successful decoding duration to obtain the target maximum decoding corrected duration comprises calculating the target maximum decoding duration according to the following formula:
max = m×T max +n×T suc
wherein, max correcting time length for target maximum decoding, T max For a target maximum decoding duration, T suc For the time length of the next successful decoding, m is the maximum decoding time length correction coefficient, and n is the time length correction coefficient of the next successful decoding.
7. The method of any one of claims 1 to 6, wherein decoding the barcode image according to the target maximum decoding time length comprises:
and re-capturing the bar code image under the condition that the bar code image is not successfully decoded within the maximum decoding time of the target.
8. An apparatus for barcode decoding comprising a processor and a memory storing program instructions, wherein the processor is configured to perform the method for barcode decoding of any of claims 1 to 7 when executing the program instructions.
9. An electronic device, comprising:
an electronic device main body;
the apparatus for bar code decoding according to claim 8, mounted to the electronic device main body.
CN202310687269.0A 2023-06-12 2023-06-12 Method and device for decoding bar code and electronic equipment Active CN116432676B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310687269.0A CN116432676B (en) 2023-06-12 2023-06-12 Method and device for decoding bar code and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310687269.0A CN116432676B (en) 2023-06-12 2023-06-12 Method and device for decoding bar code and electronic equipment

Publications (2)

Publication Number Publication Date
CN116432676A CN116432676A (en) 2023-07-14
CN116432676B true CN116432676B (en) 2023-11-07

Family

ID=87091065

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310687269.0A Active CN116432676B (en) 2023-06-12 2023-06-12 Method and device for decoding bar code and electronic equipment

Country Status (1)

Country Link
CN (1) CN116432676B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595937A (en) * 2013-11-20 2014-02-19 北京象开科技有限公司 Bar code decoding system and method based on rolling shutter CMOS sensor
CN105631383A (en) * 2015-12-30 2016-06-01 福建联迪商用设备有限公司 Intelligent gating bar code decoding method and system
CN110930356A (en) * 2019-10-12 2020-03-27 上海交通大学 Industrial two-dimensional code reference-free quality evaluation system and method
WO2020067440A1 (en) * 2018-09-27 2020-04-02 シャープ株式会社 Moving image coding device and moving image decoding device
CN111881702A (en) * 2020-07-17 2020-11-03 深圳牛图科技有限公司 Multi-code rapid reading method based on YOLO-barQR algorithm
CN113591508A (en) * 2021-09-29 2021-11-02 广州思林杰科技股份有限公司 Bar code decoding method and device based on artificial intelligence target recognition and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595937A (en) * 2013-11-20 2014-02-19 北京象开科技有限公司 Bar code decoding system and method based on rolling shutter CMOS sensor
CN105631383A (en) * 2015-12-30 2016-06-01 福建联迪商用设备有限公司 Intelligent gating bar code decoding method and system
WO2020067440A1 (en) * 2018-09-27 2020-04-02 シャープ株式会社 Moving image coding device and moving image decoding device
CN110930356A (en) * 2019-10-12 2020-03-27 上海交通大学 Industrial two-dimensional code reference-free quality evaluation system and method
CN111881702A (en) * 2020-07-17 2020-11-03 深圳牛图科技有限公司 Multi-code rapid reading method based on YOLO-barQR algorithm
CN113591508A (en) * 2021-09-29 2021-11-02 广州思林杰科技股份有限公司 Bar code decoding method and device based on artificial intelligence target recognition and storage medium

Also Published As

Publication number Publication date
CN116432676A (en) 2023-07-14

Similar Documents

Publication Publication Date Title
CN110853047B (en) Intelligent image segmentation and classification method, device and computer readable storage medium
CN110147864B (en) Method and device for processing coding pattern, storage medium and electronic device
JP6423814B2 (en) Document image binarization method
CA2851598C (en) Apparatus and method for automatically recognizing a qr code
CN106560840B (en) A kind of image information identifying processing method and device
CN110572573A (en) Focusing method and device, electronic equipment and computer readable storage medium
CN111107370B (en) Video watermark embedding processing method and device, electronic equipment and storage medium
CN105631449B (en) A kind of picture segmentation method, device and equipment
JP5555672B2 (en) Image processing device
CN103942762A (en) Two-dimension code preprocessing method and device
CN112163120A (en) Classification method, terminal and computer storage medium
CN111696064B (en) Image processing method, device, electronic equipment and computer readable medium
CN111833285B (en) Image processing method, image processing device and terminal equipment
CN111259680B (en) Two-dimensional code image binarization processing method and device
CN110378860B (en) Method, device, computer equipment and storage medium for repairing video
JP2014206772A (en) Image processor, imaging device, monitoring system, encoder, and image processing method
CN109214229A (en) A kind of bar code scanning method, device and electronic equipment
CN106709393B (en) QR two-dimensional code binarization method and system
CN109145751B (en) Page turning detection method and device
JP3558985B2 (en) Color image processing method and apparatus
CN116432676B (en) Method and device for decoding bar code and electronic equipment
CN116432677B (en) Method and device for identifying bar code, controller and bar code identification terminal
CN108805873A (en) Image processing method and device
CN111311573B (en) Branch determination method and device and electronic equipment
CN113542617B (en) Method and device for acquiring code scanning image, code scanning equipment and storage medium

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