Barcode positioning method, storage medium and computer

By employing an image processing method based on barcode texture features and utilizing rasterization and clustering analysis, the accuracy and speed issues of barcode localization in complex backgrounds were resolved, achieving fast and robust barcode region recognition.

CN114692660BActive Publication Date: 2026-07-31DSTEK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DSTEK CO LTD
Filing Date
2020-12-28
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately and quickly locate barcodes in complex backgrounds, as they are significantly affected by lighting and background interference.

Method used

An image processing method based on barcode texture features is adopted. By rasterizing the grayscale image, texture feature values ​​are calculated, clustering methods are used to identify barcode regions, and the regions are located by cutting out the outer rectangle.

Benefits of technology

It achieves accurate positioning of barcode areas in complex backgrounds, is fast, robust, and suitable for subsequent barcode recognition and decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114692660B_ABST
    Figure CN114692660B_ABST
Patent Text Reader

Abstract

This invention provides a barcode positioning method, a storage medium, and a computer. The barcode positioning method includes: acquiring a grayscale image including a barcode; rasterizing the grayscale image; calculating the texture feature value of each raster, wherein the texture feature value of each raster is the ratio of the average grayscale change of its rows to the average grayscale change of its columns; analyzing the texture feature values ​​of the raster to obtain a barcode region; and cutting the barcode region according to the bounding rectangle of the raster set of the barcode region. This method is unaffected by lighting conditions and background interference, accurately positioning the barcode region within the entire image, and is relatively fast with good overall robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a barcode positioning method, storage medium, and computer in complex backgrounds. Background Technology

[0002] Barcodes are widely used in society. Although QR codes have greater storage capacity and reliability, one-dimensional barcodes still have advantages such as low cost and ease of production. Therefore, in industrial production or some specific industries, barcodes are often more suitable for the needs.

[0003] However, the barcodes that need to be identified are often in complex backgrounds. Before identification and decoding, a localization algorithm must be added to extract the barcode from the overall background image. However, considering factors such as lighting conditions and background diversity, it is obviously difficult to achieve the goal by starting with the grayscale features and morphological features of the image for localization.

[0004] Therefore, it is necessary to propose an improved solution to overcome the above problems. Summary of the Invention

[0005] The purpose of this invention is to provide a barcode positioning method, storage medium, and computer that are unaffected by lighting and background interference, can accurately locate the barcode area in the entire image, and is fast with good overall robustness in positioning.

[0006] To achieve the objective of the invention, according to one aspect of the present invention, a barcode positioning method is provided, comprising: acquiring a grayscale image including a barcode; rasterizing the grayscale image; calculating a texture feature value for each raster, wherein the texture feature value for each raster is the ratio of the average grayscale variation of the row to the average grayscale variation of the column of the raster; analyzing the texture feature values ​​of the raster to obtain a barcode region; and cutting the barcode region according to the bounding rectangle of the raster set of the barcode region.

[0007] According to another aspect of the present invention, a storage medium is provided that stores program instructions, wherein the barcode positioning method described above is executed during program execution.

[0008] According to another aspect of the present invention, a computer is provided, comprising a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to perform the barcode positioning method described above.

[0009] Compared with existing technologies, this invention is based on the texture features of barcodes and uses traditional image algorithms to preprocess barcode images, locate the position of the barcode in a complex background, segment the barcode area, and is not affected by lighting or background interference. It can accurately locate the barcode area in the whole image, and the speed is relatively fast, with good overall robustness in positioning. Attached Figure Description

[0010] Figure 1 This is a flowchart illustrating one embodiment of the barcode positioning method of the present invention;

[0011] Figure 2 This is an example of a grayscale image including a barcode in this invention;

[0012] Figure 3 This invention provides a view of the normalized grid texture feature values ​​of the grayscale image. Detailed Implementation

[0013] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following detailed description of the specific implementation methods, structure, features and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided.

[0014] This invention proposes a barcode positioning method, storage medium, and computer for complex backgrounds. It is unaffected by lighting and background interference, can accurately locate the barcode area in the entire image, and is fast. The positioning has good overall robustness, providing favorable conditions for subsequent barcode recognition and decoding.

[0015] Figure 1 This is a flowchart illustrating one embodiment of the barcode positioning method 100 of the present invention. Figure 1 As shown, the barcode positioning method 100 includes the following steps.

[0016] Step 110: Obtain a grayscale image including the barcode.

[0017] In one embodiment, the captured image including the barcode can be converted into a grayscale image. For example... Figure 2 As shown, it displays a grayscale image including a barcode.

[0018] Step 120: Rasterize the grayscale image.

[0019] Specifically, the grayscale image is rasterized according to the size of the grayscale image and the barcode. The side length of each raster along the length of the barcode barcode does not exceed the length of the barcode barcode, and the side length of each raster along the width of the barcode barcode is not less than the width of the barcode barcode. This ensures that the barcode can include multiple raster cells, and that the texture features of the barcode are highlighted in each raster cell.

[0020] It should be noted that at this point, the presence and size of a barcode in the grayscale image have already been roughly determined using existing traditional algorithms.

[0021] Step 130: Calculate the texture feature value of each grid cell. The texture feature value of each grid cell is the ratio of the average gray level change of the row of the grid cell to the average gray level change of the column of the grid cell.

[0022] Considering the characteristics of barcodes, which store information through black-and-white transitions ("0" to "1") along the horizontal axis but not along the vertical axis, the ratio of the average grayscale change values ​​along the horizontal and vertical axes is used as the texture feature value of the raster. For example... Figure 2 As shown, the barcode is arranged horizontally.

[0023] Specifically, in each grid cell, the grayscale difference between the i-th row and the (i-1)-th row, and the grayscale difference between the j-th column and the (j-1)-th column are calculated. The sum of the row grayscale differences and the sum of the column grayscale differences are accumulated and then divided by the number of rows N and the number of columns M of each grid cell to obtain the mean of the row grayscale differences and the mean of the column grayscale differences. Then, the ratio of these two data is calculated to obtain the texture feature value of each grid cell.

[0024] More specifically, the texture feature value of each raster is calculated according to the following formula:

[0025]

[0026] Where x(i,j) is the gray value of the i-th column and j-th row in each grid cell, N is the number of rows in each grid cell, and M is the number of columns in each grid cell.

[0027] Figure 3 This invention provides a view of the normalized grid texture feature values ​​of the grayscale image.

[0028] Step 140: Analyze the texture feature values ​​of the grid to obtain the barcode area.

[0029] In one embodiment, step 140 includes the following steps:

[0030] Step 141: Compare the texture feature value of each grid cell with the texture feature threshold to determine whether the grid cell is located in the candidate area of ​​the barcode region. Because the barcode undergoes grayscale transitions along the horizontal axis but not along the vertical axis, if the texture feature value is greater than 1, it indicates that the grayscale change along the horizontal axis is greater than that along the vertical axis, which means it is a candidate area for the barcode region. If the texture feature value is less than or equal to 1, it indicates that it is a non-barcode region feature and must be a background region, meaning the texture feature threshold is 1.

[0031] It should be noted that the above description uses a horizontally arranged barcode as an example. If the barcode is arranged vertically, the process is reversed; simply invert the ratio of the average row grayscale variation to the average column grayscale variation of the grid. In other words, the ratio of the average row grayscale variation to the average column grayscale variation of the grid in this invention can be either the average row grayscale variation divided by the average column grayscale variation, or vice versa. The choice of ratio depends on the orientation of the barcode arrangement.

[0032] Step 142: Use clustering method to perform secondary analysis on the texture feature values ​​of the raster of the candidate area of ​​the barcode region to obtain the barcode region.

[0033] Specifically, a clustering method can be used to automatically divide the texture feature values ​​of the raster in the candidate area of ​​the barcode region into two categories. Since the clustering required here is relatively simple, the K-Means clustering method can be used. If the difference between the center values ​​of the two categories is large, for example, greater than a predetermined value, then the area with the smaller center value is determined to be a character area, and the area with the larger center value is determined to be a barcode area; if the difference between the center values ​​of the two categories is small, for example, less than a predetermined value, then it is determined that there is no character area in the barcode candidate area, and both categories are barcode areas.

[0034] Step 150: The barcode region is cut out from the original image according to the bounding rectangle of the grid set of the barcode region for subsequent code recognition and decoding.

[0035] Thus, the barcode positioning method in this invention is unaffected by lighting and background interference, can accurately locate the barcode area in the entire image, and is fast. The overall positioning is robust, providing good conditions for subsequent barcode recognition and decoding.

[0036] According to another aspect of the present invention, a storage medium is provided storing program instructions that are executed to perform the barcode positioning method described above. For simplicity, the specific details of the image barcode positioning method will not be repeated here.

[0037] According to another aspect of the present invention, a computer is provided, comprising a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to perform the barcode positioning method described above. For simplicity, the specific details of the barcode positioning method will not be repeated here.

[0038] In this document, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, which includes not only the elements listed but also other elements not expressly listed.

[0039] In this document, the directional terms such as front, back, top, and bottom are defined based on the location of the components in the accompanying drawings and their relative positions to each other, solely for the purpose of clarity and convenience in expressing the technical solution. It should be understood that the use of these directional terms should not limit the scope of protection claimed in this application.

[0040] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0041] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0042] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0043] These computer program instructions can also be loaded onto a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0044] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

Claims

1. A method of positioning a barcode, characterized by, It includes: Obtain a grayscale image including the barcode; Rasterize the grayscale image; Calculate the texture feature value of each grid cell. The texture feature value of each grid cell is the ratio of the mean gray level change of the row of the grid cell to the mean gray level change of the column of the grid cell. The barcode region is obtained by analyzing the texture feature values ​​of the grid; and The barcode region is obtained by cutting the bounding rectangle of the grid set of the barcode region. The calculation of the texture feature value for each raster includes: In each grid cell, calculate the grayscale difference between the i-th row and the (i-1)-th row, and the grayscale difference between the j-th column and the (j-1)-th column. Accumulate the sum of the row grayscale differences and the sum of the column grayscale differences, then divide each sum by the number of rows N and the number of columns M of each grid cell to obtain the mean of the row grayscale differences and the mean of the column grayscale differences. Finally, calculate the ratio of these two values. The texture feature value of each raster is calculated using the following formula: where x(i,j) is the gray value in each grid at the i-th row and j-th column, The barcode region is obtained by analyzing the texture feature values ​​of the grid, including: The texture feature value of each raster is compared with a texture feature threshold to determine whether the raster is located in the candidate area of ​​the barcode region; The barcode region is obtained by performing secondary analysis on the texture feature values ​​of the raster in the candidate area of ​​the barcode region using a clustering method. The process of using clustering to perform secondary analysis on the texture feature values ​​of the raster in the candidate area of ​​the barcode region to obtain the barcode region includes: The clustering method automatically divides the texture feature values ​​of the grid in the candidate area of ​​the barcode region into two categories. If the difference between the center values ​​of the two categories is greater than a predetermined value, the region with the smaller center value is determined to be a character region, and the region with the larger center value is determined to be a barcode region. If the difference between the center values ​​of the two categories is less than a predetermined value, it is determined that there is no character region in the barcode candidate area, and both categories are barcode regions.

2. The barcode positioning method as described in claim 1, characterized in that, The step of obtaining a grayscale image including a barcode includes converting the captured image including the barcode into a grayscale image.

3. The method of claim 1, wherein, Before rasterizing the grayscale image, it also includes: The presence and size of a barcode in the grayscale image are roughly determined.

4. A storage medium, characterized by It stores program instructions that are executed to perform the barcode positioning method as described in any one of claims 1-3.

5. A computer, characterized in that It includes a processor and a memory, the memory storing program instructions, and the processor executing the program instructions to perform the barcode positioning method as described in any one of claims 1-3.