A barcode scanning method and device based on multi-color light source comparison

By using multi-color light source comparison and image processing technology, the contributing area of ​​the image code is extracted, which solves the problem of scanning and recognition failure caused by insufficient light source and achieves efficient and accurate scanning and recognition.

CN118396007BActive Publication Date: 2025-11-14FOSHAN XINCODE ELECTRONICS TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410335782.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-22
Publication Date
2025-11-14
Estimated Expiration
2044-03-22

AI Technical Summary

Technical Problem

Existing scanning methods are prone to low image brightness when the light source is insufficient, which affects the recognition effect, and there is still a problem of recognition failure under monochromatic light source illumination.

Method used

Multiple coded images are acquired by illuminating them with multi-color light sources. The image-code contribution areas are extracted through image comparison and edge detection algorithms. Image preprocessing and perspective transformation are then performed, and finally, the information is decoded and obtained.

Benefits of technology

It improves the success rate and accuracy of image barcode recognition and solves the problem of recognition failure caused by insufficient light source.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118396007B_ABST
    Figure CN118396007B_ABST
Patent Text Reader

Abstract

This invention relates to a scanning method and apparatus based on multi-color light source comparison, comprising: illuminating the m code-containing images separately using a pre-set multi-color light source, ensuring at least one image is acquired under each color light source; comparing the m code-containing images and obtaining a representative image based on the comparison results; performing a first preprocessing on the representative image to obtain a first preprocessed image; extracting edges from the first preprocessed image using an edge detection algorithm to obtain an edge image; performing a second preprocessing on the edge image to obtain a second preprocessed image; and decoding the second preprocessed image to obtain the information recorded within the code. This invention can maximize the inclusion of all image and code information in the final representative image, and then using a combined edge detection and QR code correction processing method to decode and obtain the information recorded within the code, significantly improving the success rate and accuracy of image and code recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of barcode scanning and identification technology, and in particular to a barcode scanning method and apparatus based on multi-color light source comparison. Background Technology

[0002] With the widespread use of smart devices, scanning QR codes to obtain information has become a common method. Scanning a QR code involves using a mobile phone, PC, or other device to scan a barcode or QR code to obtain the information contained within. Overall, due to its convenience, security, and versatility, scanning QR codes to obtain information has become an indispensable part of modern life.

[0003] Current scanning methods typically involve directly acquiring images containing barcodes or QR codes, then using general image recognition algorithms to identify the codes and extract the information. This approach doesn't account for the possibility of low-brightness images due to insufficient light, which can negatively impact subsequent recognition. While improvements are being made, such as using monochromatic light sources to illuminate the images before recognition, this method still suffers from a relatively high frequency of recognition failures. Summary of the Invention

[0004] The purpose of this invention is to at least address one of the shortcomings of the prior art by providing a barcode scanning method and apparatus based on multi-color light source comparison.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] Specifically, a barcode scanning method based on multi-color light source comparison is proposed, including the following:

[0007] The images are illuminated by a pre-set multi-color light source and a total of m coded images are obtained, ensuring that at least one image is obtained under each color light source.

[0008] Image comparison is performed on m images containing codes, and a representative image for identification is obtained based on the comparison results;

[0009] The first preprocessing is performed on the identified representative image to obtain the first preprocessed image;

[0010] An edge image is obtained by performing edge extraction on the first preprocessed image using an edge detection algorithm;

[0011] The edge image is subjected to a second preprocessing to obtain a second preprocessed image;

[0012] The second preprocessed image is decoded to obtain the information recorded in the code.

[0013] Furthermore, specifically, image comparison is performed on m coded images, and representative images are obtained based on the comparison results, including:

[0014] For any image containing a code, calculate the image code contribution rate of its pixels. The formula for calculating the image code contribution rate is as follows:

[0015]

[0016] Here, the image matrix of the i-th coded image is defined as Ri(i), the pixel value of the pixel in the li-th row and hi-th column of Ri(i) is Ri(i, li, hi), the corresponding devote(i, li, hi) is the image-code contribution rate of the pixel in the li-th row and hi-th column of Ri(i), and max(i, li, hi), avg(i, li, hi) and min(i, li, hi) are the maximum, average and minimum values ​​of the 8 neighboring pixels of Ri(i, li, hi), respectively.

[0017] The corresponding code contribution region of the image is marked based on the code contribution rate;

[0018] Calculate the average pixel value of all pixels in m coded images, and use the average pixel value of all pixels to form a base image;

[0019] The corresponding pixel positions in the base image are replaced with the corresponding pixel positions in all the image contribution areas to obtain the recognition representative image.

[0020] Furthermore, specifically, the image-code contribution region of the corresponding code-containing image is marked based on the image-code contribution rate, including,

[0021] For the first image containing the code, i.e., i=1, traverse the image matrix R1(1) of the first image containing the code, select the two pixels with the largest value of the code contribution rate, connect the two pixels to obtain the line segment Zxd(1), select the pixel with the largest value of the code contribution rate other than the line segment Zxd(1) in R1(1), connect the two endpoints of the line segment Zxd(1) to the pixel with the largest value of the code contribution rate other than the line segment Zxd(1), and the connected area is the code contribution area corresponding to the first image containing the code.

[0022] For images other than the first coded image (i.e., i>1), obtain the average pixel value avg(i-1) of the coded contribution region of Ri-1(i-1). Iterate through Ri(i) and randomly select two pixels whose coded contribution rate is not lower than avg(i-1). Connect these two pixels to obtain line segment Zxd(i). In Ri(i), select the pixel with the largest coded contribution rate other than line segment Zxd(i). Connect the two endpoints of line segment Zxd(i) to the pixel with the largest coded contribution rate other than line segment Zxd(i). The connected region is the coded contribution region corresponding to the current coded image.

[0023] Further, specifically, the identified representative image undergoes a first preprocessing step to obtain a first preprocessed image, including:

[0024] The representative image for identification is converted to grayscale and denoised to obtain a first preprocessed image, thereby improving the accuracy of subsequent identification.

[0025] Furthermore, specifically, an edge image is obtained by performing edge extraction on the first preprocessed image using an edge detection algorithm based on the Canny operator.

[0026] Further, specifically, the edge image undergoes a second preprocessing step to obtain a second preprocessed image, including:

[0027] The position and orientation of the QR code are determined based on the pre-set positioning marks on the edge image;

[0028] The QR code image is then corrected using a perspective transformation algorithm to obtain the second preprocessed image.

[0029] Furthermore, specifically, the QR code image is corrected using a perspective transformation algorithm, including:

[0030] The corner points of the QR code are found using a corner detection algorithm, and then perspective transformation is performed using these corner points.

[0031] The present invention also proposes a barcode scanning device based on multi-color light source comparison, comprising:

[0032] The data acquisition module is used to illuminate the image with a pre-set multi-color light source and acquire a total of m images containing codes, ensuring that at least one image is acquired under each color light source.

[0033] The representative image construction module is used to perform image comparison on m coded images and obtain the representative image based on the comparison results.

[0034] The first preprocessing module is used to perform a first preprocessing on the identified representative image to obtain a first preprocessed image;

[0035] The edge detection module is used to extract edges from the first preprocessed image using an edge detection algorithm to obtain an edge image;

[0036] The second preprocessing module is used to perform a second preprocessing on the edge image to obtain a second preprocessed image;

[0037] The decoding module is used to decode the second preprocessed image to obtain the information recorded in the code.

[0038] The beneficial effects of this invention are as follows:

[0039] This invention proposes a scanning method and apparatus based on multi-color light source comparison. It uses pre-set multi-color light sources to illuminate and acquire a total of m images containing the code, ensuring that at least one image is acquired under each color light source. Then, through image processing, the code contribution regions of each of these m images are extracted to form a representative recognition image. This ensures that the final representative recognition image contains all the code information. Finally, decoding is performed using a combined edge detection and QR code correction method to obtain the information recorded within the code, significantly improving the success rate and accuracy of code recognition. Attached Figure Description

[0040] The above and other features of this disclosure will become more apparent from the detailed description of the embodiments illustrated in conjunction with the accompanying drawings. In the accompanying drawings, the same reference numerals denote the same or similar elements. Obviously, the drawings described below are merely some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort. In the drawings:

[0041] Figure 1 The flowchart shown is a barcode scanning method based on multi-color light source comparison according to the present invention. Detailed Implementation

[0042] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. The same reference numerals used throughout the accompanying drawings indicate the same or similar parts.

[0043] Example 1, referring to Figure 1 This invention proposes a barcode scanning method based on multi-color light source comparison, comprising the following:

[0044] Step 110: Illuminate the image with a pre-set multi-color light source and obtain a total of m images containing codes, ensuring that at least one image is obtained under each color light source.

[0045] Step 120: Perform image comparison on m images containing codes and obtain the representative image based on the comparison results;

[0046] Step 130: Perform a first preprocessing on the identified representative image to obtain a first preprocessed image;

[0047] Step 140: Extract the edges from the first preprocessed image using an edge detection algorithm to obtain an edge image;

[0048] Step 150: Perform a second preprocessing on the edge image to obtain a second preprocessed image;

[0049] Step 160: Decode the second preprocessed image to obtain the information recorded in the code.

[0050] In this embodiment 1, m code-containing images are obtained by illuminating the images with a pre-set multi-color light source, ensuring that at least one image is obtained under each color light source. Then, the image contribution region of each code-containing image is extracted from these m code-containing images through image processing to form a recognition representative image. This can make the final recognition representative image contain all the code information as much as possible. Then, the information recorded in the code is obtained by decoding using a combined edge detection and QR code correction processing method, which can greatly improve the success rate and accuracy of code recognition.

[0051] In a preferred embodiment of the present invention, specifically, image comparison is performed on m coded images, and a representative image is obtained based on the comparison results, including:

[0052] For any image containing a code, calculate the image code contribution rate of its pixels. The formula for calculating the image code contribution rate is as follows:

[0053]

[0054] Here, the image matrix of the i-th coded image is defined as Ri(i), the pixel value of the pixel in the li-th row and hi-th column of Ri(i) is Ri(i, li, hi), the corresponding devote(i, li, hi) is the image-code contribution rate of the pixel in the li-th row and hi-th column of Ri(i), and max(i, li, hi), avg(i, li, hi) and min(i, li, hi) are the maximum, average and minimum values ​​of the 8 neighboring pixels of Ri(i, li, hi), respectively.

[0055] The corresponding code contribution region of the image is marked based on the code contribution rate;

[0056] Calculate the average pixel value of all pixels in m coded images, and use the average pixel value of all pixels to form a base image;

[0057] The corresponding pixel positions in the base image are replaced with the corresponding pixel positions in all the image contribution areas to obtain the recognition representative image.

[0058] In a preferred embodiment of the present invention, specifically, the image code contribution region corresponding to the code-containing image is marked based on the image code contribution rate, including,

[0059] For the first image containing the code, i.e., i=1, traverse the image matrix R1(1) of the first image containing the code, select the two pixels with the largest value of the code contribution rate, connect the two pixels to obtain the line segment Zxd(1), select the pixel with the largest value of the code contribution rate other than the line segment Zxd(1) in R1(1), connect the two endpoints of the line segment Zxd(1) to the pixel with the largest value of the code contribution rate other than the line segment Zxd(1), and the connected area is the code contribution area corresponding to the first image containing the code.

[0060] For images other than the first coded image (i.e., i>1), obtain the average pixel value avg(i-1) of the coded contribution region of Ri-1(i-1). Iterate through Ri(i) and randomly select two pixels whose coded contribution rate is not lower than avg(i-1). Connect these two pixels to obtain line segment Zxd(i). In Ri(i), select the pixel with the largest coded contribution rate other than line segment Zxd(i). Connect the two endpoints of line segment Zxd(i) to the pixel with the largest coded contribution rate other than line segment Zxd(i). The connected region is the coded contribution region corresponding to the current coded image.

[0061] In this preferred embodiment, considering the problem that insufficient illumination may still be encountered when using a monochromatic light source, which may lead to the loss of important information in the image code region, the image code is illuminated with a multi-color light source and at least one image is obtained in each color light source. Then, the image code contributing regions that may involve important information are found from these images, and these regions are replaced in the basic image. This is done to make the final recognition representative image contain all the image code information as much as possible, so as to improve the subsequent recognition results.

[0062] In a preferred embodiment of the present invention, specifically, the identification representative image is subjected to a first preprocessing to obtain a first preprocessed image, including:

[0063] The representative image for identification is converted to grayscale and denoised to obtain a first preprocessed image, thereby improving the accuracy of subsequent identification.

[0064] In a preferred embodiment of the present invention, an edge image is obtained by using an edge detection algorithm based on the Canny operator to extract the edges of the first preprocessed image.

[0065] In this preferred embodiment, considering the following advantages of the Canny operator,

[0066] 1. Low error rate: The Canny operator can detect almost all existing edges while minimizing false detections. 2. Precise localization: The Canny operator provides precise edge location information. The algorithm uses non-maximum suppression to ensure only true edge points are detected, eliminating blurred edges. 3. Robustness to noise: The Canny operator uses a Gaussian filter to eliminate noise, thus better preserving the detection of true edges in noisy images. 4. Single response: The Canny operator ensures that each edge has only one response point, avoiding the duplication of multiple detection points. 5. Multiple threshold options: The Canny operator provides multiple threshold options, allowing adjustment of different thresholds to balance the sensitivity and accuracy of edge detection. In summary, the Canny operator's low error rate, precise localization capability, and robustness to noise make it a commonly used edge detection algorithm in image processing. Therefore, an edge detection algorithm based on the Canny operator is used to extract edges from the first preprocessed image to obtain an edge image.

[0067] In a preferred embodiment of the present invention, specifically, the edge image is subjected to a second preprocessing to obtain a second preprocessed image, including:

[0068] The position and orientation of the QR code are determined based on the pre-set positioning marks on the edge image;

[0069] The QR code image is then corrected using a perspective transformation algorithm to obtain the second preprocessed image.

[0070] In this preferred embodiment, the position and orientation of the QR code are determined by finding a positioning pattern in the image based on the characteristics of the QR code. A perspective transformation algorithm is then used to correct the QR code image, transforming it into a square or rectangle.

[0071] In a preferred embodiment of the present invention, specifically, the QR code image is corrected using a perspective transformation algorithm, including...

[0072] The corner points of the QR code are found using a corner detection algorithm, and then perspective transformation is performed using these corner points.

[0073] In this preferred embodiment, the corner positions of the QR code are detected by a corner detection algorithm (such as the Harris corner detection algorithm, the Shi-Tomasi corner detection algorithm, etc.), and then perspective transformation is performed using these corners.

[0074] The present invention also proposes a barcode scanning device based on multi-color light source comparison, comprising:

[0075] The data acquisition module is used to illuminate the image with a pre-set multi-color light source and acquire a total of m images containing codes, ensuring that at least one image is acquired under each color light source.

[0076] The representative image construction module is used to perform image comparison on m coded images and obtain the representative image based on the comparison results.

[0077] The first preprocessing module is used to perform a first preprocessing on the identified representative image to obtain a first preprocessed image;

[0078] The edge detection module is used to extract edges from the first preprocessed image using an edge detection algorithm to obtain an edge image;

[0079] The second preprocessing module is used to perform a second preprocessing on the edge image to obtain a second preprocessed image;

[0080] The decoding module is used to decode the second preprocessed image to obtain the information recorded in the code.

[0081] In this embodiment 2, a hardware device corresponding to the barcode scanning method based on multi-color light source comparison of the present invention is proposed, which can achieve the same beneficial effects as the barcode scanning method based on multi-color light source comparison of the present invention during operation.

[0082] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0083] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention 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 system capable of carrying the 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.

[0084] Although the description of the invention has been quite detailed and particularly of several described embodiments, it is not intended to limit it to any of these details or embodiments or any particular embodiment, but should be considered as providing a broad possible interpretation of the claims by referring to the appended claims and taking into account the prior art, thereby effectively covering the intended scope of the invention. Furthermore, the invention has been described above with respect to embodiments foreseeable by the inventors in order to provide a useful description, and non-substantial modifications to the invention that have not yet been foreseen may still represent equivalent modifications.

[0085] The above description is merely a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. Any embodiment that achieves the technical effects of the present invention using the same means should fall within the protection scope of the present invention. Within the protection scope of the present invention, various modifications and variations can be made to the technical solutions and / or implementation methods.

Claims

1. A barcode scanning method based on multi-color light source comparison, characterized in that, Including the following: The images are illuminated by a pre-set multi-color light source and a total of m coded images are obtained, ensuring that at least one image is obtained under each color light source. Image comparison is performed on m images containing codes, and a representative image for identification is obtained based on the comparison results; The first preprocessing is performed on the identified representative image to obtain the first preprocessed image; An edge image is obtained by performing edge extraction on the first preprocessed image using an edge detection algorithm; The edge image is subjected to a second preprocessing to obtain a second preprocessed image; Decode the second preprocessed image to obtain the information recorded in the code; Specifically, image comparison is performed on m coded images, and representative images are obtained based on the comparison results, including: For any image containing a code, calculate the image code contribution rate of its pixels. The formula for calculating the image code contribution rate is as follows: ; Here, the image matrix of the i-th coded image is defined as Ri(i), and the pixel value of the pixel in the li-th row and hi-th column of Ri(i) is Ri(i, li, hi), and the corresponding... Let be the image code contribution rate of the pixel in the li-th row and hi-th column of Ri(i), and max(i, li, hi), avg(i, li, hi) and min(i, li, hi) be the maximum, average and minimum values ​​of the 8 neighboring pixels of Ri(i, li, hi), respectively. The corresponding code contribution region of the image is marked based on the code contribution rate; Calculate the average pixel value of all pixels in m coded images, and use the average pixel value of all pixels to form a base image; The corresponding pixel positions in the base image are replaced with the pixel positions corresponding to all the image code contribution areas to obtain the recognition representative image; Specifically, the image-code contribution region of the corresponding coded image is marked based on the image-code contribution rate, including, For the first image containing the code, i.e. i=1, traverse the image matrix R1(1) of the first image containing the code, select the two pixels with the largest value of the code contribution rate, connect the two pixels to obtain the line segment Zxd(1), select the pixel with the largest value of the code contribution rate other than the line segment Zxd(1) in R1(1), connect the two endpoints of the line segment Zxd(1) to the pixel with the largest value of the code contribution rate other than the line segment Zxd(1), and the connected area is the code contribution area corresponding to the first image containing the code. For images other than the first coded image (i.e., i>1), obtain the average pixel value avg(i-1) of the coded contribution region of Ri-1(i-1). Iterate through Ri(i) and randomly select two pixels whose coded contribution rate is not less than avg(i-1). Connect these two pixels to obtain line segment Zxd(i). In Ri(i), select the pixel with the largest coded contribution rate other than line segment Zxd(i). Connect the two endpoints of line segment Zxd(i) to the pixel with the largest coded contribution rate other than line segment Zxd(i). The connected region is the coded contribution region corresponding to the current coded image.

2. The barcode scanning method based on multi-color light source comparison according to claim 1, characterized in that, Specifically, the representative image to be identified undergoes a first preprocessing step to obtain a first preprocessed image, including: The representative image for identification is converted to grayscale and denoised to obtain a first preprocessed image, thereby improving the accuracy of subsequent identification.

3. The barcode scanning method based on multi-color light source comparison according to claim 1, characterized in that, Specifically, an edge image is obtained by performing edge extraction on the first preprocessed image using an edge detection algorithm based on the Canny operator.

4. The barcode scanning method based on multi-color light source comparison according to claim 1, characterized in that, Specifically, the edge image undergoes a second preprocessing step to obtain a second preprocessed image, including: The position and orientation of the QR code are determined based on the pre-set positioning marks on the edge image; The QR code image is then corrected using a perspective transformation algorithm to obtain the second preprocessed image.

5. The barcode scanning method based on multi-color light source comparison according to claim 4, characterized in that, Specifically, the QR code image is corrected using a perspective transformation algorithm, including: The corner points of the QR code are found using a corner detection algorithm, and then perspective transformation is performed using these corner points.

6. A barcode scanning device based on multi-color light source comparison, characterized in that, The apparatus comprising the steps of the method according to any one of claims 1-5, wherein the method is applied, the apparatus includes: The data acquisition module is used to illuminate the image with a pre-set multi-color light source and acquire a total of m images containing codes, ensuring that at least one image is acquired under each color light source. The representative image construction module is used to perform image comparison on m coded images and obtain the representative image based on the comparison results. The first preprocessing module is used to perform a first preprocessing on the identified representative image to obtain a first preprocessed image; The edge detection module is used to extract edges from the first preprocessed image using an edge detection algorithm to obtain an edge image; The second preprocessing module is used to perform a second preprocessing on the edge image to obtain a second preprocessed image; The decoding module is used to decode the second preprocessed image to obtain the information recorded in the code.

Citation Information

Patent Citations

  • Two-dimensional code extraction method and system under uneven illumination

    CN108345816A

  • Code scanning device of three-color light source

    CN217787774U