A barcode detection and recognition method and device
By combining global binarization with local binarization and barcode feature localization, the problem of low decoding success rate when barcodes are damaged or obscured is solved, and high-precision barcode recognition is achieved in complex environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUNLUX IOT TECHNOLOGY (GUANGDONG) INC
- Filing Date
- 2025-03-26
- Publication Date
- 2026-04-17
AI Technical Summary
Existing barcode detection technologies have a low decoding success rate when the product barcode is damaged or obscured, and global binarization processing can easily cause the loss of local details, resulting in unsatisfactory recognition results.
After global binarization, local binarization is performed on modules that fail to decode. Combining barcode characteristics and a preset window to locate the target area, bar width information is obtained through local binarization, and the bar width information and check bits are used for decoding.
It improves the decoding success rate of barcodes in damaged or obscured conditions, enhances the system's fault tolerance to damaged or interfered areas of the barcode, and ensures the accuracy and reliability of the decoding results.
Smart Images

Figure CN120337958B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of barcode detection technology, and in particular to a barcode detection and recognition method and apparatus. Background Technology
[0002] Currently, for product barcode recognition, the barcode image is globally binarized, and then the barcode is located by combining the bar and space characteristics of the product barcode. After location, the decoding operation is performed based on the width ratio of the bar and space and the EAN13 decoding rules.
[0003] Current barcode detection methods place high demands on the integrity of product barcodes. When products, such as bottled water, are taken out of the refrigerator, water droplets may obscure or damage parts of the barcode. Even after common procedures like gently pressing the packaging or wiping away water droplets, the recognition results may still be unsatisfactory, potentially requiring manual input of the code, which is relatively cumbersome. Furthermore, global binarization processing can easily lead to the loss of local details, further affecting the decoding success rate. Summary of the Invention
[0004] This invention provides a barcode detection and recognition method and apparatus to improve the success rate of barcode decoding.
[0005] To address the aforementioned technical problems, embodiments of the present invention provide a barcode detection and recognition method, comprising:
[0006] A barcode image is acquired; a first binarized image of the barcode image is acquired based on global binarization; the barcode image is recognized based on the first binarized image and barcode localization; and a first recognition result is obtained.
[0007] When the recognition result is recognition failure, the location of the decoding failure module is obtained, and the target area of the barcode image is obtained based on the location of the decoding failure module and the preset window;
[0008] The target region is locally binarized to obtain a second binarized image, and the bar width information of the decoding failure module is obtained based on barcode characteristics, preset search rules, and the second binarized image.
[0009] The barcode image is identified based on the bar width information and the first binarized image to obtain a second recognition result.
[0010] This invention uses global binarization to process images. When decoding fails, it performs local binarization on potentially problematic modules. Local binarization allows for more precise processing of barcode details in specific areas, especially in cases of barcode damage, wrinkles, or water droplets. It effectively compensates for detail loss that might occur with global binarization, thereby improving the decoding success rate. Furthermore, by obtaining the location of the failed decoding module and further locating the target area based on a preset window, and combining barcode characteristics and preset rules, it can infer and repair damaged or blurred barcode portions, obtaining bar width information. This provides stronger fault tolerance when dealing with incomplete or irregular barcodes, further improving the decoding success rate.
[0011] Furthermore, the step of obtaining the location of the decoding failure module, and obtaining the target area of the barcode image based on the location of the decoding failure module and a preset window, includes:
[0012] The location of the decoding failure module is obtained, and the target area of the barcode image is determined based on the preset window, using the previous module of the decoding failure module as the starting point; the target area includes seven modules.
[0013] This invention uses the module preceding the decoding failure module as a starting point and determines the target area based on a preset window, enabling more precise location of potentially problematic regions. This method avoids erroneously selecting areas that are too large or too small, thus ensuring more accurate local binarization processing. Furthermore, by leveraging barcode characteristics and setting the target area to include seven modules, it effectively prevents the omission of critical information areas during local binarization, improving the system's tolerance to damaged or interfered barcode areas.
[0014] Furthermore, the barcode characteristics include seven modules, including two black modules and two white modules; the step of locally binarizing the target area to obtain a second binarized image, and obtaining the bar width information of the decoding failure module based on the barcode characteristics, preset search rules, and the second binarized image, includes:
[0015] Starting from the top left corner of the target region, based on a preset step size, the target region is iteratively binarized in a top-down order to obtain a second binarized image; and the barcode characteristics, preset search rules, and the second binarized image are used to obtain the bar width information of the decoding failure module, until the bar width information of the decoding failure module is obtained, and then the iteration stops.
[0016] This invention achieves accurate recovery of damaged or interfered barcode information by performing local binarization on the target area. Compared to global binarization, local binarization better handles complex situations (such as water droplets, wrinkles, etc.), improving barcode recognition accuracy. Through a top-down iterative processing method, the required bar width information in the module can be identified, avoiding the loss of some information and improving barcode recognition accuracy.
[0017] Furthermore, in each iteration, it is determined whether there are two black information points and two white information points in the second binarized image. If they exist, the position and width information of the black and white information points are recorded, and the strip width information of the decoding failure module is output.
[0018] This invention, by determining the presence of two black information dots and two white information dots and recording their positions and widths, can more accurately extract key information (i.e., bar width information) from barcodes. This method can help accurately recover damaged barcodes, especially in complex interference environments.
[0019] Furthermore, the step of recognizing the barcode image based on the bar width information and the first binarized image to obtain a second recognition result includes:
[0020] Based on the strip width information, a preset width ratio table is searched to obtain the target value;
[0021] The check digit of the barcode image is obtained based on the first binarized image;
[0022] The target value is verified based on the verification bit. If the verification is successful, the barcode image is recognized based on the target value to obtain a second recognition result.
[0023] This invention improves the accuracy and reliability of decoding by searching a width ratio table based on bar width information and combining this with check bits to verify the target value. Check bit verification ensures the validity of the decoding result and prevents erroneous decoding.
[0024] In a second aspect, the present invention provides a barcode detection and recognition device, comprising: 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 acquire a barcode image, acquire a first binarized image of the barcode image based on global binarization, recognize the barcode image based on the first binarized image and barcode positioning, and obtain a first recognition result;
[0026] The target confirmation module is used to obtain the location of the decoding failure module when the recognition result is recognition failure, and obtain the target area of the barcode image based on the location of the decoding failure module and a preset window;
[0027] The bar width acquisition module is used to perform local binarization on the target region to obtain a second binarized image, and to obtain the bar width information of the decoding failure module based on barcode characteristics, preset search rules and the local binarized image;
[0028] The second recognition module is used to recognize the barcode image based on the bar width information and the first binarized image to obtain a second recognition result.
[0029] Furthermore, the target confirmation module is used for:
[0030] The location of the decoding failure module is obtained, and the target area of the barcode image is determined based on the preset window, using the previous module of the decoding failure module as the starting point; the target area includes seven modules.
[0031] Furthermore, the strip width acquisition module is used for:
[0032] Starting from the top left corner of the target region, based on a preset step size, the target region is iteratively binarized in a top-down order to obtain a second binarized image; and the barcode characteristics, preset search rules, and the second binarized image are used to obtain the bar width information of the decoding failure module, until the bar width information of the decoding failure module is obtained, and then the iteration stops.
[0033] Furthermore, in each iteration, it is determined whether there are two black information points and two white information points in the second binarized image. If they exist, the position and width information of the black and white information points are recorded, and the strip width information of the decoding failure module is output.
[0034] Furthermore, the second identification module is used for:
[0035] Based on the strip width information, a preset width ratio table is searched to obtain the target value;
[0036] The check digit of the barcode image is obtained based on the first binarized image;
[0037] The target value is verified based on the verification bit. If the verification is successful, the barcode image is recognized based on the target value to obtain a second recognition result. Attached Figure Description
[0038] Figure 1 A flowchart illustrating a barcode detection and recognition method provided in an embodiment of the present invention;
[0039] Figure 2 A structural diagram of a commodity barcode symbol provided in an embodiment of the present invention;
[0040] Figure 3 This is a schematic diagram of a commodity barcode module provided in an embodiment of the present invention;
[0041] Figure 4 This is a schematic diagram of a barcode detection and recognition method provided in an embodiment of the present invention. Detailed Implementation
[0042] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0043] The terms "first" and "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus.
[0044] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0045] Example 1
[0046] See Figure 1 , Figure 1 This is a flowchart illustrating a barcode detection and recognition method provided in an embodiment of the present invention. The embodiment of the present invention provides a barcode detection and recognition method, including steps 101 to 104, as detailed below:
[0047] Step 101: Obtain a barcode image; obtain a first binarized image of the barcode image based on global binarization; recognize the barcode image based on the first binarized image and barcode localization; and obtain a first recognition result.
[0048] In this embodiment, a barcode image is acquired, and a first binarized image of the barcode image is obtained based on global binarization.
[0049] Please refer to Figure 2 and Figure 3 , Figure 2 A structural diagram of a commodity barcode symbol provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of a product barcode module provided in an embodiment of the present invention.
[0050] In this embodiment, the barcode image is decoded based on the EAN-13 decoding rules. The EAN-13 product barcode consists of a left blank area, a start character, a left data character, a middle separator, a right data character, a check character, a stop character, a right blank area, and human-readable characters.
[0051] In this embodiment, the left blank area is located on the far left of the barcode symbol, in a region with the same reflectivity as the empty space, and its minimum width is 11 modules wide; the start symbol is located to the right of the left blank area of the barcode symbol, a special symbol indicating the start of information, and consists of 3 modules; the left data symbol is located to the right of the start symbol, a special symbol that divides the characters equally, and consists of 35 modules; the middle separator is located to the right of the left data symbol, a special symbol that divides the barcode characters equally, and consists of 5 modules; the right data symbol is located to the right of the middle separator, representing a group of 5-digit barcode characters, and consists of 35 modules; the check symbol is located to the right of the right data symbol, representing the barcode characters of the check digit, and consists of 7 modules; the stop symbol is located to the right of the barcode symbol check symbol, a special symbol indicating the end of information, and consists of 3 modules; the right blank area is located on the far right of the barcode symbol, in a region with the same reflectivity as the empty space, and its minimum width is 7 modules wide.
[0052] In this embodiment, the 13-digit number corresponding to the barcode is located below the barcode 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 barcode character is 0.5 module widths. The prefix code in the human-readable characters of the EAN-13 product barcode is printed to the left of the barcode symbol start character.
[0053] In this embodiment, the barcode image is decoded using the EAN-13 decoding rules to obtain the first recognition result.
[0054] Step 102: When the recognition result is recognition failure, obtain the location of the decoding failure module, and obtain the target area of the barcode image based on the location of the decoding failure module and the preset window;
[0055] In this embodiment, obtaining the location of the decoding failure module and obtaining the target area of the barcode image based on the location of the decoding failure module and a preset window includes:
[0056] The location of the decoding failure module is obtained, and the target area of the barcode image is determined based on the preset window, using the previous module of the decoding failure module as the starting point; the target area includes seven modules.
[0057] In this embodiment, the total length of the barcode image can be obtained based on the start and end positions of the first binarized image. The length of each module is determined according to the total of 95 modules and the total length of the barcode. Then, the start and end module and the middle separator are subtracted to determine the data area of the barcode image. Based on the characteristics of the barcode, each data area consists of 7 modules. When decoding, if a part in the middle cannot be decoded, it can be determined that the data area at that position is missing or occluded. This part is taken as the target area and then divided into local binarizations. The proportional relationship of the 7 modules in the missing part is used for correct decoding.
[0058] In this embodiment, the preset window length is set to 7 modules. During the decoding process, EAN-13 decodes each module one by one. If the decoding is successful, it continues to decode the next module. During the decoding process, when the decoding fails, the module where the decoding failure occurs is recorded. Then, based on the end of the number of modules that were successfully decoded in the previous step, the length of the next 7 modules is taken as the target area of the module that failed to be decoded, thereby performing local binarization on the target area.
[0059] This invention uses the module preceding the decoding failure module as a starting point and determines the target area based on a preset window, enabling more precise location of potentially problematic regions. This method avoids erroneously selecting areas that are too large or too small, thus ensuring more accurate local binarization processing. Furthermore, by leveraging barcode characteristics and setting the target area to include seven modules, it effectively prevents the omission of critical information areas during local binarization, improving the system's tolerance to damaged or interfered barcode areas.
[0060] Step 103: Perform local binarization on the target region to obtain a second binarized image, and obtain the bar width information of the decoding failure module based on barcode characteristics, preset search rules and the second binarized image;
[0061] In this embodiment, the barcode characteristics include seven modules, including two black modules and two white modules; the step of locally binarizing the target area to obtain a second binarized image, and obtaining the bar width information of the decoding failure module based on the barcode characteristics, preset search rules, and the second binarized image, includes:
[0062] Starting from the top left corner of the target region, based on a preset step size, the target region is iteratively binarized in a top-down order to obtain a second binarized image; and the barcode characteristics, preset search rules, and the second binarized image are used to obtain the bar width information of the decoding failure module, until the bar width information of the decoding failure module is obtained, and then the iteration stops.
[0063] In this embodiment, during each iteration, it is determined whether there are two black information points and two white information points in the second binarized image. If they exist, the position and width information of the black and white information points are recorded, and the strip width information of the decoding failure module is output.
[0064] In this embodiment, for the target area, starting from the upper left corner of the target area, local binarization is iterated from top to bottom based on a preset step size. In each iteration, it is checked whether there are only two black information points and two white information points in the local binarized image. If so, it meets the barcode characteristics. The position information, order information and width information of the black information points and white information points are recorded to generate the bar width information of the target area.
[0065] In this embodiment, for the target area, taking advantage of the characteristic that every 7 modules fix 2 black blocks and 2 white blocks, the pixels are locally binarized from top to bottom at intervals. The process stops when 2 black blocks and 2 white blocks are found, and their strip width information is recorded.
[0066] This invention achieves accurate recovery of damaged or interfered barcode information by performing local binarization on the target area. Compared to global binarization, local binarization better handles complex situations (such as water droplets, wrinkles, etc.), improving barcode recognition accuracy. Through a top-down iterative processing method, the required bar width information in the module can be identified, avoiding the loss of some information and improving barcode recognition accuracy.
[0067] In this embodiment, by determining whether there are two black information dots and two white information dots, and recording their positions and widths, the key information of the barcode (i.e., bar width information) can be extracted more accurately. This method can help to accurately recover damaged barcodes, especially in complex interference environments.
[0068] Step 104: Based on the bar width information and the first binarized image, identify the barcode image to obtain a second identification result.
[0069] Please base on Figure 4 , Figure 4 This is a schematic diagram of a barcode detection and recognition method provided in an embodiment of the present invention.
[0070] In this embodiment, after global binarization and barcode localization of the input image, existing decoding methods are used first. If decoding is successful, the decoding result is output correctly. If decoding fails, the new method mentioned in this invention is used. The width of the EAN13 module is approximated to estimate the possible problematic modules, i.e., the target area. Then, by recording the modules that may have problems, local binarization is performed. Taking advantage of the characteristic that every 7 modules have 2 black blocks and 2 white blocks, pixels are taken at intervals from top to bottom for local binarization. When 2 black blocks and 2 white blocks are found, the local binarization stops and their width information is recorded. Local binarization is added to the original global binarization to obtain a new binarized image, and decoding continues. Then, the last check bit is used to check whether the data is correct. If the check passes, the successfully decoded data is output. If the check fails, the data is taken from the width information ratio of the found data for decoding. If the check passes, the successfully decoded data is output. This process continues until all data has been traversed and decoding is still unsuccessful, at which point a decoding failure flag is output.
[0071] In this embodiment, the step of recognizing the barcode image based on the bar width information and the first binarized image to obtain a second recognition result includes:
[0072] Based on the strip width information, a preset width ratio table is searched to obtain the target value;
[0073] The check digit of the barcode image is obtained based on the first binarized image;
[0074] The target value is verified based on the verification bit. If the verification is successful, the barcode image is recognized based on the target value to obtain a second recognition result.
[0075] In this embodiment, in the EAN-13 decoding rules, different strip 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, a new binarized image is obtained by adding the strip width information obtained by local binarization to the original global binarization, and then decoding is continued. Then, the last check bit is used to check whether the target value is correct data. If the check passes, the successfully decoded data is output.
[0077] In this embodiment, if the verification fails, the target region is iterated again based on the position where the last iteration ended, and local binarization is performed until the correct strip width information is found and decoded. If the number of iterations of the target region reaches the maximum limit and the strip width information fails to be verified, a decoding failure flag is output.
[0078] This invention also provides a barcode detection and recognition device, comprising: a first recognition module, a target confirmation module, a bar width acquisition module, and a second recognition module;
[0079] The first recognition module is used to acquire a barcode image, acquire a first binarized image of the barcode image based on global binarization, recognize the barcode image based on the first binarized image and barcode positioning, and obtain a first recognition result;
[0080] The target confirmation module is used to obtain the location of the decoding failure module when the recognition result is recognition failure, and obtain the target area of the barcode image based on the location of the decoding failure module and a preset window;
[0081] The bar width acquisition module is used to perform local binarization on the target region to obtain a second binarized image, and to obtain the bar width information of the decoding failure module based on barcode characteristics, preset search rules and the local binarized image;
[0082] The second recognition module is used to recognize the barcode image based on the bar width information and the first binarized image to obtain a second recognition result.
[0083] In this embodiment, the target confirmation module is used for:
[0084] The location of the decoding failure module is obtained, and the target area of the barcode image is determined based on the preset window, using the previous module of the decoding failure module as the starting point; the target area includes seven modules.
[0085] In this embodiment, the strip width acquisition module is used for:
[0086] Starting from the top left corner of the target region, based on a preset step size, the target region is iteratively binarized in a top-down order to obtain a second binarized image; and the barcode characteristics, preset search rules, and the second binarized image are used to obtain the bar width information of the decoding failure module, until the bar width information of the decoding failure module is obtained, and then the iteration stops.
[0087] In this embodiment, during each iteration, it is determined whether there are two black information points and two white information points in the second binarized image. If they exist, the position and width information of the black and white information points are recorded, and the strip width information of the decoding failure module is output.
[0088] In this embodiment, the second identification module is used for:
[0089] Based on the strip width information, a preset width ratio table is searched to obtain the target value;
[0090] The check digit of the barcode image is obtained based on the first binarized image;
[0091] The target value is verified based on the verification bit. If the verification is successful, the barcode image is recognized based on the target value to obtain a second recognition result.
[0092] In this embodiment, global binarization is used to process the image. When decoding fails, local binarization is performed on the potentially problematic modules. Local binarization allows for more precise processing of barcode details in specific areas, especially in cases of barcode damage, wrinkles, or water droplets. It effectively compensates for the loss of details that global binarization might cause, thereby improving the decoding success rate. Furthermore, by obtaining the location of the failed decoding module and further locating the target area based on a preset window, and combining barcode characteristics and preset rules, damaged or blurred barcode portions can be inferred and repaired. Bar width information is obtained, thus providing stronger fault tolerance when dealing with incomplete or irregular barcodes, further improving the decoding success rate.
[0093] In this embodiment of the invention, a terminal device is also 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, it implements the above-described barcode detection and recognition method.
[0094] In this embodiment of the invention, a computer-readable storage medium is also provided, which includes a stored computer program, wherein the computer program controls the device where the computer-readable storage medium is located to execute the above-described barcode detection and recognition method when it is running.
[0095] For example, a computer program can be divided into one or more modules, one or more of which are stored in memory and executed by a processor to perform the present invention. The one or more modules can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in a terminal device.
[0096] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor, memory, and display. Those skilled in the art will understand that the above components are merely examples of terminal devices and do not constitute a limitation on the terminal device. It may include more or fewer components, or combinations of certain components, or different components. For example, the terminal device may also include input / output devices, network access devices, buses, etc.
[0097] The processor can be a Central Processing Unit (CPU), or 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. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device through various interfaces and lines.
[0098] Memory can be used to store computer programs and / or modules. The processor implements various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for at least one function (such as sound playback, text conversion, etc.), etc.; the data storage area can store data created based on the use of the mobile phone (such as audio data, text message data, etc.). In addition, memory can include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital cards (SD cards), flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.
[0099] In this invention, the module for barcode detection and recognition, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. Those skilled in the art can understand and implement this invention without any inventive effort.
[0100] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A barcode detection and recognition method, characterized in that, include: A barcode image is acquired; a first binarized image of the barcode image is acquired based on global binarization; the barcode image is recognized based on the first binarized image and barcode localization; and a first recognition result is obtained. When the recognition result is recognition failure, the location of the decoding failure module is obtained, and the target area of the barcode image is obtained based on the location of the decoding failure module and the preset window; The target region is locally binarized to obtain a second binarized image, and the bar width information of the decoding failure module is obtained based on the barcode characteristics, preset search rules, and the second binarized image; the barcode characteristics include seven modules, including two black modules and two white modules; The step of performing local binarization on the target region to obtain a second binarized image, and obtaining the bar width information of the decoding failure module based on barcode characteristics, preset search rules, and the second binarized image, includes: starting from the upper left corner of the target region, iteratively performing local binarization on the target region in a top-to-bottom order based on a preset step size to obtain a second binarized image; obtaining the bar width information of the decoding failure module based on barcode characteristics, preset search rules, and the second binarized image, until the bar width information of the decoding failure module is obtained, and stopping the iteration; in each iteration, determining whether there are two black information points and two white information points in the second binarized image, if so, recording the position information and width information of the black information points and the white information points, and outputting the bar width information of the decoding failure module; The barcode image is identified based on the bar width information and the first binarized image to obtain a second recognition result.
2. The barcode detection and recognition method as described in claim 1, characterized in that, The step of obtaining the location of the decoding failure module and obtaining the target area of the barcode image based on the location of the decoding failure module and a preset window includes: The location of the decoding failure module is obtained, and the target area of the barcode image is determined based on the preset window, using the previous module of the decoding failure module as the starting point; the target area includes seven modules.
3. The barcode detection and recognition method as described in claim 1, characterized in that, The step of recognizing the barcode image based on the bar width information and the first binarized image to obtain a second recognition result includes: Based on the strip width information, a preset width ratio table is searched to obtain the target value; The check digit of the barcode image is obtained based on the first binarized image; The target value is verified based on the verification bit. If the verification is successful, the barcode image is recognized based on the target value to obtain a second recognition result.
4. A barcode detection and recognition device, characterized in that, include: The module comprises a first identification module, a target confirmation module, a strip width acquisition module, and a second identification module. The first recognition module is used to acquire a barcode image, acquire a first binarized image of the barcode image based on global binarization, recognize the barcode image based on the first binarized image and barcode positioning, and obtain a first recognition result; The target confirmation module is used to obtain the location of the decoding failure module when the recognition result is recognition failure, and obtain the target area of the barcode image based on the location of the decoding failure module and a preset window; The bar width acquisition module is used to perform local binarization on the target area to obtain a second binarized image, and to obtain the bar width information of the decoding failure module based on barcode characteristics, preset search rules and the second binarized image; the barcode characteristics include seven modules, including two black modules and two white modules; The step of performing local binarization on the target region to obtain a second binarized image, and obtaining the bar width information of the decoding failure module based on barcode characteristics, preset search rules, and the second binarized image, includes: starting from the upper left corner of the target region, iteratively performing local binarization on the target region in a top-to-bottom order based on a preset step size to obtain a second binarized image; obtaining the bar width information of the decoding failure module based on barcode characteristics, preset search rules, and the second binarized image, until the bar width information of the decoding failure module is obtained, and stopping the iteration; in each iteration, determining whether there are two black information points and two white information points in the second binarized image, if so, recording the position information and width information of the black information points and the white information points, and outputting the bar width information of the decoding failure module; The second recognition module is used to recognize the barcode image based on the bar width information and the first binarized image to obtain a second recognition result.
5. The barcode detection and recognition device as described in claim 4, characterized in that, The target confirmation module is used for: The location of the decoding failure module is obtained, and the target area of the barcode image is determined based on the preset window, using the previous module of the decoding failure module as the starting point; the target area includes seven modules.
6. The barcode detection and recognition device as described in claim 4, characterized in that, The second identification module is used for: Based on the strip width information, a preset width ratio table is searched to obtain the target value; The check digit of the barcode image is obtained based on the first binarized image; The target value is verified based on the verification bit. If the verification is successful, the barcode image is recognized 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