Bar code detection and identification method and device

Through global binarization combined with local binarization and barcode characteristic processing, the problem of low decoding success rate when barcode is damaged or occluded is solved, and high-precision recognition and fault tolerance are achieved in complex environments.

CN120337958AActive Publication Date: 2025-07-18SUNLUX IOT TECHNOLOGY (GUANGDONG) INC
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510367427.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2025-07-18
Estimated Expiration
2045-03-26

AI Technical Summary

Technical Problem

When the existing barcode detection technology is damaged or obscured, the decoding success rate is low, and global binary processing is likely to cause local details to be lost, resulting in unsatisfactory recognition effect and cumbersome operation.

Method used

After using global binarization processing, local binarization is performed for the target area of the decoding failure, and bar width information is obtained by combining barcode characteristics and preset rules. The barcode information of the damaged or interfering part is restored through top-down iteration processing, and the decoding result is verified using the check bit.

Benefits of technology

Improves the decoding success rate of barcodes in incomplete or irregular situations, enhances the system's fault tolerance to damaged or disturbed areas, and ensures the accuracy and credibility of identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120337958A_ABST
    Figure CN120337958A_ABST
Patent Text Reader

Abstract

The invention discloses a bar code detection and identification method and device, and the method comprises the steps: obtaining a bar code image, obtaining a first binary image of the bar code image based on global binarization, carrying out the recognition of the bar code image based on the first binary image and bar code positioning, and obtaining a first recognition result; when the identification result is identification failure, obtaining the position of a decoding failure module, and obtaining a target area of the bar code image based on the position of the decoding failure module and a preset window; performing local binaryzation on the target area to obtain a second binaryzation image, and obtaining bar width information of a decoding failure module based on bar code characteristics, a preset search rule and the second binaryzation image; and identifying the bar code image based on the bar width information and the first binary image to obtain a second identification result. The bar width information is speculated and repaired by positioning the target area and combining the bar code characteristics and the preset rules, so that the decoding success rate is improved when the bar codes are incomplete or irregular.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of barcode detection, and particularly to a barcode detection and recognition method and device. Background Art

[0002] Currently, for commodity barcode recognition, global binarization is performed on a barcode image, and then barcode positioning is performed in combination with the bar and space characteristics of the commodity barcode. After positioning, decoding operations are performed according to the width ratio of the bars and spaces in combination with the EAN13 decoding rule.

[0003] In existing barcode detection, there are relatively high requirements for the integrity of commodity barcodes. When commodities such as mineral water are taken out of the refrigerator, there may be water droplets or the like that cause partial parts of the barcode to be blocked or damaged. Even after common operations such as gently pressing the package or wiping the water droplets, the recognition effect may still be unsatisfactory, and ultimately manual input of the code may be required, and the operation is relatively cumbersome. In addition, global binarization processing is also prone to loss of local details, further affecting the decoding success rate. Summary of the Invention

[0004] The present invention provides a barcode detection and recognition method and device to improve the barcode decoding success rate.

[0005] To solve the above technical problems, an embodiment of the present invention provides a barcode detection and recognition method, including:

[0006] Obtain a barcode image, obtain a first binarized image of the barcode image based on global binarization, and perform recognition on the barcode image based on the first binarized image and barcode positioning to obtain a first recognition result;

[0007] When the recognition result is recognition failure, obtain the position of the decoding failure module, and obtain the target area of the barcode image based on the position of the decoding failure module and a preset window;

[0008] Perform local binarization on the target area to obtain a second binarized image, and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the second binarized image;

[0009] Perform recognition on the barcode image based on the bar width information and the first binarized image to obtain a second recognition result.

[0010] The present invention processes the image through global binarization. When decoding fails, local binarization is performed on the module where problems may occur. Through local binarization, more delicate processing can be carried out on the barcode details in a specific area. Especially in the case of interference such as damaged, wrinkled or water droplet on the barcode, it can effectively make up for the detail loss that may be caused by global binarization, thereby improving the decoding success rate. Moreover, by obtaining the position of the decoding failure module, further locating the target area based on a preset window, and combining the barcode characteristics and preset rules, it is possible to speculate and repair the damaged or blurred part of the barcode, obtain the bar width information, so that when facing an incomplete or irregular barcode, it has stronger fault tolerance ability and improves the decoding success rate.

[0011] Further, the obtaining the position of the decoding failure module and obtaining the target area of the barcode image based on the position of the decoding failure module and a preset window includes:

[0012] Obtain the position of the decoding failure module, take the module before the decoding failure module as the starting point, and determine the target area of the barcode image based on the preset window; the target area includes seven modules.

[0013] The present invention takes the module before the decoding failure module as the starting point and determines the target area according to the preset window, which can more accurately locate the area where problems may exist. Using this method, it is possible to avoid erroneously selecting an area that is too large or too small, thereby ensuring more accurate local binarization processing. At the same time, by using the barcode characteristics and setting the target area to include seven modules, it can effectively prevent the omission of key information areas during local binarization, and improve the fault tolerance ability of the system for damaged or interfered areas of the barcode.

[0014] Further, the barcode characteristics include that two of the seven modules are black modules and two are white modules; the performing local binarization on the target area, obtaining a second binarized image, and obtaining the bar width information of the decoding failure module based on the barcode characteristics, a preset search rule and the second binarized image includes:

[0015] Taking the upper left corner of the target area as the starting point, based on a preset step size, iteratively perform local binarization on the target area in a top-down order to obtain a second binarized image; and obtain the bar width information of the decoding failure module based on the barcode characteristics, a preset search rule and the second binarized image until the bar width information of the decoding failure module is obtained, and stop the iteration.

[0016] Through local binarization processing of the target area, the present invention can accurately restore the bar code information of damaged or interfered parts. Compared with global binarization, local binarization can better handle complex situations (such as water droplets, wrinkles, etc.) and improve the accuracy of bar code recognition. Through the top-down iterative processing method, the bar width information required in the module can be recognized, avoiding the loss of some information in the module and being unable to be recognized, and improving the accuracy of bar code recognition.

[0017] Further, in each iteration process, it is determined whether there are two black information points and two white information points in the second binarized image. If so, the position information and width information of the black information points and the white information points are recorded, and the bar width information of the decoding failure module is output.

[0018] By determining whether there are two black information points and two white information points and recording their positions and widths, the present invention can more accurately extract the key information (i.e., bar width information) of the bar code. This method can help accurately restore damaged bar codes, especially in complex interference environments.

[0019] Further, the recognition of the bar code image based on the bar width information and the first binarized image to obtain a second recognition result includes:

[0020] Searching a preset width ratio table based on the bar width information to obtain a target value;

[0021] Obtaining the check digit of the bar code image based on the first binarized image;

[0022] Verifying the target value based on the check digit. If the verification is successful, the bar code image is recognized based on the target value to obtain a second recognition result.

[0023] By searching the width ratio table based on the bar width information and combining the verification of the check digit to verify the target value, the present invention can improve the accuracy and credibility of decoding. The verification of the check digit can ensure the validity of the decoding result and prevent incorrect decoding.

[0024] In a second aspect, the present invention provides a bar code detection and recognition device, including: a first recognition module, a target confirmation module, a bar width acquisition module, and a second recognition module;

[0025] The first recognition module is used to obtain a bar code image, obtain a first binarized image of the bar code image based on global binarization, and recognize the bar code image based on the first binarized image and bar code positioning to obtain a first recognition result;

[0026] The target confirmation module is configured to, when the recognition result is recognition failure, obtain the position of the decoding failure module, and obtain the target area of the barcode image based on the position of the decoding failure module and a preset window;

[0027] The bar width obtaining module is configured to perform local binarization on the target area, obtain a second binarized image, and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the local binarized image;

[0028] The second recognition module is configured to recognize the barcode image based on the bar width information and the first binarized image, and obtain a second recognition result.

[0029] Further, the target confirmation module is configured to:

[0030] Obtain the position of the decoding failure module, take the previous module of the decoding failure module as the starting point, and determine the target area of the barcode image based on the preset window; the target area includes seven modules.

[0031] Further, the bar width obtaining module is configured to:

[0032] Take the upper left corner of the target area as the starting point, based on a preset step size, perform local binarization on the target area iteratively in a top-down order to obtain a second binarized image; and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the second binarized image until the bar width information of the decoding failure module is obtained, and then stop the iteration.

[0033] Further, in each iteration process, determine whether there are two black information points and two white information points in the second binarized image. If so, record the position information and width information of the black information points and the white information points, and output the bar width information of the decoding failure module.

[0034] Further, the second recognition module is configured to:

[0035] Search a preset width ratio table based on the bar width information to obtain a target value;

[0036] Obtain the check digit of the barcode image based on the first binarized image;

[0037] Verify the target value based on the check digit. If the verification is successful, recognize the barcode image based on the target value to obtain a second recognition result. Description of the Drawings

[0038] Figure 1 It is a schematic flowchart of a barcode detection and recognition method provided by an embodiment of the present invention;

[0039] Figure 2 A structural diagram of a commodity barcode symbol provided by an embodiment of the present invention;

[0040] Figure 3 A schematic diagram of the composition of commodity barcode modules provided by an embodiment of the present invention;

[0041] Figure 4 A structural schematic diagram of a barcode detection and recognition method provided by an embodiment of the present invention. Detailed implementation manners

[0042] The following combines the accompanying drawings and embodiments to further describe in detail the specific implementation manners of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0043] The terms "first" and "second" in the specification, claims and drawings of this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.

[0044] Referring to "embodiment" herein means that the specific features, structures or characteristics described in connection with the embodiment can be included in at least one embodiment of this application. The phrase appears at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0045] Embodiment 1

[0046] Refer to Figure 1 , Figure 1 A flowchart of a barcode detection and recognition method provided by an embodiment of the present invention. An embodiment of the present invention provides a barcode detection and recognition method, including steps 101 to 104, as follows:

[0047] Step 101: Obtain a barcode image, obtain a first binary image of the barcode image based on global binarization, and identify the barcode image based on the first binary image and barcode positioning to obtain a first recognition result;

[0048] In this embodiment, a barcode image is obtained, and a first binary image of the barcode image is obtained based on global binarization.

[0049] Please refer to Figure 2 and Figure 3 , Figure 2 which is a structure diagram of a commodity bar code symbol provided by an embodiment of the present invention; Figure 3 which is a schematic diagram of the composition of commodity bar code modules provided by an embodiment of the present invention.

[0050] In this embodiment, the bar code image is decoded based on the EAN-13 decoding rule. Among them, the EAN-13 commodity bar code is composed of a left blank area, a start character, left data characters, a middle separator, right data characters, a check character, a stop character, a right blank area, and human-readable characters.

[0051] In this embodiment, the left blank area is the area with the same reflectivity as the blank at the leftmost side of the bar code symbol, and its minimum width is 11 module widths; the start character is located on the right side of the left blank area of the bar code symbol, which is a special symbol indicating the start of information and consists of 3 modules; the left data characters are located on the right side of the start symbol, which is a special symbol for bisecting characters and consists of 35 modules; the middle separator is located on the right side of the left data characters, which is a special symbol for bisecting bar code characters and consists of 5 modules; the right data characters are located on the right side of the middle separator, which is a group of bar code characters representing 5-digit digital information and consists of 35 modules; the check character is located on the right side of the right data characters, which is a bar code character representing the check code and consists of 7 modules; the stop character is located on the right side of the check character of the bar code symbol, which is a special symbol indicating the end of information and consists of 3 modules; the right blank area is the area with the same reflectivity as the blank at the rightmost side of the bar code symbol, and its minimum width is 7 module widths.

[0052] In this embodiment, there are 13 digits corresponding to the bar code below the bar code symbol. The human-readable characters preferably use the OCR-B character set specified in GB / T 12508; the minimum distance between the top of the character and the bottom of the bar code character is 0.5 module width. The prefix code in the human-readable characters of the EAN-13 commodity bar code is printed on the left side of the start character of the bar code symbol.

[0053] In this embodiment, the bar code image is decoded through the EAN-13 decoding rule to obtain a first recognition result.

[0054] Step 102: When the recognition result is recognition failure, obtain the position of the decoding failure module, and obtain the target area of the bar code image based on the position of the decoding failure module and a preset window;

[0055] In this embodiment, the obtaining the position of the decoding failure module and obtaining the target area of the bar code image based on the position of the decoding failure module and a preset window includes:

[0056] Obtain the position of the decoding failure module. Taking the module before the decoding failure module as the starting point, determine the target area of the barcode image based on the preset window; the target area includes seven modules.

[0057] In this embodiment, based on the start and end positions of the first binary image, the total length of the barcode of the barcode image can be obtained. According to the 95 modules of the total barcode length and the total length, the length of each module can be determined. Then, subtracting the start and end position modules and the middle separator can determine the data area of the barcode image. Based on the barcode characteristics, each data area is composed of 7 modules respectively. When decoding, if there are some positions that cannot be decoded in the middle, it can be determined that there are defects or occlusions in the data area at this position, and this position is used as the target area, so as to divide it into local binaryzation; perform correct decoding according to the proportional relationship of the 7 modules in the defective part.

[0058] In this embodiment, the length of the preset window is set to 7 modules. During the decoding process of EAN-13, each module is decoded one by one. If the decoding is successful, continue to decode the next module. During the decoding process, when the decoding fails, record the module where the decoding fails. Then, taking the end of the number of modules successfully decoded last time as the starting point, the length area of the next 7 module numbers is used as the target area of the decoding failure module, so as to perform local binaryzation on this target area.

[0059] The present invention takes the module before the decoding failure module as the starting point and determines the target area according to the preset window, which can more accurately locate the area that may have problems. Using this method, it is possible to avoid incorrectly selecting an area that is too large or too small, thereby ensuring that the local binaryzation process is more accurate. At the same time, using the barcode characteristics, setting the target area to include seven modules can effectively prevent missing key information areas during local binaryzation, and improve the fault tolerance ability of the system for damaged or interfered areas of the barcode.

[0060] Step 103: Perform local binaryzation on the target area to obtain a second binary image, and obtain the bar width information of the decoding failure module based on the barcode characteristics, the preset search rule, and the second binary image;

[0061] In this embodiment, the barcode characteristics include that there are two black modules and two white modules in the seven modules; the performing local binaryzation on the target area to obtain a second binary image, and obtaining the bar width information of the decoding failure module based on the barcode characteristics, the preset search rule, and the second binary image includes:

[0062] Starting from the upper left corner of the target area, based on a preset step size, iteratively perform local binarization on the target area in a top-down order to obtain a second binarized image; and obtain the bar width information of the decoding failure module based on the bar code characteristics, preset search rules, and the second binarized image, and stop the iteration until the bar width information of the decoding failure module is obtained.

[0063] In this embodiment, during each iteration process, determine whether there are two black information points and two white information points in the second binarized image. If so, record the position information and width information of the black information points and the white information points, and output the bar width information of the decoding failure module.

[0064] In this embodiment, for the target area, starting from the upper left corner of the target area, iteratively perform local binarization from top to bottom based on a preset step size. During each iteration process, check whether there are only two black information points and two white information points in the locally binarized image. If so, it conforms to the bar code characteristics, and record the position information, sequence information, and width information of the black information points and the white information points, so as to generate the bar width information of the target area.

[0065] In this embodiment, for the target area, utilize the characteristic that 2 black blocks and 2 white blocks are fixed in every 7 modules, take pixel points for local binarization at intervals from top to bottom, stop when 2 black blocks and 2 white blocks are found, and record their bar width information.

[0066] By performing local binarization processing on the target area, the present invention can accurately restore the bar code information of the damaged or interfered part. Compared with global binarization, local binarization can better handle complex situations (such as water droplets, wrinkles, etc.) and improve the accuracy of bar code recognition. Through the top-down iterative processing method, the bar width information required in the module can be recognized, avoiding the loss of some information in the module and being unable to be recognized, and improving the accuracy of bar code recognition.

[0067] In this embodiment, by determining whether there are two black information points and two white information points and recording their positions and widths, the key information (i.e., bar width information) of the bar code can be extracted more accurately. This method can help accurately restore damaged bar codes, especially in complex interference environments.

[0068] Step 104: Based on the bar width information and the first binarized image, recognize the bar code image to obtain a second recognition result.

[0069] Please be based on Figure 4 , Figure 4 is a structural schematic diagram of a bar code detection and recognition method provided by an embodiment of the present invention.

[0070] In this embodiment, for the input image, after global binarization and barcode localization, if the existing method can be directly used for decoding and the decoding is successful, the decoding result is correctly output. If the decoding fails, the new method mentioned in the present invention is used. By approximating the width of the EAN13 module, the problem modules that may occur, that is, the target area, are estimated. Then, by recording the modules that may have problems, local binarization is performed. Utilizing the characteristic that there are 2 black blocks and 2 white blocks fixed in every 7 modules, pixel points are taken at intervals from top to bottom for local binarization, and the process stops when 2 black blocks and 2 white blocks are found, and their width information is recorded. On the basis of the original global binarization, local binarization is added to obtain a new binarized image, and then decoding continues. Then, using the last check digit, it is verified whether the data is correct. If the verification passes, the successfully decoded data is output. If the verification fails, the data from the found width information ratio is taken out for decoding again. If the verification passes, the successfully decoded data is output. If the data is traversed and the decoding is still not successful, a decoding failure flag is output.

[0071] In this embodiment, recognizing the barcode image based on the bar width information and the first binarized image to obtain a second recognition result includes:

[0072] Searching a preset width ratio table based on the bar width information to obtain a target value;

[0073] Obtaining the check digit of the barcode image based on the first binarized image;

[0074] Verifying the target value based on the check digit, and if the verification is successful, recognizing the barcode image based on the target value to obtain a second recognition result.

[0075] In this embodiment, in the EAN-13 decoding rule, different bar width information represents different values, and the target value of the target area can be obtained based on the preset width ratio table.

[0076] In this embodiment, on the basis of the original global binarization, the bar width information obtained by adding local binarization is used to obtain a new binarized image, and then decoding continues. Then, using the last check digit, it is verified whether the target value is correct data. If the verification passes, the successfully decoded data is output.

[0077] In this embodiment, if the verification fails, local binarization is iteratively performed on the target area again based on the position where the previous iteration ended until the correct bar width information is searched for decoding. If the number of iterations of the target area reaches the maximum upper limit and the bar width information all fails the verification, a decoding failure flag is output.

[0078] An embodiment of the present invention also provides a bar code detection and recognition device, including: a first recognition module, a target confirmation module, a bar width acquisition module, and a second recognition module;

[0079] The first recognition module is configured to obtain a bar code image, obtain a first binary image of the bar code image based on global binarization, and recognize the bar code image based on the first binary image and bar code positioning to obtain a first recognition result;

[0080] The target confirmation module is configured to, when the recognition result is recognition failure, obtain the position of the decoding failure module, and obtain the target area of the bar code image based on the position of the decoding failure module and a preset window;

[0081] The bar width acquisition module is configured to perform local binarization on the target area to obtain a second binary image, and obtain the bar width information of the decoding failure module based on bar code characteristics, a preset search rule, and the local binary image;

[0082] The second recognition module is configured to recognize the bar code image based on the bar width information and the first binary image to obtain a second recognition result.

[0083] In this embodiment, the target confirmation module is configured to:

[0084] Obtain the position of the decoding failure module, take the previous module of the decoding failure module as the starting point, and determine the target area of the bar code image based on the preset window; the target area includes seven modules.

[0085] In this embodiment, the bar width acquisition module is configured to:

[0086] Take the upper left corner of the target area as the starting point, perform local binarization on the target area iteratively in a top-down order based on a preset step size to obtain a second binary image; and obtain the bar width information of the decoding failure module based on bar code characteristics, a preset search rule, and the second binary image until the bar width information of the decoding failure module is obtained, and stop the iteration.

[0087] In this embodiment, in each iteration process, it is determined whether there are two black information points and two white information points in the second binary image. If so, record the position information and width information of the black information points and the white information points, and output the bar width information of the decoding failure module.

[0088] In this embodiment, the second recognition module is configured to:

[0089] Search a preset width ratio table based on the bar width information to obtain a target value;

[0090] Obtain the check digit of the bar code image based on the first binarized image;

[0091] Verify the target value based on the check digit. If the verification is successful, recognize the bar code image based on the target value to obtain a second recognition result.

[0092] In this embodiment, the image is processed by global binarization. When decoding fails, local binarization is performed on the module that may have problems. Local binarization can perform more refined processing on the bar code details in a specific area. Especially in the case of interference such as damaged, wrinkled or water droplet bar codes, it can effectively make up for the detail loss that may be caused by global binarization, thereby improving the decoding success rate. Moreover, by obtaining the position of the decoding failure module, further positioning the target area based on a preset window, and combining the bar code characteristics and preset rules, it is possible to speculate and repair the damaged or blurred part of the bar code, obtain the bar width information, so that when facing an incomplete or irregular bar code, it has stronger fault tolerance and improves the decoding success rate.

[0093] In an embodiment of the present invention, a terminal device is further provided, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the above-mentioned bar code detection and recognition method is implemented.

[0094] In an embodiment of the present invention, a computer-readable storage medium is further provided. The computer-readable storage medium includes a stored computer program. When the computer program runs, it controls the device where the computer-readable storage medium is located to execute the above-mentioned bar code detection and recognition method.

[0095] Exemplarily, the computer program can be divided into one or more modules. One or more modules are stored in the memory and executed by the processor to complete the present invention. One or more modules can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.

[0096] The terminal device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The terminal device may include, but is not limited to, a processor, a memory, and a display. Those skilled in the art can understand that the above components are only examples of the terminal device and do not constitute a limitation on the terminal device. It may include more or fewer components than those described, or combine some components, or different components. For example, the terminal device may further include input / output devices, network access devices, a bus, etc.

[0097] The so-called processor may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The processor is the control center of the terminal device, connecting all parts of the entire terminal device through various interfaces and lines.

[0098] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory, and by invoking the data stored in the memory. The memory may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function (such as a sound playback function, a text conversion function, etc.); the data storage area may store data created according to the use of the mobile phone (such as audio data, text message data, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0099] Among them, when the module for barcode detection and recognition is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of the present invention, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-described various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. Those of ordinary skill in the art can understand and implement it without creative efforts.

[0100] The specific embodiments described above further elaborate on the purpose, technical solutions, and beneficial effects of the present invention. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. In particular, for those skilled in the art, any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A barcode detection and recognition method, characterized in that, Including: Obtain a barcode image, obtain a first binary image of the barcode image based on global binarization, identify the barcode image based on the first binary image and barcode positioning, and obtain a first recognition result; When the recognition result is recognition failure, obtain the position of the decoding failure module, and obtain the target area of the barcode image based on the position of the decoding failure module and a preset window; Perform local binarization on the target area, obtain a second binary image, and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the local binary image; Identify the barcode image based on the bar width information and the first binary image, and obtain a second recognition result.

2. The barcode detection and recognition method according to claim 1, characterized in that The obtaining the position of the decoding failure module, and obtaining the target area of the barcode image based on the position of the decoding failure module and a preset window includes: Obtain the position of the decoding failure module, use the module previous to the decoding failure module as the starting point, and determine the target area of the barcode image based on the preset window; the target area includes seven modules.

3. A barcode detection and recognition method according to claim 1, characterized in that, The barcode characteristics include that there are two black modules and two white modules in the seven modules; the performing local binarization on the target area, obtaining a second binary image, and obtaining the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the second binary image includes: Taking the upper left corner of the target area as the starting point, based on a preset step size, perform local binarization on the target area iteratively in a top-down order to obtain a second binary image; and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the second binary image until the bar width information of the decoding failure module is obtained, and stop the iteration.

4. The barcode detection and recognition method according to claim 3, characterized in that, In each iteration process, determine whether there are two black information points and two white information points in the second binary image. If so, record the position information and width information of the black information points and the white information points, and output the bar width information of the decoding failure module.

5. A barcode detection and recognition method according to claim 4, characterized in that, The identifying the barcode image based on the bar width information and the first binary image, and obtaining a second recognition result includes: Search a preset width ratio table based on the bar width information to obtain a target value; Obtain the check digit of the barcode image based on the first binary image; Verify the target value based on the check digit. If the verification is successful, identify the barcode image based on the target value to obtain a second recognition result.

6. A barcode detection and recognition device, characterized in that, Including: A first recognition module, a target confirmation module, a bar width obtaining module, and a second recognition module; The first recognition module is used to obtain a barcode image, obtain a first binary image of the barcode image based on global binarization, identify the barcode image based on the first binary image and barcode positioning, and obtain a first recognition result; The target confirmation module is used to, when the recognition result is recognition failure, obtain the position of the decoding failure module, and obtain the target area of the barcode image based on the position of the decoding failure module and a preset window; The bar width acquisition module is configured to perform local binarization on the target area to obtain a second binarized image, and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the local binarized image; The second recognition module is configured to recognize the barcode image based on the bar width information and the first binarized image to obtain a second recognition result.

7. The barcode detection and recognition device according to claim 6, wherein The target confirmation module is configured to: Obtain the position of the decoding failure module, take the previous module of the decoding failure module as the starting point, and determine the target area of the barcode image based on the preset window; the target area includes seven modules.

8. The barcode detection and recognition device according to claim 6, characterized in that, The bar width acquisition module is configured to: Taking the upper left corner of the target area as the starting point, based on a preset step size, perform local binarization on the target area iteratively in a top-down order to obtain a second binarized image; and obtain the bar width information of the decoding failure module based on barcode characteristics, a preset search rule, and the second binarized image, and stop the iteration until the bar width information of the decoding failure module is obtained.

9. The barcode detection and recognition device according to claim 8, wherein, In each iteration process, determine whether there are two black information points and two white information points in the second binarized image. If so, record the position information and width information of the black information points and the white information points, and output the bar width information of the decoding failure module.

10. A barcode detection and recognition device according to claim 9, characterized in that, The second recognition module is configured to: Search a preset width ratio table based on the bar width information to obtain a target value; Obtain the check digit of the barcode image based on the first binarized image; Verify the target value based on the check digit. If the verification is successful, recognize the barcode image based on the target value to obtain a second recognition result.

Citation Information

Patent Citations

  • Chinese-sensible code barcode decoding chip and decoding method thereof

    CN101882211A

  • One-dimensional bar code word decoding method based on least square method

    CN106874820A

  • Method and device for decoding EAN13 code

    CN107766770A

  • Bar code decoding method and device

    CN115510889A

  • Camera-based barcode recognition

    US20060202039A1