CN114298078A - Decoding method for stained one-dimensional bar code - Google Patents

Decoding method for stained one-dimensional bar code Download PDF

Info

Publication number
CN114298078A
CN114298078A CN202111644795.6A CN202111644795A CN114298078A CN 114298078 A CN114298078 A CN 114298078A CN 202111644795 A CN202111644795 A CN 202111644795A CN 114298078 A CN114298078 A CN 114298078A
Authority
CN
China
Prior art keywords
code
code word
decoding
values
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111644795.6A
Other languages
Chinese (zh)
Other versions
CN114298078B (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

Images

Landscapes

  • Error Detection And Correction (AREA)

Abstract

The invention provides a method for decoding a stained one-dimensional bar code, which belongs to the technical field of bar code identification and comprises the following steps: s1, collecting a bar code image, and preprocessing the bar code image; s2, screening and positioning the bar code image in the bar code area; 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 using a width measurement method and comparing the bar code character set code table, and if the decoding is successful, ending the process; if the decoding fails, go to S5; s5 scans the barcode region line by line, and calculates the maximum confidence of all codewords to obtain all codeword values, where the codeword values include: and decoding the real values and the missing values of the code words according to the number of the missing values of the code words. According to the method, the code word true value is obtained by a method of calculating the maximum confidence coefficient through multiple scanning after the strip space width measurement decoding fails, and the code word missing value is calculated by using the code word true value so as to decode, so that the decoding success rate of the contaminated one-dimensional code is effectively improved.

Description

Decoding method for stained one-dimensional bar code
Technical Field
The invention relates to the technical field of bar code identification, in particular to a decoding method for a stained one-dimensional bar code.
Background
In the prior art, the bar space width is often acquired through the scanning line to decode the one-dimensional bar code, the method needs to acquire the more accurate bar space width from the image to correctly decode the bar code, but in practical application, the bar code is frequently damaged by local pollution, and in the bar code identification process based on image information, environmental factors such as illumination can also cause the acquired bar code image to be incomplete, so that each single-line scanning line scans the incomplete bar code, the acquired bar space width is inaccurate, the correct decoding is difficult, and the decoding success rate is not high.
Disclosure of Invention
The invention aims to provide a decoding method for a stained one-dimensional bar code, which can correctly identify the stained one-dimensional bar code to a certain degree.
In order to achieve the purpose, the invention adopts the technical scheme that:
a decoding method for a stained one-dimensional bar code is characterized by comprising the following steps: s1, collecting a bar code image, and preprocessing the bar code image; s2, screening and positioning the bar code image in the bar code area; 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 using a width measurement method and comparing the bar code character set code table, and if the decoding is successful, ending the process; if the decoding fails, go to S5; s5 scans the barcode region line by line, calculates the maximum confidence of all codewords, and obtains all codeword values, where the codeword values include: and decoding the real values and the missing values of the code words according to the number of the missing values of the code words.
S5 includes: s51 finding out the start character, the end character and the middle separator according to the width of the bar space, and determining the bar space data in the code word area; s52, decoding the code words in the code word area line by line in the forward and reverse directions to obtain a code word data matrix; s53, calculating the confidence of each row of code words in the code word data matrix, obtaining the true values and the missing values of all code words, and decoding according to the number of the missing values of the code words.
S52 includes: s521, searching a character set coding table to perform forward decoding and reverse decoding on the strip-empty data, and recording the numerical value of the code word corresponding to the error of the strip-empty data as Null; s532 repeats S52, scanning 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 respectively counting the frequency of occurrence of numerical values of codewords represented by each column in the left codeword data matrix and the right codeword data matrix, calculating the confidence coefficient of each numerical value to obtain the maximum confidence coefficient of codewords represented by each column, judging whether the maximum confidence coefficient of the column is greater than a threshold value, if so, judging that the numerical value corresponding to the maximum confidence coefficient is the true value of the codewords of the column, and continuing to calculate the next column; otherwise, marking the code word represented by the row as a code word missing value, recording the code word as Null, and continuously calculating the next row until the last row of data is calculated to obtain all code word values of the bar code; s532, counting the number of the code word missing values obtained in S531, and if the number of the code word missing values is greater than 1, failing to decode; if the number of the code word missing values is equal to 1, calculating the code word missing values according to the obtained code word true values, and successfully decoding; if the number of the missing values of the code words is equal to 0, calculating a correct check code according to all the code word values, and if the correct check code is matched with the code word value of the check bit obtained in the step S531, successfully decoding; otherwise, executing S533; s533 comparing the maximum confidence of all the code words obtained in S531, selecting the minimum value, marking the code word corresponding to the minimum value as a code word missing value, and marking as Null; and calculating a code word missing value according to the obtained code word true value, and successfully decoding.
In S532, if the number of missing codewords is equal to 1 and the missing codewords are check codes, the method for calculating the missing codewords according to the obtained true codewords comprises: s01, judging the parity of each code word value on the left side of the bar code, and calculating the numerical value of the preposed position of the bar code according to the parity coding table; s02, defining the rightmost code word position as an odd number position, the code word position before the rightmost code word position as an even number position, and defining the parity of each code word including the front position from right to left in turn; s03, summing the code word values on the odd-numbered positions and multiplying by 3 to obtain A, summing the code word values on the even-numbered positions to obtain B, and calculating to obtain the result of A + B; s04 divides the result of S503 by 10, if the result is divisible, the check code is 0, otherwise, the remainder is x, and the calculated (10-x) value is the found check code, and the decoding is successful.
In S532, if the number of missing codewords is equal to 1 and the missing codewords are not check codes, the method for calculating the missing codewords according to the obtained true codewords comprises: and (4) setting the initial value of the code word missing value as 0, repeating S01 to S04, comparing the obtained check code with the code word value of the check bit obtained in S531, if the result is inconsistent, sequentially adjusting the numerical value of the code word missing value from 0 to 9 for calculation until the obtained check code is consistent with the code word value comparison result of the check bit obtained in S531, and successfully decoding.
Drawings
The invention and its features, aspects and advantages will become more apparent from reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings. Like reference symbols in the various drawings indicate like elements. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating the principles of the invention.
FIG. 1 is a block diagram of a decoding method for a stained one-dimensional bar code according to the present invention;
FIG. 2 is a schematic view of a barcode structure;
figure 3 is a schematic diagram of a single code word character of a barcode.
Detailed Description
The invention will be further described with reference to the following drawings and specific examples, which are not intended to limit the invention thereto.
A complete one-dimensional bar code consists of two side static areas, a start symbol, a data symbol, a check symbol and a stop symbol, 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.
A typical barcode scanning device is generally composed of a light source (such as a laser), an optical lens, a photosensitive device (e.g., CCD, CMOS, etc.), a decoding logic circuit, and an I/O interface. Briefly, 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 digital image of the bar code is formed after a series of processing such as photoelectric conversion and analog-to-digital conversion, and then the decoding logic circuit analyzes and decodes the captured image.
The invention provides a decoding method of a stained one-dimensional bar code, firstly collecting a bar code image, and preprocessing the bar code image, including denoising, binaryzation and the like; screening and positioning a bar code region of the preprocessed bar code image; and scanning the successfully positioned bar code area line by line from top to bottom according to the bar code direction to obtain bar space information of each line. As known from the coding rule of EAN13, each codeword is composed of two black bars and two white spaces, as shown in FIG. 3, C1、C2、C3、C4The width of the corresponding bar or space, respectively. After the scanning line is scanned by one line, the strip-space width of the whole line is obtained, and the strip-space ratio data of each character of the line is obtained after the strip-space width value is normalized; and solving the code word according to the acquired information of the strip space width ratio. Looking up a character set coding table by referring to EAN13 bar code standard, wherein each code word value of the numbers 0-9 has a corresponding bar space width ratio KLA(left-hand singular code), KLB(left side parity code), KR(right code), comparing the obtained strip space width ratio with data in the coding table, determining a code word value according to the similarity, storing code word character data, and verifying whether the decoding result is correct or not by using the check digit code word value.
If the decoding fails in the process, scanning the bar code region line by line as shown in fig. 1, finding out an initial character, a termination character and a middle separator according to the width of the bar space, and determining the bar space data in the code word region; let the code word stripe width on the left side of the row (between the start symbol and the middle separator) be { C1,C2,...,CnSearching a character set coding table to sequentially perform forward decoding and reverse decoding, and respectively recording code word data D obtained by twice decoding in different directionsforward={Df1,Df2,...,Df6And Dinverse={Di1,Di2,...,Di6}. If the corresponding strip empty data error can not be successfully solved when the kth code word is solved, recording the numerical value D of the current code wordkAnd (4) continuing to solve the subsequent code words, and ensuring that the left side and the right side of the bar code are 6 code words according to the coding rule. Repeating the steps, traversing and scanning the whole barcode region image, counting the code word value of each line, and setting a left sideThe side codeword data matrix is XLThe number of scanning times is n, and then:
Figure BDA0003443715030000041
each data is an integer codeword value or Null with a value of 0-9, the number of rows in the set X is 2n, and the number of columns is 6. The right code word data matrix X can be obtained by the same methodR. Then start to count XLAnd XRData of each column, XLData in column 1 { D1f1,D1i1,...,Dni1The codes represent all measured values of the first code word of the bar code except the prefix, and the frequency f of each numerical value in each row of data is counted from the 1 st row to obtain the frequency f of each numerical value in the row of code words of 0,1, 90,f1,...,f9(e.g., the value of the column of codewords is 1 and k times, then f1K) and the number of codewords is the frequency f of occurrence of NullNull. From this, the confidence factor Conf of each possible value i of the code word character of the row of the bar code can be obtainediThe calculation formula is as follows:
Figure BDA0003443715030000051
the calculated confidence factor Conf of the columniIf the maximum confidence coefficient is greater than a threshold value T (T is 0.3), i in the maximum confidence coefficient is considered to be the true value of the codeword in the row of codewords, and the codeword character corresponding to the row is successfully decoded. If the maximum confidence of the row is not larger than the threshold value T, the decoding of the current code word character fails, the current code word data is marked as a code word missing value and is marked as Null, and the next row is calculated continuously.
To XLAnd XRAfter all 12 code word values of the bar code are calculated, counting the number of code word missing values in the 12 code word values, setting the number of the code word missing values as N, and if N is the number of the code word missing values, counting the number of the code word missing values>1, the barcode information is seriously lost, the decoding fails and quits. If N is equal to 0, pairAnd verifying the decoding correctness of the bar code. According to the bar code coding rule, the correct check code can be calculated by the 11-bit data character code word, the check code is compared with the code word value of the check bit obtained in the decoding process, if the comparison numerical values are consistent, the decoding is successful, and the correct decoding result is output. And when the check values are inconsistent, comparing the maximum confidence coefficient of each code word in the decoding result, selecting the minimum value, marking the code word corresponding to the minimum value as a code word missing value, recording the code word missing value as Null, calculating the code word missing value according to the obtained code word true value, and successfully decoding.
When N is 1, the other 11-bit code word values are considered to be true and reliable, then according to the encoding rule, the 11-bit code word values can be used for calculating the true numerical value of the code word missing value, the calculation method refers to the national standard GB12904-2003 of commodity bar codes, and when the code word missing value is a check code, the specific calculation method is as follows:
s01, judging the parity of each code word value on the left side of the bar code, and calculating the numerical value of the preposed position of the bar code according to the parity coding table;
s02, defining the rightmost code word position as an odd number position, the code word position before the rightmost code word position as an even number position, and defining the parity of each code word including the front position from right to left in turn;
s03, summing the code word values on the odd-numbered positions and multiplying by 3 to obtain A, summing the code word values on the even-numbered positions to obtain B, and calculating to obtain the result of A + B;
s04 divides the result of S503 by 10, if the result is divisible, the check code is 0, otherwise, the remainder is x, and the calculated (10-x) value is the found check code, and the decoding is successful.
If the number N of the missing codeword values is 1 and the missing codeword values are not check codes, the method for calculating the missing codeword values according to the obtained true codeword values comprises the following steps: and (4) setting the initial value of the code word missing value as 0, repeating S01 to S04, comparing the obtained check code with the code word value of the check bit obtained in S531, if the result is inconsistent, sequentially adjusting the numerical value of the code word missing value from 0 to 9 for calculation until the obtained check code is consistent with the code word value comparison result of the check bit obtained in S531, and successfully decoding.
In summary, the method for calculating the codeword value by using the statistical maximum confidence codeword value and the method for calculating the codeword value by using the multi-line scanning information effectively improve the decoding success rate of the dirty code, and the algorithm process is not complicated, has small calculation amount, and is suitable for practical application scenarios.
The above description is of the preferred embodiment of the invention; it is to be understood that the invention is not limited to the particular embodiments described above, in that devices and structures not described in detail are understood to be implemented in a manner common in the art; any person skilled in the art can make many possible variations and modifications, or modify equivalent embodiments, without departing from the technical solution of the invention, without affecting the essence of the invention; therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention are still within the scope of the protection of the technical solution of the present invention, unless the contents of the technical solution of the present invention are departed.

Claims (6)

1. A decoding method for a stained one-dimensional bar code is characterized by comprising the following steps:
s1, collecting a bar code image, and preprocessing the bar code image;
s2, screening and positioning the bar code image in the bar code area;
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 using a width measurement method and comparing the bar code character set code table, and if the decoding is successful, ending the process; if the decoding fails, go to S5;
s5 scans the barcode region line by line, and calculates the maximum confidence of all codewords to obtain all codeword values, where the codeword values include: and decoding the real values and the missing values of the code words according to the number of the missing values of the code words.
2. The method for decoding the contaminated one-dimensional code according to claim 1, wherein said S5 includes:
s51 finding out the start character, the end character and the middle separator according to the width of the bar space, and determining the bar space data in the code word area;
s52, decoding the code words in the code word area line by line in the forward and reverse directions to obtain a code word data matrix;
s53, calculating the confidence of each row of code words in the code word data matrix, obtaining the true values and the missing values of all code words, and decoding according to the number of the missing values of the code words.
3. The method for decoding the contaminated one-dimensional code according to claim 2, wherein said S52 includes:
s521, searching a character set coding table to perform forward decoding and reverse decoding on the strip-empty data, and recording the numerical value of the code word corresponding to the error of the strip-empty data as Null;
s532 repeats the step of S52, and scans line by line until the entire barcode region is traversed, generating a left codeword data matrix and a right codeword data matrix.
4. The method for decoding the contaminated one-dimensional code according to claim 3, wherein said S53 includes:
s531 respectively counting the frequency of occurrence of numerical values of codewords represented by each column in the left codeword data matrix and the right codeword data matrix, calculating the confidence coefficient of each numerical value to obtain the maximum confidence coefficient of codewords represented by each column, judging whether the maximum confidence coefficient of the column is greater than a threshold value, if so, judging that the numerical value corresponding to the maximum confidence coefficient is the true value of the codewords of the column, and continuing to calculate the next column; otherwise, marking the code word represented by the row as a code word missing value, recording the code word as Null, and continuously calculating the next row until the last row of data is calculated to obtain all code word values of the bar code;
s532, counting the number of the code word missing values obtained in the S531, and if the number of the code word missing values is more than 1, failing to decode; if the number of the code word missing values is equal to 1, calculating the code word missing values according to the obtained code word true values, and successfully decoding; if the number of the missing values of the code words is equal to 0, calculating a correct check code according to all the code word values, and if the correct check code is matched with the code word value of the check bit obtained in the step S531, successfully decoding; otherwise, executing S533;
s533 comparing the maximum confidence of all the code words obtained in S531, selecting the minimum value, marking the code word corresponding to the minimum value as a code word missing value, and marking as Null; and calculating a code word missing value according to the obtained code word true value, and successfully decoding.
5. The method as claimed in claim 4, wherein in S532, if the number of missing codeword values is equal to 1 and the missing codeword values are check codes, the method for calculating the missing codeword values according to the obtained true codeword values comprises:
s01, judging the parity of each code word value on the left side of the bar code, and calculating the numerical value of the preposed position of the bar code according to the parity coding table;
s02, defining the rightmost code word position as an odd number position, the code word position before the rightmost code word position as an even number position, and defining the parity of each code word including the front position from right to left in turn;
s03, summing the code word values on the odd-numbered positions and multiplying by 3 to obtain A, summing the code word values on the even-numbered positions to obtain B, and calculating to obtain the result of A + B;
s04 divides the result of S503 by 10, if the result is divisible, the check code is 0, otherwise, the remainder is x, and the calculated (10-x) value is the found check code, and the decoding is successful.
6. The method as claimed in claim 5, wherein in S532, if the number of missing values of the codeword is equal to 1 and the missing value of the codeword is not a check code, the method for calculating the missing value of the codeword according to the obtained true value of the codeword comprises:
and setting the initial value of the code word missing value as 0, repeating the steps from S01 to S04, comparing the obtained check code with the code word value of the check bit obtained in the step S531, and if the result is inconsistent, sequentially adjusting the numerical value of the code word missing value from 0 to 9 for calculation until the comparison result of the obtained check code and the code word value of the check bit obtained in the step S531 is consistent, and successfully decoding.
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 true CN114298078A (en) 2022-04-08
CN114298078B 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
张闯: "条码识别技术研究及其在产品流水线上的应用", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 05, pages 37 - 48 *

Also Published As

Publication number Publication date
CN114298078B (en) 2023-10-24

Similar Documents

Publication Publication Date Title
US7546950B2 (en) Method and apparatus for locating and decoding a two-dimensional machine-readable symbol
EP1016027B1 (en) Distortion resistant double-data correcting color transition barcode and method of generating and using same
US8733649B2 (en) Data matrix decoding chip and decoding method thereof
US8550352B2 (en) QR barcode decoding chip and decoding method thereof
EP1086439B1 (en) Techniques for reading postal codes
US4074114A (en) Bar code and method and apparatus for interpreting the same
EP2393038A1 (en) Matrix-type two-dimensional barcode decoding chip and decoding method thereof
EP1278151A2 (en) High speed image acquisition system and method
JP3115003B2 (en) Method and apparatus for decoding barcode symbols using module size ratio analysis
KR20040014336A (en) Methods and systems for encoding and decoding data in 2d symbology
JPH0612515A (en) Method and apparatus for decoding two-dimensional bar code using ccd/cmd camera
CN107247985B (en) Coding, positioning and identifying method of two-dimensional code
CN111783495B (en) Bar code identification method and device, electronic equipment and storage medium
CN109657515B (en) Decoding method and device for one-dimensional bar code
CN111339797B (en) Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
US8333326B2 (en) Stacked barcode reader and stacked barcode reading method
US9070033B2 (en) Stack barcode reader and stack barcode reading method
US9361504B2 (en) Optical information reading device, optical information reading method, computer-readable program and recording medium
US6102295A (en) Method and apparatus for decoding symbols by declaring erasures of element characteristics
CN106446732A (en) Barcode identification method, device and equipment
CN114417904A (en) Bar code identification method based on deep learning and book retrieval system
US5393968A (en) Method and device for reading bar code
US5929420A (en) Method for reading distorted bar codes
CN114298078A (en) Decoding method for stained one-dimensional bar code
JP5379626B2 (en) Stack bar code information reading method and stack bar code information reading device

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