CN114298078B - Decoding method of stained one-dimensional bar code - Google Patents

Decoding method of stained one-dimensional bar code Download PDF

Info

Publication number
CN114298078B
CN114298078B CN202111644795.6A CN202111644795A CN114298078B CN 114298078 B CN114298078 B CN 114298078B CN 202111644795 A CN202111644795 A CN 202111644795A CN 114298078 B CN114298078 B CN 114298078B
Authority
CN
China
Prior art keywords
codeword
code
decoding
value
values
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
CN202111644795.6A
Other languages
Chinese (zh)
Other versions
CN114298078A (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.)
Hangzhou Synochip Data Security Technology Co ltd
Original Assignee
Hangzhou Synochip Data Security Technology 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 Hangzhou Synochip Data Security Technology Co ltd filed Critical Hangzhou Synochip Data Security Technology Co ltd
Priority to CN202111644795.6A priority Critical patent/CN114298078B/en
Publication of CN114298078A publication Critical patent/CN114298078A/en
Application granted granted Critical
Publication of CN114298078B publication Critical patent/CN114298078B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Error Detection And Correction (AREA)

Abstract

The invention provides a decoding method of a stained one-dimensional bar code, which belongs to the technical field of bar code identification and comprises the following steps: s1, acquiring a bar code image, and preprocessing the bar code image; s2, screening and positioning bar code areas of the bar code images; s3, scanning bar space information along the bar code direction by using a scanning line to obtain the width of each bar space of the bar code; s4, decoding according to the bar space width by utilizing a width measurement method and comparing a bar code character set coding table, and ending the flow if the decoding is successful; if the decoding fails, S5 is executed; s5, scanning the bar code area line by line, and calculating the maximum confidence coefficient of all the code words to obtain all code word values, wherein the code word values comprise: and decoding the codeword true value and the codeword missing value according to the number of the codeword missing values. The method obtains the true value of the code word by a method of calculating the maximum confidence through multiple times of scanning after the measurement of the strip space width fails in decoding, and calculates the missing value of the code word by using the true value of the code word so as to decode, thereby effectively improving the decoding success rate of the stained one-dimensional code.

Description

Decoding method of stained one-dimensional bar code
Technical Field
The invention relates to the technical field of bar code identification, in particular to a decoding method of a stained one-dimensional bar code.
Background
In the prior art, the barcode is often decoded by acquiring the barcode space width through the scanning line, the method needs to acquire more accurate barcode space width from the image to decode correctly, but in practical application, the barcode is frequently subjected to local pollution damage, and in the barcode identification process based on image information, the acquired barcode image is incomplete due to environmental factors such as illumination, so that each single-line scanning line scans an incomplete barcode, the acquired barcode space width is inaccurate, the correct decoding is difficult, and the decoding success rate is not high.
Disclosure of Invention
The technical problem of the invention is to provide a decoding method of a stained one-dimensional bar code, which can correctly identify the stained one-dimensional bar code to a certain extent.
In order to achieve the above purpose, the technical scheme adopted by the invention is as follows:
the decoding method of the stained one-dimensional bar code is characterized by comprising the following steps of: s1, acquiring a bar code image, and preprocessing the bar code image; s2, screening and positioning bar code areas of the bar code images; s3, scanning bar space information along the bar code direction by using a scanning line to obtain the width of each bar space of the bar code; s4, decoding according to the bar space width by utilizing a width measurement method and comparing a bar code character set coding table, and ending the flow if the decoding is successful; if the decoding fails, S5 is executed; s5, scanning the bar code area line by line, and calculating the maximum confidence coefficient of all the code words to obtain all the code word values, wherein the code word values comprise: and decoding the codeword true value and the codeword missing value according to the number of the codeword missing values.
S5 comprises the following steps: s51, searching out a start symbol, a stop symbol and a middle separator according to the space width, and determining the space data of the code word area; s52, forward and reverse decoding is carried out on the code words in the code word area row by row to obtain a code word data matrix; s53, calculating the confidence coefficient of each column of code word in the code word data matrix, obtaining the true value and the missing value of the code word, and decoding according to the number of the missing values of the code word.
S52 includes: s521, searching a character set coding table to perform forward decoding and reverse decoding on the strip-space data, and recording the numerical value of the codeword corresponding to the strip-space data error as Null; s532 repeatedly performs S52, scans line by line until the entire barcode region is traversed, generating a left codeword data matrix and a right codeword data matrix.
S53 includes: s531 counts the frequency of the occurrence of the numerical value of the code word represented by each column in the left code word data matrix and the right code word data matrix respectively, calculates the confidence coefficient of each numerical value, obtains the confidence coefficient maximum value of the code word represented by each column, judges whether the column confidence coefficient maximum value is larger than a threshold value, if so, judges that the numerical value corresponding to the confidence coefficient maximum value is the true value of the code word of the column, and continues to calculate the next column; otherwise, marking the code word represented by the column as a code word missing value, marking as Null, and continuing to calculate the next column until the last column of data is calculated, so as to obtain all code word values of the bar code; s532, counting the number of the codeword missing values obtained in S531, and if the number of the codeword missing values is greater than 1, failing decoding; if the number of the codeword missing values is equal to 1, calculating the codeword missing values according to the obtained codeword true values, and decoding successfully; if the number of the codeword missing values is equal to 0, calculating a correct check code according to all codeword values, and if the correct check code is matched with the codeword value of the check bit obtained in the step S531, decoding is successful; otherwise, executing S533; s533 compares the maximum confidence of all codewords obtained in S531, selects the minimum value, marks the codeword corresponding to the minimum value as a codeword missing value, and marks the codeword missing value as Null; and calculating a codeword missing value according to the obtained codeword true value, and decoding successfully.
In S532, if the number of codeword missing values is equal to 1 and the codeword missing values are check codes, the method for calculating codeword missing values according to the obtained codeword true values is as follows: s01, judging the parity of each codeword value at the left side of the bar code, and calculating the numerical value of the front bit of the bar code according to a parity coding table; s02, defining rightmost codeword bits as odd bits, defining rightmost codeword bits as even bits and sequentially and alternately defining parity of each codeword including the prefix bits from right to left; s03, summing the codeword values on the odd digits and multiplying the codeword values by 3 to obtain A, summing the codeword values on the even digits to obtain B, and calculating to obtain a result of A+B; s04, dividing the result of A+B in S03 by 10, if the result can be divided completely, the check code is 0, otherwise, the remainder is x, and the calculated value of (10-x) is the calculated check code, so that the decoding is successful.
In S532, if the number of codeword missing values is equal to 1 and the codeword missing values are not check codes, the method for calculating codeword missing values according to the obtained codeword true values is as follows: and (3) setting the initial value of the codeword missing value as 0, repeating the steps S01 to S04, comparing the obtained check code with the codeword value of the check bit obtained in the step S531, and if the result is inconsistent, sequentially adjusting the numerical value of the codeword missing value from 0 to 9 to calculate until the obtained check code is consistent with the codeword value comparison result of the check bit obtained in the step S531, and decoding is successful.
Drawings
The invention and its features, aspects and advantages will become more apparent from the detailed description of non-limiting embodiments with reference to the following drawings. Like numbers refer to like parts throughout. The drawings are not intended to be drawn to scale, emphasis instead being placed upon illustrating the principles of the invention.
FIG. 1 is a block diagram of a decoding method of a stained one-dimensional bar code provided by the invention;
FIG. 2 is a schematic diagram of a bar code construction;
fig. 3 is a schematic diagram of a single codeword character of a barcode.
Detailed Description
The invention will now be further described with reference to the accompanying drawings and specific examples, which are not intended to limit the invention.
A complete one-dimensional bar code is composed of two side static areas, a starter, a data symbol, a verifier and a terminator, and the structure diagram is shown in figure 2. A plurality of black bars and blanks with different widths are arranged according to a certain coding rule to express a group of information.
Common barcode scanning devices are typically composed of components such as a light source (e.g., laser), an optical lens, a photosensitive device (e.g., CCD, CMOS, etc.), decoding logic, and an I/O interface. In brief, the light source projects light onto the bar code, the light reflected from the bar code enters the surface of the photosensitive device through the optical lens, a series of treatments such as photoelectric conversion and analog-to-digital conversion are carried out to form a digital image of the bar code, then the decoding logic circuit analyzes and decodes the captured image, in the prior art, the method for decoding the one-dimensional bar code by acquiring the width of the bar space through the scanning line has larger requirements on the definition degree of the bar code, and the decoding success rate of the method is lower under the condition that the bar code is seriously stained.
The invention provides a decoding method of a stained one-dimensional bar code, which comprises the steps of firstly, collecting bar code images, preprocessing the bar code images, including denoising, binarization and the like; the bar code region screening and positioning are carried out on the bar code image after pretreatment; and scanning the successfully positioned bar code area line by line from top to bottom according to the bar code direction to obtain the bar space information of each line. As can be seen from the EAN13 coding rule, each codeword consists of two black bars and two white spaces, as shown in FIG. 3, C 1 、C 2 、C 3 、C 4 The width of the corresponding bar or void, respectively. After the decoding scanning line sweeps a row, acquiring the space-stripe width of the whole row, and normalizing the space-stripe width value to obtain space-stripe ratio data of each character of the row; according to the obtained space widthThe degree ratio information decodes the codeword. Referring to EAN13 bar code standard, searching character set coding table, each codeword value with numbers 0-9 has its corresponding bar space width ratio K LA (left-side odd code), K LB (left-side even code), K R And (right side code), comparing the obtained space-space width ratio with data in a coding table, determining a codeword value according to the similarity, storing codeword character data, and verifying whether a decoding result is correct by using a check bit codeword value.
If the decoding fails in the above process, as shown in fig. 1, scanning the bar code area line by line, searching the initiator, terminator and middle separator according to the bar space width, and determining the bar space data of the code word area; let the left codeword area stripe width (between the initiator and the middle separator) of the row be { C 1 ,C 2 ,...,C n Sequentially forward and backward decoding by searching a character set coding table, and respectively recording codeword data D obtained by decoding twice in different directions forward ={D f1 ,D f2 ,...,D f6 Sum D inverse ={D i1 ,D i2 ,...,D i6 }. If the corresponding stripe data errors in the k code word are solved and the stripe data errors can not be successfully solved, the current code word value D is recorded k =null, and then continue to solve the subsequent code words, and ensure that the left side and the right side of the bar code are both 6 code words according to the coding rule. Repeating the steps, traversing and scanning the whole bar code area image, counting the code word value of each row, and setting the left code word data matrix as X L The number of scans was n, at which time it was possible to obtain:
wherein each data is an integer codeword value or Null with a value of 0-9, the number of rows of the set X is 2n, and the number of columns is 6. The right codeword data matrix X can be obtained by the same way R . Then start counting X L And X R Data of each column, X L Data { D of column 1 1f1 ,D 1i1 ,...,D ni1 All measured values representing the first code word of the bar code except the preamble code, counting each row of data from column 1The frequency of occurrence of each value in (a) is used to obtain the frequency f of occurrence of 0,1, 9 in the values of the code words in the column respectively 0 ,f 1 ,...,f 9 (e.g., the number of codewords in the column is 1, k times, f 1 =k), and the number of codewords is the frequency f of occurrences of Null Null . From this, the confidence Conf of each possible value i of the code word character of the bar code can be obtained i The calculation formula is as follows:
calculate the column confidence Conf i And (3) the maximum value, the corresponding i value of which is the most frequently occurring in the list, is considered to be the codeword true value of the codeword in the row if the maximum confidence is greater than a threshold value T (taking T=0.3), and the codeword character corresponding to the row is successfully decoded. If the maximum confidence of the column is not greater than the threshold T, the decoding of the current codeword character fails, the current codeword data is marked as a codeword missing value, and the codeword missing value is marked as Null to continue to calculate the next column.
For X L And X R After all 12 codeword values of the bar code are calculated, counting the number of codeword missing values in the 12 codeword values, setting the number of codeword missing values as N, if N>And 1, indicating that the bar code information is seriously lost, and failing to decode and exiting. If n=0, the barcode decoding correctness is verified. According to the bar code coding rule, the 11-bit data symbol code word can calculate the correct check code, compare the code word values of the check bits obtained in the decoding process, if the comparison values are consistent, the decoding is successful, and the correct decoding result is output. When the check values are inconsistent, comparing the maximum confidence of each codeword in the decoding result, selecting the minimum value, marking the corresponding codeword as a codeword missing value, marking as Null, calculating the codeword missing value according to the obtained codeword true value, and decoding successfully.
When n=1, the remaining 11-bit codeword values are considered to be true and reliable, and according to the coding rule, the true value of the codeword missing value can be calculated through the 11-bit codeword values, the calculation method refers to the commodity barcode national standard GB12904-2003, and when the codeword missing value is a check code, the specific calculation method is as follows:
s01, judging the parity of each codeword value at the left side of the bar code, and calculating the numerical value of the front bit of the bar code according to a parity coding table;
s02, defining rightmost codeword bits as odd bits, defining rightmost codeword bits as even bits and sequentially and alternately defining parity of each codeword including the prefix bits from right to left;
s03, summing the codeword values on the odd digits and multiplying the codeword values by 3 to obtain A, summing the codeword values on the even digits to obtain B, and calculating to obtain a result of A+B;
s04, dividing the result of A+B in S03 by 10, if the result can be divided completely, the check code is 0, otherwise, the remainder is x, and the calculated value of (10-x) is the calculated check code, so that the decoding is successful.
If the number of the codeword missing values is n=1 and the codeword missing values are not check codes, the method for calculating the codeword missing values according to the obtained codeword true values is as follows: and (3) setting the initial value of the codeword missing value as 0, repeating the steps S01 to S04, comparing the obtained check code with the codeword value of the check bit obtained in the step S531, and if the result is inconsistent, sequentially adjusting the numerical value of the codeword missing value from 0 to 9 to calculate until the obtained check code is consistent with the codeword value comparison result of the check bit obtained in the step S531, and decoding is successful.
In summary, the method for counting the codeword value with the maximum confidence and the method for calculating the codeword value by using the multi-row scanning information effectively improve the decoding success rate of the dirty code, and the algorithm process is not complex, has smaller calculated amount and is suitable for practical application scenes.
The foregoing describes preferred embodiments of the present invention; it is to be understood that the invention is not limited to the specific embodiments described above, wherein devices and structures not described in detail are to be understood as being implemented in a manner common in the art; any person skilled in the art will make many possible variations and modifications, or adaptations to equivalent embodiments without departing from the technical solution of the present invention, which do not affect the essential content of the present invention; therefore, any simple modification, equivalent variation and modification of the above embodiments according to the technical substance of the present invention still fall within the scope of the technical solution of the present invention.

Claims (3)

1. The decoding method of the stained one-dimensional bar code is characterized by comprising the following steps of:
s1, acquiring a bar code image, and preprocessing the bar code image;
s2, screening and positioning bar code areas of the bar code images;
s3, scanning bar space information along the bar code direction by using a scanning line to obtain the width of each bar space of the bar code;
s4, decoding according to the bar space width by utilizing a width measurement method and comparing a bar code character set coding table, and ending the flow if the decoding is successful; if the decoding fails, S5 is executed;
s5, scanning the bar code area line by line, and calculating the maximum confidence coefficient of all the code words to obtain all code word values, wherein the code word values comprise: decoding the true value and the missing value of the code word according to the number of the missing values of the code word; the method specifically comprises the following steps:
s51, searching out a start symbol, a stop symbol and a middle separator according to the space width, and determining the space data of the code word area;
s52, forward and reverse decoding is carried out on the code words in the code word area row by row to obtain a code word data matrix; the method comprises the following steps:
s521, searching a character set coding table to perform forward decoding and reverse decoding on the strip-space data, and recording the numerical value of the codeword corresponding to the strip-space data error as Null;
s532 repeatedly executing the S52, scanning line by line until the whole bar code area is traversed, and generating a left codeword data matrix and a right codeword data matrix;
s53, calculating the confidence coefficient of each column of code words in the code word data matrix, obtaining the true values and the missing values of all the code words, and decoding according to the number of the missing values of the code words; the method comprises the following steps:
s531 counts the frequency of the occurrence of the numerical value of the code word represented by each column in the left code word data matrix and the right code word data matrix respectively, calculates the confidence coefficient of each numerical value, obtains the confidence coefficient maximum value of the code word represented by each column, judges whether the column confidence coefficient maximum value is larger than a threshold value, if so, judges that the numerical value corresponding to the confidence coefficient maximum value is the true value of the code word of the column, and continues to calculate the next column; otherwise, marking the code word represented by the column as a code word missing value, marking as Null, and continuing to calculate the next column until the last column of data is calculated, so as to obtain all code word values of the bar code;
s532, counting the number of the codeword missing values obtained in the S531, and if the number of the codeword missing values is greater than 1, failing decoding; if the number of the codeword missing values is equal to 1, calculating the codeword missing values according to the obtained codeword true values, and decoding successfully;
if the number of the codeword missing values is equal to 0, calculating a correct check code according to all codeword values, and if the correct check code is matched with the codeword value of the check bit obtained in the step S531, decoding is successful; otherwise, executing S533;
s533 compares the maximum confidence degrees of all the codewords obtained in the S531, selects the minimum value, marks the codeword corresponding to the minimum value as a codeword missing value, and marks the codeword missing value as Null; and calculating a codeword missing value according to the obtained codeword true value, and decoding successfully.
2. The method for decoding a dirty one-dimensional code according to claim 1, wherein in S532, if the number of codeword missing values is equal to 1 and the codeword missing values are check codes, the method for calculating the codeword missing values according to the obtained codeword true values is as follows:
s01, judging the parity of each codeword value at the left side of the bar code, and calculating the numerical value of the front bit of the bar code according to a parity coding table;
s02, defining rightmost codeword bits as odd bits, defining rightmost codeword bits as even bits and sequentially and alternately defining parity of each codeword including the prefix bits from right to left;
s03, summing the codeword values on the odd digits and multiplying the codeword values by 3 to obtain A, summing the codeword values on the even digits to obtain B, and calculating to obtain a result of A+B;
s04, dividing the result of the A+B in the S03 by 10, if the result is divided completely, the check code is 0, otherwise, setting the remainder as x, calculating the value of (10-x) as the calculated check code, and decoding successfully.
3. The method for decoding a dirty one-dimensional code according to claim 2, wherein in S532, if the number of codeword missing values is equal to 1 and the codeword missing values are not check codes, the method for calculating the codeword missing values according to the obtained codeword true values is as follows:
and (3) setting the initial value of the codeword missing value to be 0, repeating the steps from S01 to S04, comparing the obtained check code with the codeword value of the check bit obtained in the step S531, and if the result is inconsistent, sequentially adjusting the numerical value of the codeword missing value from 0 to 9 to calculate until the obtained check code is consistent with the codeword value comparison result of the check bit obtained in the step S531, wherein the decoding is successful.
CN202111644795.6A 2021-12-29 2021-12-29 Decoding method of stained one-dimensional bar code Active CN114298078B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111644795.6A CN114298078B (en) 2021-12-29 2021-12-29 Decoding method of stained one-dimensional bar code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111644795.6A CN114298078B (en) 2021-12-29 2021-12-29 Decoding method of stained one-dimensional bar code

Publications (2)

Publication Number Publication Date
CN114298078A CN114298078A (en) 2022-04-08
CN114298078B true CN114298078B (en) 2023-10-24

Family

ID=80972581

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111644795.6A Active CN114298078B (en) 2021-12-29 2021-12-29 Decoding method of stained one-dimensional bar code

Country Status (1)

Country Link
CN (1) CN114298078B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5243655A (en) * 1990-01-05 1993-09-07 Symbol Technologies Inc. System for encoding and decoding data in machine readable graphic form
CN101840500A (en) * 2010-06-01 2010-09-22 福建新大陆电脑股份有限公司 Device based on confidence for code word decoding and method
CN104361309A (en) * 2014-12-05 2015-02-18 网易宝有限公司 Bar code identifying method and bar code identifying equipment
CN110874538A (en) * 2018-08-29 2020-03-10 杭州海康威视数字技术股份有限公司 Method and device for evaluating decoding result of bar code and electronic equipment
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5243655A (en) * 1990-01-05 1993-09-07 Symbol Technologies Inc. System for encoding and decoding data in machine readable graphic form
CN101840500A (en) * 2010-06-01 2010-09-22 福建新大陆电脑股份有限公司 Device based on confidence for code word decoding and method
CN104361309A (en) * 2014-12-05 2015-02-18 网易宝有限公司 Bar code identifying method and bar code identifying equipment
CN110874538A (en) * 2018-08-29 2020-03-10 杭州海康威视数字技术股份有限公司 Method and device for evaluating decoding result of bar code and electronic equipment
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
条码识别技术研究及其在产品流水线上的应用;张闯;《中国优秀硕士学位论文全文数据库 信息科技辑》(第05期);论文第17、37-48页 *

Also Published As

Publication number Publication date
CN114298078A (en) 2022-04-08

Similar Documents

Publication Publication Date Title
US7546950B2 (en) Method and apparatus for locating and decoding a two-dimensional machine-readable symbol
US8326037B1 (en) Methods and apparatus for locating an object in an image
US7172124B2 (en) Camera-based barcode recognition
US8733649B2 (en) Data matrix decoding chip and decoding method thereof
US7273177B2 (en) Camera-based barcode recognition
EP1278151A2 (en) High speed image acquisition system and method
EP2393038A1 (en) Matrix-type two-dimensional barcode decoding chip and decoding method thereof
JP3115003B2 (en) Method and apparatus for decoding barcode symbols using module size ratio analysis
WO2013044875A1 (en) Linear barcode identification method and system
CN111783495B (en) Bar code identification method and device, electronic equipment and storage medium
CN111339797B (en) Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN111046996B (en) Color QR code generation and identification method
CN107247985B (en) Coding, positioning and identifying method of two-dimensional code
US20120085823A1 (en) Stacked barcode reader and stacked barcode reading method
US9361504B2 (en) Optical information reading device, optical information reading method, computer-readable program and recording medium
CN109657515B (en) Decoding method and device for one-dimensional bar code
CN106446732A (en) Barcode identification method, device and equipment
CN114417904A (en) Bar code identification method based on deep learning and book retrieval system
JP2012058776A (en) Bar code reading device and method
CN114298078B (en) Decoding method of stained one-dimensional bar code
CN112733568B (en) One-dimensional bar code recognition method, device, equipment and storage medium
KR100498683B1 (en) A character recognition apparatus, a character recognition method, and a computer-readable storage medium recording a character recognition apparatus
JP5379626B2 (en) Stack bar code information reading method and stack bar code information reading device
CN111274841B (en) Identification method and device for bar codes
CN111368576A (en) Code128 bar Code automatic reading method based on global optimization

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