CN110222547B - Bar code identification method and device - Google Patents

Bar code identification method and device Download PDF

Info

Publication number
CN110222547B
CN110222547B CN201910357591.0A CN201910357591A CN110222547B CN 110222547 B CN110222547 B CN 110222547B CN 201910357591 A CN201910357591 A CN 201910357591A CN 110222547 B CN110222547 B CN 110222547B
Authority
CN
China
Prior art keywords
decoding
column
row
bar code
barcode
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
CN201910357591.0A
Other languages
Chinese (zh)
Other versions
CN110222547A (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 Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online 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 Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN201910357591.0A priority Critical patent/CN110222547B/en
Publication of CN110222547A publication Critical patent/CN110222547A/en
Application granted granted Critical
Publication of CN110222547B publication Critical patent/CN110222547B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (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)
  • Character Discrimination (AREA)

Abstract

The embodiment of the disclosure provides a barcode identification method and a barcode identification device. The method comprises the following steps: collecting a bar code image corresponding to a bar code, and executing a first decoding operation on bar code characters of a specified row/column in a middle area of the bar code image by adopting a ZBar decoding mode; under the condition that the first decoding operation fails, extracting binarization features corresponding to the bar code characters of the specified row/column, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode; judging whether the designated row/column is located in a preset middle area or not under the condition that the second decoding operation fails; under the condition that the appointed row/column is positioned in a preset middle area, performing third decoding operation on the bar code characters of the appointed row/column by adopting a ZXing decoding mode; and under the condition that the third decoding operation is successful, acquiring a decoding result corresponding to the bar code image. The embodiment of the disclosure can improve the identification speed of the single-frame bar code image and the success rate of bar code identification.

Description

Bar code identification method and device
Technical Field
The embodiment of the disclosure relates to the technical field of barcode identification, in particular to a barcode identification method and device.
Background
The bar code is a one-dimensional code, and is a graphic identifier which is compiled by bars (black) and spaces (white) with different widths and different reflectivity according to a certain coding rule and is used for expressing a group of numbers, a group of letters or a group of symbol information formed by mixing the numbers and the letters.
At present, a plurality of merchants or consumers scan commodity bar codes through cameras of mobile terminals for different application scenes, such as commodity entry and self-service checkout. At present, the mainstream barcode scanning methods disclosed in the prior art are divided into two methods, namely barcode identification based on the open source library ZXing and barcode identification based on the open source library ZBar.
ZBar extracts the barcode features row by row and column by column based on calculating the image gradient and attempts decoding, which has the advantage of much higher barcode recognition rate than ZXing which only cuts barcode features based on pixel values.
The code scanning sequence of the ZBAR starts from the first line of the image, and the decoding is carried out line by line, when the bar code result is successfully analyzed in a certain line, the next line can be continuously solved until all lines of the whole image are completely solved. At the moment, the ZBAR performs post-processing on all the first decoding results, and the first decoding result with the highest reliability is screened out to be output, so that the decoding accuracy can be improved to a certain extent. When all the rows fail to attempt decoding, decoding is performed column by column starting from the first column. The step of decoding by row is repeated. For ZBar, the most important disadvantage is that a decoding attempt must be made for each row/column in the whole image, and then the decoded result is post-processed, so that the barcode recognition speed is slow, and the barcode recognition time is increased.
Disclosure of Invention
The embodiment of the disclosure provides a barcode identification method and a barcode identification device, which are used for improving the barcode identification speed and reducing the barcode identification time.
According to a first aspect of embodiments of the present disclosure, there is provided a barcode identification method, including: collecting a bar code image corresponding to a bar code, and executing a first decoding operation on bar code characters of a specified row/column in a middle area of the bar code image by adopting a ZBar decoding mode; under the condition that the first decoding operation fails, extracting binarization features corresponding to the bar code characters of the specified row/column, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode; judging whether the designated row/column is located in a preset middle area or not under the condition that the second decoding operation fails; under the condition that the appointed row/column is positioned in a preset middle area, performing third decoding operation on the bar code characters of the appointed row/column by adopting a ZXing decoding mode; and under the condition that the third decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
Preferably, the barcode characters include a barcode and characters, and the step of performing a first decoding operation on the barcode characters in a designated row/column in a middle region of the barcode image in a ZBar decoding manner includes: adjusting the width ratio of the bar code corresponding to the bar code character of the appointed row/column to the character to be a width ratio threshold value; and executing the first decoding operation on the adjusted bar code characters of the appointed row/column by adopting the ZBAR decoding mode.
Preferably, the width ratio threshold is 3/8.
Preferably, after the step of performing a first decoding operation on the barcode characters in the designated row/column in the middle region of the barcode image by using a ZBar decoding manner, the method further includes: under the condition that the first decoding operation is successful, acquiring a decoding result corresponding to the bar code image; after the step of performing the second decoding operation on the binarized feature in the ZBar decoding manner, the method further includes: and under the condition that the second decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
Preferably, after the step of performing the third decoding operation on the barcode characters of the designated row/column by adopting the ZXing decoding manner, the method further includes: under the condition that the third decoding operation fails, acquiring a first row/column of bar code characters behind the bar code characters of the appointed row/column or a second row/column of bar code characters in front of the bar code characters of the appointed row/column; performing a fourth decoding operation on the bar code characters of the first row/column or the bar code characters of the second row/column by adopting the ZBar decoding mode; under the condition that the fourth decoding operation is successful, a decoding result corresponding to the bar code image is obtained; under the condition that the fourth decoding operation fails, extracting sub-binarization characteristics corresponding to the bar code characters of the first row/column or the bar code characters of the second row/column; performing a fifth decoding operation on the sub-binarization characteristics by adopting the ZBAR decoding mode; under the condition that the fifth decoding operation is successful, a decoding result corresponding to the bar code image is obtained; judging whether the first row/column or the second row/column is located in the preset middle area or not under the condition that the fifth decoding operation fails; when the first row/column or the second row/column is located in the preset middle area, performing a sixth decoding operation on the barcode characters of the first row/column or the barcode characters of the second row/column by adopting the ZXing decoding mode; under the condition that the sixth decoding operation is successful, a decoding result corresponding to the bar code image is obtained; and under the condition that the sixth decoding operation fails, acquiring a third row/column of barcode characters behind or before the first row/column of barcode characters, or a fourth row/column of barcode characters behind or before the second row/column of barcode characters, and performing the steps on the third row/column of barcode characters or the fourth row/column of barcode characters.
Preferably, after the step of acquiring the decoding result corresponding to the barcode image, the method further includes: counting at least one result number corresponding to the same decoding result in a plurality of decoding results corresponding to the bar code; obtaining the maximum value of the number of the results; under the condition that the maximum value does not reach a set numerical value, returning to execute the bar code image corresponding to the collected bar code, and executing a first decoding operation on the bar code characters of the appointed row/column in the middle area of the bar code image in a ZBar decoding mode; and under the condition that the maximum value reaches the set value, acquiring the same decoding result corresponding to the maximum value and determining the decoding result as a target decoding result.
According to a second aspect of embodiments of the present disclosure, there is provided a barcode recognition apparatus including: the first decoding module is used for acquiring a bar code image corresponding to a bar code and executing a first decoding operation on bar code characters of a specified row/column in a middle area of the bar code image in a ZBar decoding mode; the second decoding module is used for extracting the binarization features corresponding to the bar code characters of the specified row/column under the condition that the first decoding operation fails, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode; a first region judgment module, configured to judge whether the designated row/column is located in a preset middle region when the second decoding operation fails; the third decoding module is used for executing third decoding operation on the bar code characters of the appointed row/column by adopting a ZXing decoding mode under the condition that the appointed row/column is positioned in a preset middle area; and the first decoding result acquisition module is used for acquiring a decoding result corresponding to the bar code image under the condition that the third decoding operation is successful.
Preferably, the barcode characters include a barcode and characters, and the first decoding module includes: the width ratio adjusting submodule is used for adjusting the width ratio of the bar code corresponding to the bar code character of the appointed row/column to a width ratio threshold value; and the first decoding submodule is used for executing the first decoding operation on the adjusted bar code characters of the appointed row/column by adopting the ZBar decoding mode.
Preferably, the width ratio threshold is 3/8.
Preferably, the apparatus further comprises: the second decoding result acquisition module is used for acquiring a decoding result corresponding to the bar code image under the condition that the first decoding operation is successful;
the device further comprises: and the third decoding result acquisition module is used for acquiring a decoding result corresponding to the bar code image under the condition that the second decoding operation is successful.
Preferably, the apparatus further comprises: a barcode character acquisition module, configured to acquire, when the third decoding operation fails, a barcode character of a first row/column located after the barcode character of the specified row/column, or a barcode character of a second row/column located before the barcode character of the specified row/column; the fourth decoding module is used for executing fourth decoding operation on the bar code characters of the first row/column or the bar code characters of the second row/column by adopting the ZBar decoding mode; a fourth decoding result obtaining module, configured to obtain a decoding result corresponding to the barcode image when the fourth decoding operation is successful; a binarization feature extraction module, configured to extract sub-binarization features corresponding to the barcode characters in the first row/column or the barcode characters in the second row/column when the fourth decoding operation fails; a fifth decoding module, configured to perform a fifth decoding operation on the sub-binarization feature in the ZBar decoding manner; a fifth decoding result obtaining module, configured to obtain a decoding result corresponding to the barcode image when the fifth decoding operation is successful; a second region determining module, configured to determine whether the first row/column or the second row/column is located in the preset middle region when the fifth decoding operation fails; a sixth decoding module, configured to perform a sixth decoding operation on the barcode character of the first row/column or the barcode character of the second row/column in the ZXing decoding manner when the first row/column or the second row/column is located in the preset middle area; a sixth decoding result obtaining module, configured to obtain a decoding result corresponding to the barcode image when the sixth decoding operation is successful; the first return execution module is configured to, when the sixth decoding operation fails, acquire a barcode character of a third row/column located after or before the barcode character of the first row/column, or a barcode character of a fourth row/column located after or before the barcode character of the second row/column, and execute the above module on the barcode character of the third row/column, or the barcode character of the fourth row/column.
Preferably, the apparatus further comprises: the result number counting module is used for counting at least one result number corresponding to the same decoding result in a plurality of decoding results corresponding to the bar code; a maximum value obtaining module, configured to obtain a maximum value of the number of results; the second return execution module is used for returning and executing the bar code image corresponding to the collected bar code under the condition that the maximum value does not reach a set numerical value, and executing a first decoding operation on the bar code characters of the appointed row/column in the middle area of the bar code image in a ZBar decoding mode; and the target decoding result determining module is used for acquiring the same decoding result corresponding to the maximum value and determining the decoding result as a target decoding result under the condition that the maximum value reaches the set value.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic apparatus including: a processor, a memory and a computer program stored on the memory and operable on the processor, wherein the processor implements one or more of the barcode identification methods described above when executing the program.
According to a fourth aspect of embodiments of the present disclosure, there is provided a readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform one or more of the barcode recognition methods described above.
The barcode identification method and the barcode identification device provided by the embodiment of the disclosure are characterized in that a barcode image corresponding to a barcode is collected, a ZBar decoding mode is adopted to perform a first decoding operation on barcode characters in a designated row/column in a middle region of the barcode image, a binarization feature corresponding to the barcode characters in the designated row/column is extracted under the condition that the first decoding operation fails, a ZBar decoding mode is adopted to perform a second decoding operation on the binarization feature, a ZXing decoding mode is adopted to perform a third decoding operation on the barcode characters in the designated row/column under the condition that the second decoding operation fails and the designated row/column is located in a preset middle region, and a decoding result corresponding to the barcode image is obtained under the condition that the third decoding operation succeeds. The method and the device can improve the identification speed of the single-frame barcode image by identifying row by row/column, and can improve the success rate of barcode identification by fusing two decoding modes of ZBAR and ZXing.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments of the present disclosure will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart illustrating steps of a barcode identification method according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a barcode character width ratio provided by an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating steps of a barcode identification method according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a result of selecting a target barcode according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a barcode identification apparatus provided in an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a barcode identification apparatus according to an embodiment of the present disclosure.
Detailed Description
Technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments, which can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present disclosure, belong to the protection scope of the embodiments of the present disclosure.
Example one
Referring to fig. 1, a flowchart illustrating steps of a barcode identification method provided in an embodiment of the present disclosure is shown, which may specifically include the following steps:
step 101: collecting a bar code image corresponding to a bar code, and executing a first decoding operation on bar code characters of a specified row/column in a middle area of the bar code image by adopting a ZBar decoding mode.
In the embodiment of the present disclosure, the mobile terminal may be a mobile electronic device having a camera, such as a mobile phone, a PDA (Personal Digital Assistant), a tablet computer, and the like.
The bar code image is a bar code image to be identified, a bar code to be identified is arranged on the acquired bar code image, and the bar code (barcode) is a graphic identifier which is used for expressing a group of information by arranging a plurality of black bars and blanks with different widths according to a certain coding rule. Common bar codes are parallel line patterns formed by black bars and white bars (short for empty bars) with greatly different reflectivity, and of course, the bar codes on the bar code images can also be other forms of bar codes, and the embodiment of the disclosure is not limited to this.
The bar code can mark a lot of information such as the production country, the manufacturer, the name of the goods, the production date, the book classification number, the starting and ending place of the mail, the category, the date and the like of the goods.
When the bar code needs to be identified, the camera arranged on the mobile terminal can be adopted to shoot the bar code to be identified so as to obtain a bar code image, and then the bar code to be identified exists on the bar code image.
The first decoding operation is a decoding operation performed on bar characters of a designated row/column in the middle region of the barcode image by using a ZBar decoding method, and since the ZBar decoding method is compared with a ZXing decoding method, the ZBar decoding method performs decoding by dividing barcode features based on pixel values only, and the barcode recognition rate is much higher.
The bar code in the bar code image is formed by arranging a plurality of black bars and blanks with different widths according to a certain coding rule, two black bars and two white bars form a bar code character, and the bar code comprises a plurality of bar code characters which are respectively arranged in a line/column mode.
The designated row/column refers to a bar code character of a certain row/column in a plurality of bar code characters in the middle area of the bar code image. In practical applications, the barcode character recognition success rate of the middle row/column of the barcode is high, and therefore, in the embodiment of the present disclosure, the barcode character of the specified row/column is preferably the barcode character of the middle row/column in the middle area of the barcode image, of course, the barcode character of a certain row/column in the middle area of the barcode may also be used as the specified row/column, and specifically, the present disclosure may be determined according to practical situations, and the present disclosure does not limit this.
Of course, before the ZBar decoding mode is adopted to perform the first decoding operation on the bar code characters in the designated row/column in the middle area of the bar code image, the width ratio of the bar code characters and the characters can be adjusted, and specifically, the following preferred embodiment is described in detail.
In a preferred embodiment of the present disclosure, the step 101 may include:
substep A1: and adjusting the width ratio of the bar code corresponding to the bar code character of the appointed row/column to the width ratio threshold value.
In the disclosed embodiments, the width ratio refers to the ratio of the width of the barcode to the width of the character in the barcode.
For example, referring to fig. 2, a schematic diagram of a character width ratio of a barcode provided by the embodiment of the present disclosure is shown, as shown in fig. 2, where black bars indicate the barcode, i.e., the portions indicated by C1 and C3; the black and white bars shown in the figure (i.e., the portions indicated by C2 and C4) collectively represent characters, and the width ratio of the barcode shown in fig. 2 is (C1+ C3)/(C1+ C2+ C3+ C4).
The width ratio threshold is a ratio of a preset width of a barcode to a width of a character, and may be 3: 8. 2: 8, etc., and in particular, may be practical, and embodiments of the present disclosure are not limited in this regard.
In the prior art, the width ratio of a barcode to characters of a common barcode is 3:7, in the embodiment of the present disclosure, a width ratio threshold may be set to 3:8, and after a barcode image corresponding to a barcode is acquired, the width ratio of the barcode corresponding to barcode characters of a specified row/column in the barcode image may be adjusted to the width ratio threshold, that is, the width ratio of the barcode corresponding to barcode characters of the specified row/column is adjusted to 3:8, so that, in a subsequent decoding process, the decoding accuracy of the barcode characters of the specified row/column may be improved.
After adjusting the barcode-to-character width ratio corresponding to the barcode character of the specified row/column to a width ratio threshold, substep a2 is performed.
Substep A2: and executing the first decoding operation on the adjusted bar code characters of the appointed row/column by adopting the ZBAR decoding mode.
After the width ratio of the barcode corresponding to the barcode character of the designated row/column is adjusted to the width ratio threshold, a ZBar decoding method may be adopted to perform a first decoding operation on the adjusted barcode character of the designated row/column.
Of course, not limited to the first decoding operation, the second decoding operation and the third decoding operation mentioned in the following steps may be decoding performed on the adjusted barcode characters of the designated row/column.
The embodiment of the disclosure can improve the decoding accuracy of the bar code characters of the designated row/column by adjusting the width ratio of the bar code characters.
In the case that the first decoding operation is successful, a decoding operation corresponding to the barcode image may be acquired, and specifically, a detailed description is given below in accordance with a preferred embodiment.
In another preferred embodiment of the present disclosure, after the step 101, the method may further include:
and B: and under the condition that the first decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
In the embodiment of the disclosure, after the ZBar decoding mode is adopted to successfully decode the barcode characters of the specified row/column, a decoding result obtained by successful decoding can be obtained, and the decoding result is a decoding result corresponding to the barcode image.
In case the first decoding operation fails, step 102 is performed.
Step 102: and under the condition that the first decoding operation fails, extracting binarization features corresponding to the bar code characters of the specified row/column, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode.
The binarization of the image refers to setting the gray value of a pixel point on the image to be 0 or 255, that is, the whole image has an obvious visual effect only including black and white.
The binarization characteristic is that the gray level image with 256 brightness levels is selected through a proper threshold value to obtain the characteristic which can still reflect the whole and local characteristics of the image.
The second decoding operation is the decoding operation executed on the binarization characteristics corresponding to the bar code characters of the appointed row/column by adopting a ZBar decoding mode.
When the bar code image is collected and the bar code in the bar code image is decoded, the bar code image is a gray level image, and further, when the first decoding operation fails, the binarization characteristics corresponding to the bar code characters of the specified row/column in the bar code image can be extracted for decoding again.
According to the embodiment of the disclosure, the ZBar decoding mode is adopted again for decoding the binarization characteristics corresponding to the specified row/column bar code characters, so that the success rate of bar code identification can be improved.
In case that the second decoding operation is successful, a decoding result corresponding to the barcode image may be obtained, and specifically, a detailed description is provided in a preferred embodiment described below.
In another preferred embodiment of the present disclosure, after the step 102, the method may further include:
and C: and under the condition that the second decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
In the embodiment of the disclosure, after the ZBar decoding mode is adopted to successfully decode the barcode characters of the specified row/column, a decoding result obtained by successful decoding can be obtained, and the decoding result is used as a decoding result corresponding to the barcode image.
In case the second decoding operation fails, step 103 is performed.
Step 103: and judging whether the designated row/column is positioned in a preset middle area or not under the condition that the second decoding operation fails.
The preset middle area of the preset barcode image is different according to the different positions of the barcode in the barcode image, and specifically, may be determined according to an actual situation, which is not limited in this embodiment of the present disclosure.
In the disclosure, the preset middle area may be a/4 area of a barcode center of the barcode image, when decoding the barcode, barcode characters often appear in a center portion of the sampling frame, and actually, the area of the barcode center 1/4 in the barcode image is taken as a barcode high frequency appearing area, which is taken as the preset area, so that a decoding success rate can be improved.
When the designated row/column is located outside the preset middle area, the barcode characters of a row/column before or after the designated row/column can be collected, and the decoding operation steps are sequentially executed on the barcode characters of the row/column.
And in case the designated row/column is located in the preset middle area, step 104 is performed.
Step 104: and under the condition that the specified row/column is positioned in a preset middle area, performing third decoding operation on the bar code characters of the specified row/column by adopting a ZXing decoding mode.
The third decoding operation refers to the decoding operation executed on the bar code characters of the appointed row/column by adopting a ZXing decoding mode.
When the designated row/column is located in the preset middle area and the ZBar decoding mode fails to decode the barcode characters of the designated row/column, decoding the barcode characters of the designated row/column by adopting a ZXing decoding mode can be attempted.
According to the method and the device, the success rate of bar code character recognition can be improved by fusing the ZBAR decoding mode and the ZXing decoding mode.
In the method, a third decoding operation is performed on the barcode characters of the designated row/column by using a ZXing decoding manner, and when the third decoding operation fails, the barcode characters of a certain row/column before or after the designated row/column may be obtained, and the step of performing the decoding operation again may be specifically described in the following embodiment two, which is not described again in this disclosure.
And if the third decoding operation is performed on the barcode characters of the designated row/column by adopting the ZXing decoding mode and the decoding is successful, executing step 105.
Step 105: and under the condition that the third decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
The decoding result refers to a decoding result corresponding to the barcode image obtained after the barcode image is successfully decoded.
When the ZXing decoding mode is adopted to decode the bar code characters of the appointed row/column and the decoding is successful, the decoding result of the bar code image can be obtained.
According to the method and the device, the success rate of barcode identification can be improved by fusing the ZBAR decoding mode and the ZXing decoding mode, and the barcode image identification speed can be improved by only decoding the barcode characters of a certain row/column of the single-frame barcode image.
In the case that the third decoding operation fails, the barcode characters of a certain row/column before or after the designated row/column may be acquired and decoded in the above manner, specifically, as described in detail in the following preferred embodiment.
In another preferred embodiment of the present disclosure, after the step 105, the method may further include:
step D1: and under the condition that the third decoding operation fails, acquiring the bar code characters of a first row/column behind the bar code characters of the appointed row/column or the bar code characters of a second row/column in front of the bar code characters of the appointed row/column.
In the embodiment of the present disclosure, the barcode character in the first row/column refers to a barcode character which is located behind the barcode character in the specified row/column and is regarded as a barcode character, and the barcode character in the second row/column refers to a barcode character which is located before the barcode character in the specified row/column and is regarded as a barcode character, for example, the barcode character in the specified row/column includes 5 barcode characters, the barcode character in the specified row/column is a barcode character in the middle 3 rows/columns, the barcode character in the first row/column is a barcode character in 4 rows/columns which is one bit behind the barcode character in 3 rows/columns, and the barcode character in the second row/column is a barcode character in 2 rows/columns which is one bit ahead of the barcode character in 3 rows/columns.
It is to be understood that the above examples are only examples set forth for a better understanding of the technical solutions of the embodiments of the present disclosure, and are not to be taken as the only limitations on the embodiments of the present disclosure.
After the third decoding operation fails, the barcode character of the first row/column or the barcode character of the second row/column may be acquired, and step D2 is performed.
Step D2: and executing a fourth decoding operation on the bar code characters of the first row/column or the bar code characters of the second row/column by adopting the ZBar decoding mode.
The fourth decoding operation refers to the decoding operation executed on the bar code characters of the first row/column and the bar code characters of the second row/column by adopting a ZBar decoding mode.
After the barcode characters of the first row/column or the barcode characters of the second row/column are acquired, a ZBar decoding mode may be adopted to perform a fourth decoding operation on the barcode characters of the first row/column or the barcode characters of the second row/column.
In the case where the fourth decoding operation is successful, performing step D3; and in case the fourth decoding operation fails, step D4 is performed.
Step D3: and under the condition that the fourth decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
After the fourth decoding operation is successful, a decoding result corresponding to the fourth decoding operation, that is, a decoding result corresponding to the barcode image, may be obtained.
Step D4: and under the condition that the fourth decoding operation fails, extracting sub-binarization characteristics corresponding to the bar code characters of the first row/column or the bar code characters of the second row/column.
The sub-binarization characteristics refer to binarization characteristics corresponding to bar code characters in a first row/column.
After the fourth decoding operation fails, the sub-binary features corresponding to the barcode characters of the first row/column or the barcode characters of the second row/column can be extracted.
After extracting the sub-binary feature corresponding to the barcode character of the first row/column or the barcode character of the second row/column, step D5 is executed.
Step D5: and executing a fifth decoding operation on the sub-binarization characteristics by adopting the ZBAR decoding mode.
The fifth decoding operation refers to a decoding operation performed on the sub-binarization feature in a Zbar decoding manner.
And extracting the bar code characters of the first row/column or the sub-binarization characteristics corresponding to the bar code characters of the second row/column for decoding.
In the case where the fifth decoding operation is successful, performing step D6; and in case the fifth decoding operation fails, step D7 is performed.
Step D6: and under the condition that the fifth decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
After the fifth decoding operation is successful, a decoding result corresponding to the fifth decoding operation may be obtained, and the decoding result corresponding to the fifth decoding operation may be used as a decoding result of the barcode image.
Step D7: and judging whether the first row/column or the second row/column is located in the preset middle area or not when the fifth decoding operation fails.
And after the fifth decoding operation fails, it may be determined whether the first row/column or the second row/column is located in the preset middle area.
When the first row/column or the second row/column is positioned outside the preset middle area, judging that the decoding of the bar code characters of the first row/column or the bar code characters of the second row/column fails, and continuously acquiring the bar code characters of a certain row/column before or after the first row/column to decode by adopting the decoding process; or acquiring the bar code characters of a certain row/column before or after the second row/column, and decoding by adopting the decoding process.
In case that the first row/column or the second row/column is located in the preset middle area, step D8 is performed.
Step D8: and under the condition that the first row/column or the second row/column is positioned in the preset middle area, performing sixth decoding operation on the bar code characters of the first row/column or the bar code characters of the second row/column by adopting the ZXing decoding mode.
The sixth decoding operation is an operation of decoding the barcode characters of the first row/column or the barcode characters of the second row/column by adopting a ZXing decoding mode.
And under the condition that the first row/column or the second row/column is positioned in the preset middle area, decoding the bar code characters of the first row/column or the bar code characters of the second row/column by adopting a ZXing decoding mode.
In case the sixth decoding operation is successful, step D9 is performed; and in case the sixth decoding operation fails, step D10 is performed.
Step D9: and under the condition that the sixth decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
In case that the sixth decoding operation is successful, a decoding result corresponding to the sixth decoding operation may be obtained, and the decoding result corresponding to the sixth decoding operation may be used as a decoding result of the barcode image.
Step D10: and under the condition that the sixth decoding operation fails, acquiring a third row/column of barcode characters behind or before the first row/column of barcode characters, or a fourth row/column of barcode characters behind or before the second row/column of barcode characters, and performing the steps on the third row/column of barcode characters or the fourth row/column of barcode characters.
The bar code character of the third row/column refers to the bar code character which is one bit behind or before the bar code character of the first row/column, and the bar code character of the fourth row/column refers to the bar code character which is one bit behind or before the bar code character of the second row/column. For example, the barcode includes 5 barcode characters, and when the barcode character in the first row/column is the barcode character in the middle 3 rows/columns, the barcode character in the third row/column is the barcode character in 4 rows/columns or the barcode character in 2 rows/columns; and when the bar code character of the second row/column is the bar code character of 4 rows/columns, the bar code character of the fourth row/column is the bar code character of 3 rows/columns or the bar code character of 5 rows/columns.
It is to be understood that the above examples are only examples set forth for a better understanding of the technical solutions of the embodiments of the present disclosure, and are not to be taken as the only limitations on the embodiments of the present disclosure.
And in case of failure of the sixth decoding operation, a third row/column barcode character located after or before the first row/column barcode character, or a fourth row/column barcode character located after or before the second row/column barcode character may be acquired, and the decoding process may be performed on the third row/column barcode character, or the fourth row/column barcode character.
And by analogy, the decoding process can be adopted to decode row by row/column, the execution process is similar, and when the decoding of the bar code character of a certain row/column is successful, the decoding of the bar code image of the current frame is considered to be successful, the next frame of image is collected to decode according to the decoding process.
The barcode identification method provided by the embodiment of the invention comprises the steps of collecting a barcode image corresponding to a barcode, executing a first decoding operation on barcode characters of a designated row/column in a middle region of the barcode image by adopting a ZBAR decoding mode, extracting binarization characteristics corresponding to the barcode characters of the designated row/column under the condition that the first decoding operation fails, executing a second decoding operation on the binarization characteristics by adopting the ZBAR decoding mode, executing a third decoding operation on the barcode characters of the designated row/column under the condition that the second decoding operation fails and the designated row/column is located in a preset middle region, and acquiring a decoding result corresponding to the barcode image under the condition that the third decoding operation succeeds. The method and the device can improve the identification speed of the single-frame barcode image by identifying row by row/column, and can improve the success rate of barcode identification by fusing two decoding modes of ZBAR and ZXing.
Example two
Referring to fig. 3, a flowchart illustrating steps of a barcode identification method provided in the embodiment of the present disclosure is shown, which may specifically include the following steps:
step 201: collecting a bar code image corresponding to a bar code, and executing a first decoding operation on bar code characters of a specified row/column in a middle area of the bar code image by adopting a ZBar decoding mode;
step 202: under the condition that the first decoding operation fails, extracting binarization features corresponding to the bar code characters of the specified row/column, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode;
step 203: judging whether the designated row/column is located in a preset middle area or not under the condition that the second decoding operation fails;
step 204: under the condition that the appointed row/column is positioned in a preset middle area, performing third decoding operation on the bar code characters of the appointed row/column by adopting a ZXing decoding mode;
step 205: and under the condition that the third decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
In the embodiment of the present disclosure, the implementation of the step 201 to the step 205 is similar to the implementation of the step 101 to the step 105 in the above embodiment, and the embodiment of the present disclosure is not described in detail here.
Step 206: and counting at least one result number corresponding to the same decoding result in a plurality of decoding results corresponding to the bar code.
In the embodiment of the present disclosure, the number of results refers to the number of the same results in a plurality of decoding results corresponding to the barcode.
The final decoding result of the barcode may be obtained by using a multi-frame smoothing strategy, specifically, after the barcode image of the barcode is successfully decoded, the decoding result corresponding to the current barcode image may be cached, and the number of results of the same decoding result in a plurality of decoding results corresponding to the barcode is counted, for example, three decoding results are obtained when the barcode is decoded three times and are all successfully, where the three decoding results are a1, a2, and a1, where the same decoding result is a1, and the number of results is 2; and four decoding results are obtained successfully after the barcode is decoded four times, wherein the four decoding results are a1, a2, a2 and a1, wherein the same decoding results are a1 and a2, the number of the results of the same decoding results is 2 and 2, namely the number of the results a1 is 2, and the number of the results a2 is 2.
It is to be understood that the above examples are only examples set forth for a better understanding of the technical solutions of the embodiments of the present disclosure, and are not to be taken as the only limitations on the embodiments of the present disclosure.
After each barcode image corresponding to the barcode is successfully decoded, counting the number of results of the same decoding result once, and after at least one result number of the same decoding result in the plurality of decoding results corresponding to the barcode is obtained through counting, executing step 207.
Step 207: and acquiring the maximum value of the number of the results.
After obtaining at least one result number, the maximum value of each result number may be obtained, for example, after 5 frame barcode images corresponding to the barcode are decoded to obtain 5 decoding results, the 5 decoding results are a1, a2, a1, a1, and a2, where the same decoding results are a1 and a2, the result numbers are 3 and 2, respectively, that is, the same number of a1 results is 3, and the same number of a2 results is 2, and then the maximum value of the result numbers is 3.
It is to be understood that the above examples are only examples set forth for a better understanding of the technical solutions of the embodiments of the present disclosure, and are not to be taken as the only limitations on the embodiments of the present disclosure.
After the maximum value among the result numbers is obtained, step 208 is executed.
Step 208: and under the condition that the maximum value does not reach the set numerical value, returning to execute the bar code image corresponding to the collected bar code, and executing a first decoding operation on the bar code characters of the appointed row/column in the middle area of the bar code image in a ZBar decoding mode.
The set value refers to a value preset by a service person and corresponding to the number of results of the same decoding result, and the set value may be 4, 5, 8, and the like, and specifically may be determined according to a service requirement, which is not limited in this embodiment of the disclosure.
And returning to the step 201 under the condition that the maximum value in at least one result number of the same decoding results does not reach the set numerical value, namely, re-collecting the next frame of bar code image corresponding to the bar code and executing the decoding operation on the next frame of bar code image according to the decoding process.
After the barcode image corresponding to the newly acquired barcode is successfully decoded, a decoding result can be obtained again, and at least one result number of the same decoding result in the plurality of decoding results corresponding to the barcode is counted again, that is, the above steps 201 to 206 are executed in a loop until the maximum value of the result numbers reaches a set value.
Step 209: and determining the same decoding result corresponding to the maximum value as a target decoding result when the maximum value reaches the set value.
The target decoding result is a final decoding result obtained by decoding the barcode.
In a case that the maximum value reaches a set value, the same decoding result corresponding to the maximum value may be determined as a target decoding result, for example, referring to fig. 4, a schematic diagram of a target barcode result selection result provided in the embodiment of the present disclosure is shown, as shown in fig. 4, the set value is 4, and after 5 frames of barcode images are decoded, the obtained decoding results are: 4712302310085, 4712302310085, 6712302310065, 4712302310085 and 4712302310085, the same decoding result is: 4712302310085, the number of the same decoding results is 4, namely 4712302310085 is the target decoding result, and the current decoding operation of the barcode is terminated.
It is to be understood that the above examples are only examples set forth for a better understanding of the technical solutions of the embodiments of the present disclosure, and are not to be taken as the only limitations on the embodiments of the present disclosure.
The barcode recognition method provided by the embodiment of the disclosure has the beneficial effects that the barcode recognition method provided by the first embodiment has, and can also count the number of the same decoding results in a plurality of decoding results corresponding to the barcode after each frame of barcode image is successfully decoded, and determine the same decoding results as target decoding results when the number reaches a set number.
EXAMPLE III
Referring to fig. 5, a schematic structural diagram of a barcode identification apparatus provided in the embodiment of the present disclosure is shown, which may specifically include the following modules:
the first decoding module 310 is configured to acquire a barcode image corresponding to a barcode, and perform a first decoding operation on barcode characters in a designated row/column in a middle region of the barcode image in a ZBar decoding manner;
a second decoding module 320, configured to, in a case that the first decoding operation fails, extract a binarization feature corresponding to the barcode character in the specified row/column, and perform a second decoding operation on the binarization feature in the ZBar decoding manner;
a first region determining module 330, configured to determine whether the designated row/column is located in a preset middle region when the second decoding operation fails;
a third decoding module 340, configured to perform a third decoding operation on the barcode character of the designated row/column in a ZXing decoding manner when the designated row/column is located in a preset middle area;
a first decoding result obtaining module 350, configured to obtain a decoding result corresponding to the barcode image when the third decoding operation is successful.
Preferably, the barcode characters include a barcode and characters, and the first decoding module 310 includes:
the width ratio adjusting submodule is used for adjusting the width ratio of the bar code corresponding to the bar code character of the appointed row/column to a width ratio threshold value;
and the first decoding submodule is used for executing the first decoding operation on the adjusted bar code characters of the appointed row/column by adopting the ZBar decoding mode.
Preferably, the width ratio threshold is 3/8.
Preferably, the apparatus further comprises:
the second decoding result acquisition module is used for acquiring a decoding result corresponding to the bar code image under the condition that the first decoding operation is successful;
the device further comprises:
and the third decoding result acquisition module is used for acquiring a decoding result corresponding to the bar code image under the condition that the second decoding operation is successful.
Preferably, the apparatus further comprises:
a barcode character acquisition module, configured to acquire, when the third decoding operation fails, a barcode character of a first row/column located after the barcode character of the specified row/column, or a barcode character of a second row/column located before the barcode character of the specified row/column;
the fourth decoding module is used for executing fourth decoding operation on the bar code characters of the first row/column or the bar code characters of the second row/column by adopting the ZBar decoding mode;
a fourth decoding result obtaining module, configured to obtain a decoding result corresponding to the barcode image when the fourth decoding operation is successful;
a binarization feature extraction module, configured to extract sub-binarization features corresponding to the barcode characters in the first row/column or the barcode characters in the second row/column when the fourth decoding operation fails;
a fifth decoding module, configured to perform a fifth decoding operation on the sub-binarization feature in the ZBar decoding manner;
a fifth decoding result obtaining module, configured to obtain a decoding result corresponding to the barcode image when the fifth decoding operation is successful;
a second region determining module, configured to determine whether the first row/column or the second row/column is located in the preset middle region when the fifth decoding operation fails;
a sixth decoding module, configured to perform a sixth decoding operation on the barcode character of the first row/column or the barcode character of the second row/column in the ZXing decoding manner when the first row/column or the second row/column is located in the preset middle area;
a sixth decoding result obtaining module, configured to obtain a decoding result corresponding to the barcode image when the sixth decoding operation is successful;
the first return execution module is configured to, when the sixth decoding operation fails, acquire a barcode character of a third row/column located after or before the barcode character of the first row/column, or a barcode character of a fourth row/column located after or before the barcode character of the second row/column, and execute the above module on the barcode character of the third row/column, or the barcode character of the fourth row/column.
The barcode recognition device provided by the embodiment of the invention acquires a barcode image corresponding to a barcode, performs a first decoding operation on barcode characters in a designated row/column in a middle region of the barcode image by adopting a ZBar decoding mode, extracts binarization features corresponding to the barcode characters in the designated row/column under the condition that the first decoding operation fails, performs a second decoding operation on the binarization features by adopting the ZBar decoding mode, performs a third decoding operation on the barcode characters in the designated row/column by adopting a ZXing decoding mode under the condition that the second decoding operation fails and the designated row/column is located in a preset middle region, and acquires a decoding result corresponding to the barcode image under the condition that the third decoding operation succeeds. The method and the device can improve the identification speed of the single-frame barcode image by identifying row by row/column, and can improve the success rate of barcode identification by fusing two decoding modes of ZBAR and ZXing.
Example four
Referring to fig. 6, a schematic structural diagram of a barcode identification apparatus provided in the embodiment of the present disclosure is shown, which may specifically include the following modules:
the first decoding module 410 is configured to acquire a barcode image corresponding to a barcode, and perform a first decoding operation on barcode characters in a designated row/column in a middle region of the barcode image in a ZBar decoding manner;
a second decoding module 420, configured to, in a case that the first decoding operation fails, extract a binarization feature corresponding to the barcode character in the specified row/column, and perform a second decoding operation on the binarization feature in the ZBar decoding manner;
a first region determining module 430, configured to determine whether the designated row/column is located in a preset middle region when the second decoding operation fails;
a third decoding module 440, configured to perform a third decoding operation on the barcode character of the designated row/column in a ZXing decoding manner when the designated row/column is located in a preset middle area;
a first decoding result obtaining module 450, configured to obtain a decoding result corresponding to the barcode image when the third decoding operation is successful;
a result number counting module 460, configured to count at least one result number corresponding to the same decoding result in the plurality of decoding results corresponding to the barcode;
a maximum value obtaining module 470, configured to obtain a maximum value of each result number;
a second return execution module 480, configured to return to execute the barcode image corresponding to the collected barcode and execute a first decoding operation on barcode characters in a specified row/column in a middle area of the barcode image in a ZBar decoding manner when the maximum value does not reach a set numerical value;
and a target decoding result determining module 490, configured to, when the maximum value reaches the set value, obtain the same decoding result corresponding to the maximum value, and determine the same decoding result as a target decoding result.
The barcode recognition device provided by the embodiment of the disclosure, besides the beneficial effects of the barcode recognition device provided by the third embodiment, can also count the number of the same decoding results in a plurality of decoding results corresponding to the barcode after each frame of barcode image is successfully decoded, and determine the same decoding results as target decoding results when the number reaches a set number.
An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a computer program stored on the memory and executable on the processor, the processor implementing the barcode identification method of the foregoing embodiments when executing the program.
Embodiments of the present disclosure also provide a readable storage medium, wherein when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the barcode identification method of the foregoing embodiments.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. In addition, embodiments of the present disclosure are not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the embodiments of the present disclosure as described herein, and any descriptions of specific languages are provided above to disclose the best modes of the embodiments of the present disclosure.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the disclosure may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the disclosure, various features of the embodiments of the disclosure are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that is, claimed embodiments of the disclosure require more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of an embodiment of this disclosure.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
The various component embodiments of the disclosure may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be understood by those skilled in the art that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in a motion picture generating device according to an embodiment of the present disclosure. Embodiments of the present disclosure may also be implemented as an apparatus or device program for performing a portion or all of the methods described herein. Such programs implementing embodiments of the present disclosure may be stored on a computer readable medium or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit embodiments of the disclosure, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. Embodiments of the disclosure may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The above description is only for the purpose of illustrating the preferred embodiments of the present disclosure and is not to be construed as limiting the embodiments of the present disclosure, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the embodiments of the present disclosure are intended to be included within the scope of the embodiments of the present disclosure.
The above description is only a specific implementation of the embodiments of the present disclosure, but the scope of the embodiments of the present disclosure is not limited thereto, and any person skilled in the art can easily conceive of changes or substitutions within the technical scope of the embodiments of the present disclosure, and all the changes or substitutions should be covered by the scope of the embodiments of the present disclosure. Therefore, the protection scope of the embodiments of the present disclosure shall be subject to the protection scope of the claims.

Claims (10)

1. A method of barcode identification, comprising:
acquiring a bar code image corresponding to a bar code, and executing a first decoding operation on bar code characters of a specified row/column of the bar code image by adopting a ZBar decoding mode, wherein the specified row/column refers to the bar code characters of a certain row/column in a plurality of bar code characters in the middle area of the bar code image;
under the condition that the first decoding operation fails, extracting binarization features corresponding to the bar code characters of the specified row/column, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode;
judging whether the designated row/column is located in a preset middle area or not under the condition that the second decoding operation fails;
under the condition that the appointed row/column is positioned in a preset middle area, performing third decoding operation on the bar code characters of the appointed row/column by adopting a ZXing decoding mode;
and under the condition that the third decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
2. The method of claim 1, wherein the barcode characters comprise a barcode and characters, and the step of performing a first decoding operation on the barcode characters of a specified row/column in the middle region of the barcode image by using ZBar decoding comprises:
adjusting the width ratio of the bar code corresponding to the bar code character of the appointed row/column to the character to be a width ratio threshold value;
and executing the first decoding operation on the adjusted bar code characters of the appointed row/column by adopting the ZBAR decoding mode.
3. The method of claim 2, wherein the width ratio threshold is 3/8.
4. The method of claim 1, wherein after the step of performing a first decoding operation on the barcode characters of the designated row/column in the middle region of the barcode image by using ZBar decoding, the method further comprises:
under the condition that the first decoding operation is successful, acquiring a decoding result corresponding to the bar code image;
after the step of performing the second decoding operation on the binarized feature in the ZBar decoding manner, the method further includes:
and under the condition that the second decoding operation is successful, acquiring a decoding result corresponding to the bar code image.
5. The method according to claim 1, wherein after the step of performing a third decoding operation on the barcode characters of the specified row/column by using a ZXing decoding manner, the method further comprises:
under the condition that the third decoding operation fails, acquiring a first row/column of bar code characters behind the bar code characters of the appointed row/column or a second row/column of bar code characters in front of the bar code characters of the appointed row/column;
performing a fourth decoding operation on the bar code characters of the first row/column or the bar code characters of the second row/column by adopting the ZBar decoding mode;
under the condition that the fourth decoding operation is successful, a decoding result corresponding to the bar code image is obtained;
under the condition that the fourth decoding operation fails, extracting sub-binarization characteristics corresponding to the bar code characters of the first row/column or the bar code characters of the second row/column;
performing a fifth decoding operation on the sub-binarization characteristics by adopting the ZBAR decoding mode;
under the condition that the fifth decoding operation is successful, a decoding result corresponding to the bar code image is obtained;
judging whether the first row/column or the second row/column is located in the preset middle area or not under the condition that the fifth decoding operation fails;
when the first row/column or the second row/column is located in the preset middle area, performing a sixth decoding operation on the barcode characters of the first row/column or the barcode characters of the second row/column by adopting the ZXing decoding mode;
under the condition that the sixth decoding operation is successful, a decoding result corresponding to the bar code image is obtained;
and under the condition that the sixth decoding operation fails, acquiring a third row/column of barcode characters behind or before the first row/column of barcode characters, or a fourth row/column of barcode characters behind or before the second row/column of barcode characters, and performing the steps on the third row/column of barcode characters or the fourth row/column of barcode characters.
6. The method of claim 1, 4 or 5, further comprising, after the step of obtaining a decoding result corresponding to the barcode image:
counting at least one result number corresponding to the same decoding result in a plurality of decoding results corresponding to the bar code;
obtaining the maximum value of the number of the results;
under the condition that the maximum value does not reach a set numerical value, returning to execute the bar code image corresponding to the collected bar code, and executing a first decoding operation on the bar code characters of the appointed row/column in the middle area of the bar code image in a ZBar decoding mode;
and determining the same decoding result corresponding to the maximum value as a target decoding result when the maximum value reaches the set value.
7. A barcode recognition apparatus, comprising:
the first decoding module is used for acquiring a bar code image corresponding to a bar code and executing a first decoding operation on bar code characters of a specified row/column of the bar code image in a ZBar decoding mode, wherein the specified row/column refers to the bar code characters of a certain row/column in a plurality of bar code characters in the middle area of the bar code image;
the second decoding module is used for extracting the binarization features corresponding to the bar code characters of the specified row/column under the condition that the first decoding operation fails, and executing a second decoding operation on the binarization features by adopting the ZBAR decoding mode;
a first region judgment module, configured to judge whether the designated row/column is located in a preset middle region when the second decoding operation fails;
the third decoding module is used for executing third decoding operation on the bar code characters of the appointed row/column by adopting a ZXing decoding mode under the condition that the appointed row/column is positioned in a preset middle area;
and the first decoding result acquisition module is used for acquiring a decoding result corresponding to the bar code image under the condition that the third decoding operation is successful.
8. The apparatus of claim 7, wherein the barcode characters comprise a barcode and characters, and wherein the first decoding module comprises:
the width ratio adjusting submodule is used for adjusting the width ratio of the bar code corresponding to the bar code character of the appointed row/column to a width ratio threshold value;
and the first decoding submodule is used for executing the first decoding operation on the adjusted bar code characters of the appointed row/column by adopting the ZBar decoding mode.
9. An electronic device, comprising:
processor, memory and computer program stored on the memory and executable on the processor, characterized in that the processor, when executing the program, implements the barcode recognition method according to any one of claims 1 to 6.
10. A readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the barcode recognition method of any of method claims 1-6.
CN201910357591.0A 2019-04-29 2019-04-29 Bar code identification method and device Active CN110222547B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910357591.0A CN110222547B (en) 2019-04-29 2019-04-29 Bar code identification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910357591.0A CN110222547B (en) 2019-04-29 2019-04-29 Bar code identification method and device

Publications (2)

Publication Number Publication Date
CN110222547A CN110222547A (en) 2019-09-10
CN110222547B true CN110222547B (en) 2020-11-03

Family

ID=67820165

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910357591.0A Active CN110222547B (en) 2019-04-29 2019-04-29 Bar code identification method and device

Country Status (1)

Country Link
CN (1) CN110222547B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113408314A (en) * 2020-03-16 2021-09-17 华为技术有限公司 Bar code identification method and related equipment
CN113297867A (en) * 2021-05-21 2021-08-24 苏州视印智能系统有限公司 On-site distributed deployment self-adaptive learning industrial code reader
CN114882370A (en) * 2022-07-07 2022-08-09 西安超嗨网络科技有限公司 Intelligent commodity identification method and device, terminal and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359497A (en) * 2018-09-17 2019-02-19 四川长虹电器股份有限公司 A kind of positioning and recognition methods in VAT invoice two-dimensional image code region

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102880850B (en) * 2012-09-19 2015-08-19 腾讯科技(深圳)有限公司 A kind of method of Quick Response Code batch scanning and scanning device
CN104657700B (en) * 2015-03-25 2017-07-25 广州宽度信息技术有限公司 A kind of Quick Response Code resistant to damage coding/decoding method
JP2017001201A (en) * 2015-06-05 2017-01-05 セイコーエプソン株式会社 Printer, terminal device and print system
CN105824701A (en) * 2016-02-01 2016-08-03 乐视移动智能信息技术(北京)有限公司 Identification code scanning method and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359497A (en) * 2018-09-17 2019-02-19 四川长虹电器股份有限公司 A kind of positioning and recognition methods in VAT invoice two-dimensional image code region

Also Published As

Publication number Publication date
CN110222547A (en) 2019-09-10

Similar Documents

Publication Publication Date Title
CN110222547B (en) Bar code identification method and device
US8774453B2 (en) Method and arrangement for retrieving information comprised in a barcode
CN108717543B (en) Invoice identification method and device and computer storage medium
CN109766890A (en) Information identifying method, equipment and system
CN109117228A (en) The generation method and device of graphical interfaces
US11763167B2 (en) Copy area identification method and device
CN111783495B (en) Bar code identification method and device, electronic equipment and storage medium
CN109214229B (en) Bar code scanning method and device and electronic equipment
US20160104020A1 (en) Barcode decoding
CN110765795B (en) Two-dimensional code identification method and device and electronic equipment
CN111914654B (en) Text layout analysis method, device, equipment and medium
CN112101359B (en) Text formula positioning method, model training method and related device
CN110516494A (en) A kind of two-dimensional code identification method, device, equipment and system
CN112988557A (en) Search box positioning method, data acquisition device and medium
CN110909743A (en) Book checking method and book checking system
CN111767754A (en) Identification code identification method and device, electronic equipment and storage medium
CN107862314B (en) Code spraying identification method and device
CN111914846B (en) Layout data synthesis method, equipment and storage medium
CN105022746B (en) A kind of method, server and system that character library generates
EP3531335B1 (en) Barcode identification method and apparatus
Ciazynski et al. Detection of QR-codes in digital images based on histogram similarity
CN116306731A (en) Method and device for identifying bar codes, electronic equipment and storage medium
CN116229098A (en) Image recognition method based on mask contour tracking and related products
CN111753573B (en) Two-dimensional code image recognition method and device, electronic equipment and readable storage medium
CN115700519A (en) Text-to-image generation method and device, storage medium and terminal

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