A two-dimensional code color identification method, system, device and storage medium

By performing erosion and dilation processing on the original QR code image, calculating the white balance coefficient, and calibrating the average values ​​of the red, green, and blue components, the problem of QR code color deviation caused by different mobile phone screens is solved, achieving higher color recognition accuracy.

CN116681926BActive Publication Date: 2026-06-26EEASY TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
EEASY TECH CO LTD
Filing Date
2023-05-17
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Because different mobile phone screens have different materials, color temperatures, and brightness, the colors of the QR code images captured by the image sensors deviate from the actual colors, resulting in a decrease in the accuracy of QR code color judgment.

Method used

By acquiring the original image of the QR code, erosion and dilation processes are performed to determine the bright and dark areas. First and second white balance coefficients are calculated, and these coefficients are used to calibrate the mean values ​​of the red, green, and blue components in the bright areas to obtain the true pixel values. Finally, the QR code is classified based on the true pixel values.

Benefits of technology

It improves the accuracy of QR code color recognition, mitigates color distortion issues caused by different mobile phone screens, and enhances the accuracy of electronic sentinels in recognizing QR code colors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116681926B_ABST
    Figure CN116681926B_ABST
Patent Text Reader

Abstract

The application discloses a two-dimensional code color identification method, system and device and a storage medium. The method comprises the following steps: obtaining an original image of a two-dimensional code; performing corrosion and expansion on the original image to obtain a first bright area and a first dark area; determining a first white balance coefficient and a second white balance coefficient according to the first dark area; calibrating a red component mean value, a green component mean value and a blue component mean value of the original image corresponding to the first bright area by the first white balance coefficient and the second white balance coefficient to obtain a red real pixel value, a green real pixel value and a blue real pixel value; and classifying the two-dimensional code according to the red real pixel value, the green real pixel value and the blue real pixel value. The method can improve the accuracy of two-dimensional code color identification. The application can be widely applied in the technical field of two-dimensional code identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of QR code recognition technology, and in particular to a QR code color recognition method, system, device and storage medium. Background Technology

[0002] In current technology, there are many types of mobile phones. Due to differences in screen materials, color temperatures, and brightness, the color of the QR code image captured by the image sensor may deviate from the actual QR code color. For example, in the phone's eye protection mode, a green QR code may appear yellowish. In this case, the white balance of the image signal processor (ISP) is insufficient to reproduce the true color of the QR code, thus affecting the electronic sensor's judgment of the QR code color and reducing the accuracy of QR code color recognition. Therefore, a new QR code color recognition method is urgently needed. Summary of the Invention

[0003] The purpose of this application is to at least partially solve one of the technical problems existing in the prior art.

[0004] Therefore, one objective of this application is to provide a QR code color recognition method, system, device, and storage medium, which can improve the accuracy of QR code color recognition.

[0005] To achieve the above-mentioned technical objectives, the technical solution adopted in this application includes: a QR code color recognition method, comprising the following steps:

[0006] The process involves: acquiring the original image of the QR code; performing erosion and dilation on the original image to obtain a first bright area and a first dark area; determining a first white balance coefficient and a second white balance coefficient based on the first dark area; calibrating the mean values ​​of the red, green, and blue components of the original image corresponding to the first bright area using the first and second white balance coefficients to obtain true red pixel values, true green pixel values, and true blue pixel values; and classifying the QR code based on the true red pixel values, the true green pixel values, and the true blue pixel values.

[0007] In addition, the QR code color recognition method according to the above embodiments of the present invention may also have the following additional technical features:

[0008] Furthermore, in this embodiment of the application, the step of determining the first white balance coefficient and the second white balance coefficient based on the first dark area specifically includes: calculating the mean values ​​of the red original component, the blue original component, and the green original component of the original image corresponding to the first dark area; determining the first white balance coefficient based on the blue original component and the green original component; and determining the second white balance coefficient based on the red original component and the green original component.

[0009] Further, in this embodiment of the application, the step of calibrating the mean values ​​of the red, green, and blue components of the original image corresponding to the first bright area using the first white balance coefficient and the second white balance coefficient to obtain the true red pixel value, the true green pixel value, and the true blue pixel value specifically includes: calculating the mean values ​​of the red, green, and blue components of the original image corresponding to the first bright area; calibrating the mean value of the blue component using the first white balance coefficient to determine the true blue pixel value; calibrating the mean value of the red component using the second white balance coefficient to determine the true red pixel value; and using the mean value of the green component as the true green pixel value.

[0010] Furthermore, in this embodiment of the application, the step of classifying the QR code based on the red true pixel value, the green true pixel value, and the blue true pixel value specifically includes: determining that the input QR code is a valid QR code based on the red true pixel value, the green true pixel value, and the blue true pixel value; the valid QR code must satisfy the following conditions: Max = G and Dist ≥ T. d and Max≥T m Or Max = R and Dist ≥ T d andMax≥T m , or Dist gb ≤α1·Dist and Dist≥T d and Max≥T m Where G is the true green pixel value, B is the true blue pixel value, R is the true red pixel value, Max represents the maximum value in BGR, and Dist represents the absolute value of the difference between the maximum and minimum values ​​in BGR. gb The value of T represents the absolute value of the difference between G and B, where α1 and α2 are condition coefficients. d and T m The threshold is used as a condition. The valid QR codes are classified based on the true red pixel value, the true green pixel value, and the true blue pixel value.

[0011] Further, in the embodiment of the present application, the step of classifying the valid two-dimensional code according to the red true pixel value, the green true pixel value, and the blue true pixel value specifically includes:

[0012] If the red true pixel value and the green true value satisfy the first condition or the second condition, then determine that the two-dimensional code is a yellow two-dimensional code; where the first condition is G>Mid and R<Mid, and the second condition is R>Mid and Dist gb >α2·Dist; if the red true value, the green true pixel value, and the blue true pixel value satisfy the third condition, then determine that the two-dimensional code is a red two-dimensional code, where the third condition is R>Mid and Dist gb ≤α2·Dist; if the red true value, the green true pixel value, and the blue true pixel value satisfy the fourth condition, then determine that the two-dimensional code is a green two-dimensional code. The fourth condition is R≤Mid and G>Mid; where, Dist represents the absolute value of the difference between the maximum value and the minimum value in BGR, and Dist gb represents the absolute value of the difference between G and B, G is the green true pixel value, R is the red true pixel value, B is the blue true pixel value, and Mid represents the median of the maximum value and the minimum value in BGR.

[0013] Further, in the embodiment of the present application, the step of determining the first white balance coefficient according to the blue original component and the green original component specifically includes: performing a ratio operation on the green original component and the blue original component; determining the ratio of the green original component to the blue original component as the first white balance coefficient.

[0014] Further, in the embodiment of the present application, the step of calibrating the blue component mean value through the first white balance coefficient to determine the blue true pixel value specifically includes: performing a multiplication operation on the first white balance coefficient and the blue component mean value; using the product of the first white balance coefficient and the blue component mean value as the blue true pixel value.

[0015] On the other hand, the embodiment of the present application further provides a two-dimensional code color recognition system, including:

[0016] An acquisition unit, configured to acquire the original image of the two-dimensional code;

[0017] A first processing unit, configured to erode and dilate the original image to obtain a first bright region and a first dark region;

[0018] The second processing unit is used to calibrate the mean red component, mean green component, and mean blue component of the original image corresponding to the first bright area using the first white balance coefficient and the second white balance coefficient, so as to obtain the true red pixel value, the true green pixel value, and the true blue pixel value.

[0019] A classification unit is used to classify the QR code based on the red true pixel value, the green true pixel value, and the blue true pixel value.

[0020] On the other hand, this application also provides a QR code color recognition device, including:

[0021] At least one processor;

[0022] At least one memory for storing at least one program;

[0023] When the at least one program is executed by the at least one processor, the at least one processor implements a QR code color recognition method as described in any one of the inventions.

[0024] In addition, this application also provides a storage medium storing processor-executable instructions, which, when executed by a processor, are used to perform a QR code color recognition method as described in any of the preceding claims.

[0025] The advantages and beneficial effects of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application:

[0026] This application can perform erosion and dilation on the original QR code image, first determining the bright and dark areas; based on the dark areas, determining the first and second white balance coefficients; using the first and second white balance coefficients, calibrating the mean values ​​of the red, green, and blue components of the original image corresponding to the bright areas, thus obtaining the true red, green, and blue pixel values; finally, classifying the QR code based on the true red, green, and blue pixel values. By distinguishing between bright and dark areas, this application only calibrates the pixel values ​​of the original image corresponding to the bright areas during calibration, thereby improving the accuracy of QR code color recognition. Attached Figure Description

[0027] Figure 1 This is a schematic diagram illustrating the steps of a QR code color recognition method in a specific embodiment of the present invention;

[0028] Figure 2 This is a flowchart of a color recognition algorithm in a specific embodiment of the present invention;

[0029] Figure 3 This is a schematic diagram of the structure of a QR code color recognition system in a specific embodiment of the present invention;

[0030] Figure 4 This is a schematic diagram of the structure of a QR code color recognition device in a specific embodiment of the present invention. Detailed Implementation

[0031] The principles and processes of the QR code color recognition method, system, device, and storage medium in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0032] Reference Figure 1 The present invention provides a QR code color recognition method, comprising the following steps:

[0033] S1. Obtain the original image of the QR code.

[0034] In this embodiment, the original image is obtained by performing global white balance on the captured QR code image through an ISP, then performing adaptive threshold segmentation on the QR code image and locating and extracting the QR code region image. This QR code image can be one or more. This embodiment can acquire the image using a camera or other image acquisition device, and then establish a wired or wireless connection between the image acquisition device and the processor to transmit the image to the processor. Wired connections can include connections between mobile devices and host computers, connections between host computers, and wired connections between other known or future-developed devices and host computers. Wireless connections can include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (UltraWide Band) connections, and other known or future-developed wireless connection methods. The processor can be a host computer, a microcontroller, or other existing or future-developed processors with data processing capabilities.

[0035] S2. The original image is eroded and dilated to obtain a first bright area and a first dark area.

[0036] In this embodiment, the first bright region refers to the bright region of the image after morphological processing, and the first dark region can refer to the dark region of the image after morphological processing. This embodiment can perform morphological processing such as erosion and dilation on the original image to obtain bright and dark regions. The mean values ​​of the red, green, and blue pixel components of the original image region corresponding to the dark region are calculated, and this data is processed to obtain two different white balance coefficients. The mean values ​​of the red, green, and blue pixel components of the original image region corresponding to the bright region are then calculated. Combining these two different white balance coefficients allows for the calibration of the red, green, and blue pixels of the QR code.

[0037] S3. Determine the first white balance coefficient and the second white balance coefficient based on the first dark area.

[0038] In this embodiment, the first white balance coefficient and the second white balance coefficient are two parameters with different meanings. The first white balance coefficient represents the relationship between blue and green pixel values, while the second white balance coefficient represents the relationship between green and red pixel values. The first and second white balance coefficients can be equal or different. After determining the dark area, this embodiment calculates the average values ​​of the red, green, and blue components of the original image within the dark area. Using the formula and the average values ​​of the three components, two different white balance coefficients can be calculated.

[0039] S4. Using the first white balance coefficient and the second white balance coefficient, calibrate the mean red component, mean green component, and mean blue component of the original image corresponding to the first bright area to obtain the true red pixel value, the true green pixel value, and the true blue pixel value.

[0040] In this embodiment, the first bright area may include multiple pixel values, each pixel corresponding to three different average values ​​of the red component, the green component, and the blue component. All pixels in the bright area can be calibrated using the first white balance coefficient and the second white balance coefficient to obtain the true red pixel value, the true green pixel value, and the true blue pixel value corresponding to each pixel.

[0041] S5. Classify the QR code according to the red real pixel value, the green real pixel value and the blue real pixel value.

[0042] In this step, the color classification of the QR code needs to be based on the actual red pixel value, the actual green pixel value, and the actual blue pixel value, as well as a specific classification formula. The classification formula can determine which color each pixel is. Since the color of the QR code is generally presented as a single color, this embodiment can classify the QR code by using the actual red pixel value, the actual green pixel value, and the actual blue pixel value, and finally determine the color of the QR code.

[0043] Furthermore, in some embodiments of this application, the step of determining the first white balance coefficient and the second white balance coefficient based on the first dark area may specifically include:

[0044] S201. Calculate the mean values ​​of the red, blue, and green original components of the original image corresponding to the first dark area.

[0045] S202. Determine the first white balance coefficient based on the original blue component and the original green component;

[0046] S203. Determine the second white balance coefficient based on the original red component and the original green component.

[0047] In this embodiment, by first calculating the average values ​​of the red, green, and blue pixel components of all pixels within the range included in the dark area, a red original component, a green original component, and a blue original component can be obtained. Using the blue and green original components and a specific algorithm, a first white balance coefficient can be obtained. Using the red and green original components, a second white balance coefficient can be obtained.

[0048] Furthermore, in some embodiments of this application, the step of calibrating the mean values ​​of the red, green, and blue components of the original image corresponding to the first bright area using the first white balance coefficient and the second white balance coefficient to obtain the true red pixel value, the true green pixel value, and the true blue pixel value may specifically include:

[0049] S301. Calculate the mean value of the red component, the mean value of the green component, and the mean value of the blue component of the original image corresponding to the first bright region.

[0050] S302. The average value of the blue component is calibrated using the first white balance coefficient to determine the true blue pixel value;

[0051] S303. The average value of the red component is calibrated using the second white balance coefficient to determine the true red pixel value;

[0052] S304. The average value of the green component is used as the true green pixel value.

[0053] In this embodiment, the average values ​​of the red, green, and blue components can be calibrated using a first white balance coefficient and a second white balance coefficient to obtain true blue, green, and red pixel values. Specifically, the blue true pixel value can be calibrated using the average blue component and the first white balance coefficient, while the red true pixel value can be calibrated using the average red component and the second white balance coefficient. Since the white balance coefficient corresponding to the average green component is 1, the calibrated green true pixel value is the same as the original green component average value.

[0054] Furthermore, in some embodiments of this application, the step of classifying the QR code based on the red true pixel value, the green true pixel value, and the blue true pixel value specifically includes:

[0055] S401. Determine that the input QR code is a valid QR code according to the red true pixel value, the green true pixel value, and the blue true pixel value;

[0056] S402. Classify the valid QR code according to the red true pixel value, the green true pixel value, and the blue true pixel value.

[0057] In this embodiment, it is necessary to first determine whether the obtained QR code image is a valid image. A valid QR code needs to meet the following conditions: Max = G and Dist ≥ T d and Max ≥ T m , or Max = R and Dist ≥ T d and Max ≥ T m , or Dist gb ≤ α1·Dist and Dist ≥ T d and Max ≥ T m ; In the above conditions, G is the green true pixel value, B is the blue true pixel value, R is the red true pixel value, Max represents the maximum value in BGR, Dist represents the absolute value of the difference between the maximum value and the minimum value in BGR, Dist gb represents the absolute value of the difference between G and B, α1 and α2 are condition coefficients, T d and T m are condition thresholds. It should be noted that the specific values of α1, α2, T d and T m are not limited here, and relevant personnel can make corresponding adjustments according to specific needs.

[0058] Furthermore, in some embodiments of the present application, the step of classifying the valid QR code according to the red true pixel value, the green true pixel value, and the blue true pixel value may specifically include:

[0059] S501. If the red true pixel value and the green true value meet the first condition or the second condition, determine that the QR code is a yellow QR code; where the first condition is G > Mid and R < Mid, and the second condition is R > Mid and Dist gb > α2·Dist;

[0060] S502. If the red true value, the green true pixel value, and the blue true pixel value meet the third condition, determine that the QR code is a red QR code, where the third condition is R > Mid and Dist gb ≤ α2·Dist;

[0061] S503. If the red true value, the green true pixel value, and the blue true pixel value satisfy the fourth condition, determine that the two-dimensional code is a green two-dimensional code. The fourth condition is R ≤ Mid and G > Mid;

[0062] In this embodiment, after determining the valid two-dimensional code, when the red true pixel value, the blue true pixel value, and the green true pixel value of the valid two-dimensional code satisfy the set first condition G > Mid and R < Mid and the second condition R > Mid and Dist gb > α2·Dist, it can be determined that the color of the two-dimensional code is yellow. When the red true pixel value, the blue true pixel value, and the green true pixel value of the valid two-dimensional code satisfy the set third condition R > Mid and Dist gb ≤ α2·Dist, it can be determined that the color of the two-dimensional code is red. When the red true value, the green true pixel value, and the blue true pixel value satisfy the fourth condition R ≤ Mid and G > Mid, then determine that the two-dimensional code is a green two-dimensional code. In the above first condition, second condition, third condition, and fourth condition, Dist represents the absolute value of the difference between the maximum value and the minimum value in BGR, and Dist gb represents the absolute value of the difference between G and B, G is the green true pixel value, R is the red true pixel value, B is the blue true pixel value, and Mid represents the median of the maximum value and the minimum value in BGR.

[0063] Further, in some embodiments of the present application, the step of determining the first white balance coefficient according to the blue original component and the green original component may specifically include:

[0064] S601. Perform a ratio operation on the green original component and the blue original component;

[0065] S602. Determine the ratio of the green original component to the blue original component as the first white balance coefficient.

[0066] In this embodiment, the ratio operation uses the green original component as the dividend and the blue original component as the divisor, and then the two are divided, and the finally obtained quotient value can be used as the first white balance coefficient. It should be noted that, similarly, by using the green original component as the dividend and the red original component as the divisor, the finally obtained quotient value can be used as the second white balance coefficient. The calculation method of this embodiment can be carried out according to the following formula, and the formula is

[0067] B gain =Mean(G dark ) / Mean(B dark ) (1)

[0068] R gain=Mean(G dark ) / Mean(R dark (2)

[0069] In formulas (1) and (2) above, Mean is the mean statistic, and R is the mean statistic. dark For the red original component of the dark area, G dark For the green original component and B in the dark area dark The original blue component represents the dark area.

[0070] Furthermore, in some embodiments of this application, the step of calibrating the average value of the blue component using the first white balance coefficient to determine the true blue pixel value may specifically include:

[0071] S701. Perform a multiplication operation between the first white balance coefficient and the mean value of the blue component;

[0072] S702, The product of the first white balance coefficient and the average value of the blue component is taken as the true blue pixel value.

[0073] In this embodiment, the first white balance coefficient is multiplied by the mean value of the blue component, and the product is used as the calibrated true blue pixel value. For the true red pixel value, the second white balance coefficient is multiplied by the mean value of the red component to obtain the true red pixel value. For the true green pixel value, the corresponding white balance coefficient is 1, therefore the true green pixel value is the same as the mean value of the green component.

[0074] The QR code color recognition method of this application will be described below with reference to specific embodiments.

[0075] Step 1: Obtain a frame of original QR code image, perform global white balance on the captured original QR code image through ISP, and then perform adaptive threshold segmentation on the QR code image and locate and extract the QR code region image.

[0076] Step 2: Perform morphological operations such as erosion and dilation on the extracted QR code area image to obtain the local white balance coefficient and the BGR three primary color pixel values ​​after white balance calibration, including:

[0077] Step 3-1: Perform erosion and dilation operations on the QR code region image after threshold segmentation to obtain the bright area after erosion and the dark area after dilation.

[0078] Step 3-2: Based on the range of the dark area, calculate the average of the three components (BGR) of the original image to obtain the white balance coefficient B. gain and R gain as follows:

[0079] B gain=Mean(G dark ) / Mean(B dark )

[0080] R gain =Mean(G dark ) / Mean(R dark )

[0081] In the above formula, Mean represents the mean statistic, and R0 dark G dark and B dark These are the pixel values ​​for the dark area.

[0082] Step 3-3: Based on the range of bright areas, calculate the average values ​​of the three BGR components of the original image. Use the white balance coefficient to perform white balance calibration on the BGR to obtain the true BGR three primary color pixel values ​​as follows:

[0083] B = B gain ·Mean(B light )

[0084] G = Mean(G light )

[0085] R = R gain ·Mean(R light )

[0086] In the above formula, R light G light and B light These are the pixel values ​​for the bright areas.

[0087] Step 4: Use a color classification method to classify the BGR pixel values ​​after local white balance calibration to obtain the color classification results.

[0088] Specifically, the classification method defines four classification results: COLOR_RED, COLOR_YELLOW, COLOR_GREEN, and COLOR_ERROR. The first three categories represent red, yellow, and blue, respectively, while the last category indicates that the input code does not belong to any of the three categories: red, yellow, and blue. The QR code color classification method defines six classification conditions, including:

[0089] Condition 1: Max = B and Dist gb >α1·Dist;

[0090] Condition 2: Dist <T d or Max <T m ;

[0091] Condition 3: G>Mid and R <Mid;

[0092] Condition 4: R>Mid;

[0093] Condition 5: Dist gb >α2·Dist;

[0094] Condition 6: G>Mid;

[0095] In conditions 1 to 6, Max represents the maximum value in BGR, and Dist represents the absolute value of the difference between the maximum and minimum values ​​in BGR. gb The value of T represents the absolute value of the difference between G and B, where α1 and α2 are condition coefficients. d and T m The conditional threshold is used, and Mid represents the median of the maximum and minimum values ​​in the BGR.

[0096] Reference Figure 2 Classification algorithms include:

[0097] If condition 1 is met, return COLOR_ERROR, meaning the input image is invalid; otherwise, proceed to condition 2.

[0098] If condition 2 is met, return COLOR_ERROR; otherwise, proceed to condition 3.

[0099] If condition 3 is met, return COLOR_YELLOW and the QR code will be yellow; otherwise, proceed to condition 4.

[0100] If condition 4 is met, then proceed to condition 5;

[0101] If condition 5 is met, return COLOR_YELLOW and the QR code will be yellow; otherwise, return COLOR_RED and the QR code will be red.

[0102] If condition 4 is not met, proceed to condition 6;

[0103] If condition 6 is met, return COLOR_GREEN (the QR code will be green); otherwise, return COLOR_ERROR (the input image is invalid).

[0104] In summary, this application is easy to implement. It can obtain the actual BGR (Browser Recognition Language) pixel values ​​of the QR code based on local white balance calibration. While ensuring the accuracy of the BGR pixel values, it also calculates and judges the QR code color classification result based on the QR code color classification method. This invention can improve the color distortion problem caused by different mobile phone screens on QR codes and enhance the accuracy of electronic sentinels in recognizing QR code colors.

[0105] In addition, refer to Figure 3 ,and Figure 1Corresponding to the method described above, embodiments of this application also provide a QR code color recognition system, including:

[0106] The system comprises an acquisition unit 101, a first processing unit 102, a second processing unit 103, a third processing unit 104, and a classification unit 105. The acquisition unit 101 acquires the original image of the QR code. The first processing unit 102 erodes and dilates the original image to obtain a first bright area and a first dark area. The second processing unit 103 determines a first white balance coefficient and a second white balance coefficient based on the first dark area. The third processing unit 104 calibrates the mean red, green, and blue components of the original image corresponding to the first bright area using the first and second white balance coefficients to obtain true red, true green, and true blue pixel values. The classification unit 105 classifies the QR code based on the true red, true green, and true blue pixel values.

[0107] In some embodiments of this application, the acquisition unit 101, the first processing unit 102, the second processing unit 103, the third processing unit 104, and the classification unit 105 can all be housed in the same host computer. The original image of the QR code is acquired through a module within the host computer, and then processed by a subsequent processor within the host computer. In other embodiments of this application, the acquisition unit 101 can be any module connected to the host computer. The acquired data is transmitted to the host computer via a wired or wireless connection, and processed by a module within the host computer. Furthermore, in some embodiments, the first processing unit 102, the second processing unit 103, the third processing unit 104, and the classification unit 105 are similarly configured; the specific device connection method and device setup are not limited.

[0108] The content of the above-described QR code color recognition method embodiments is applicable to this QR code color recognition system embodiment. The specific functions implemented by this QR code color recognition system embodiment are the same as those of the above-described QR code color recognition method embodiments, and the beneficial effects achieved are also the same as those achieved by the above-described QR code color recognition method embodiments.

[0109] and Figure 1 Corresponding to the method described herein, embodiments of this application also provide a QR code color recognition device, the specific structure of which can be referred to... Figure 4 ,include:

[0110] At least one processor;

[0111] At least one memory for storing at least one program;

[0112] When the at least one program is executed by the at least one processor, the at least one processor implements the QR code color recognition method.

[0113] The content of the above method embodiments is applicable to the device embodiments. The specific functions implemented by the device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0114] and Figure 1 Corresponding to the method described above, this application also provides a storage medium storing processor-executable instructions, which, when executed by a processor, are used to perform the QR code color recognition method.

[0115] The contents of the above-described QR code color recognition method embodiments are all applicable to this storage medium embodiment. The specific functions implemented by this storage medium embodiment are the same as those of the above-described QR code color recognition method embodiments, and the beneficial effects achieved are also the same as those achieved by the above-described QR code color recognition method embodiments.

[0116] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this application are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.

[0117] Furthermore, although this application is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding this application. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional technology for an engineer. Therefore, those skilled in the art can implement the application set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of this application, which is determined by the full scope of the appended claims and their equivalents.

[0118] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several programs to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0119] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequential list of executable programs for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, a program execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can retrieve and execute a program from or in conjunction with such a program execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can mean any means that can contain, store, communicate, propagate, or transmit a program for use by or in conjunction with a program execution system, apparatus, or device.

[0120] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0121] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable program execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0122] In the foregoing description of this specification, the references to terms such as "one embodiment," "another embodiment," or "some embodiments," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0123] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.

[0124] The above is a detailed description of the preferred embodiments of this application, but this application is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.

Claims

1. A method for recognizing the color of a QR code, characterized in that, Includes the following steps: Obtain the original image of the QR code; The original image is eroded and dilated to obtain a first bright region and a first dark region; Based on the first dark area, determine the first white balance coefficient and the second white balance coefficient; By using the first white balance coefficient and the second white balance coefficient, the mean red component, mean green component, and mean blue component of the original image corresponding to the first bright area are calibrated to obtain the true red pixel value, the true green pixel value, and the true blue pixel value. The QR codes are classified based on the red real pixel value, the green real pixel value, and the blue real pixel value; The step of classifying the QR code based on the true red pixel value, the true green pixel value, and the true blue pixel value specifically includes: Based on the red real pixel value, the green real pixel value, and the blue real pixel value, the input QR code is determined to be a valid QR code; The valid QR code must meet the following conditions: and ,or and ,or and ; Where G represents the true green pixel value, B represents the true blue pixel value, and R represents the true red pixel value. This represents the maximum value in BGR. This represents the absolute value of the difference between the maximum and minimum values ​​in BGR. This represents the absolute value of the difference between G and B. Conditional coefficients, and For conditional thresholds; The valid QR codes are classified according to the red real pixel value, the green real pixel value, and the blue real pixel value.

2. The QR code color recognition method according to claim 1, characterized in that, The step of determining the first white balance coefficient and the second white balance coefficient based on the first dark area specifically includes: Calculate the mean values ​​of the original red, original blue, and original green components of the original image corresponding to the first dark region; The first white balance coefficient is determined based on the original blue component and the original green component; The second white balance coefficient is determined based on the original red component and the original green component.

3. The QR code color recognition method according to claim 1, characterized in that, The step of calibrating the mean red component, mean green component, and mean blue component of the original image corresponding to the first bright area using the first white balance coefficient and the second white balance coefficient to obtain the true red pixel value, true green pixel value, and true blue pixel value specifically includes: Calculate the mean values ​​of the red component, the green component, and the blue component of the original image corresponding to the first bright region; The average value of the blue component is calibrated using the first white balance coefficient to determine the true blue pixel value; The average value of the red component is calibrated using the second white balance coefficient to determine the true red pixel value; The average value of the green component is used as the true green pixel value.

4. The QR code color recognition method according to claim 1, characterized in that, The step of classifying the valid QR code based on the red, green, and blue true pixel values ​​specifically includes: If the red true pixel value and the green true pixel value satisfy either the first condition or the second condition, then the QR code is determined to be a yellow QR code; wherein the first condition is... The second condition is and ; If the red real pixel value, the green real pixel value, and the blue real pixel value satisfy the third condition, then the QR code is determined to be a red QR code; wherein the third condition is... and ; If the red true pixel value, the green true pixel value, and the blue true pixel value satisfy the fourth condition, then the QR code is determined to be a green QR code; wherein the fourth condition is... and ; in, This represents the absolute value of the difference between the maximum and minimum values ​​in BGR. This represents the absolute value of the difference between G and B, where G is the true green pixel value, R is the true red pixel value, and B is the true blue pixel value. This represents the median of the maximum and minimum values ​​in BGR. is the condition coefficient.

5. The QR code color recognition method according to claim 2, characterized in that, The step of determining the first white balance coefficient based on the original blue component and the original green component specifically includes: Calculate the ratio between the green original component and the blue original component; The ratio of the green original component to the blue original component is determined as the first white balance coefficient.

6. The QR code color recognition method according to claim 3, characterized in that, The step of calibrating the mean value of the blue component using the first white balance coefficient to determine the true blue pixel value specifically includes: Perform a multiplication operation between the first white balance coefficient and the mean value of the blue component; The product of the first white balance coefficient and the mean value of the blue component is taken as the true blue pixel value.

7. A QR code color recognition system, characterized in that, include: The acquisition unit is used to acquire the original image of the QR code; The first processing unit is used to erode and dilate the original image to obtain a first bright area and a first dark area. The second processing unit is used to determine the first white balance coefficient and the second white balance coefficient based on the first dark area. The third processing unit is used to calibrate the mean red component, mean green component, and mean blue component of the original image corresponding to the first bright area using the first white balance coefficient and the second white balance coefficient, so as to obtain the true red pixel value, the true green pixel value, and the true blue pixel value. A classification unit is used to classify the QR code according to the red real pixel value, the green real pixel value, and the blue real pixel value; Specifically, the classification unit is used for: Based on the red real pixel value, the green real pixel value, and the blue real pixel value, the input QR code is determined to be a valid QR code; The valid QR code must meet the following conditions: and ,or and ,or and ; Where G represents the true green pixel value, B represents the true blue pixel value, and R represents the true red pixel value. This represents the maximum value in BGR. This represents the absolute value of the difference between the maximum and minimum values ​​in BGR. This represents the absolute value of the difference between G and B. Conditional coefficients, and For conditional thresholds; The valid QR codes are classified according to the red real pixel value, the green real pixel value, and the blue real pixel value.

8. A QR code color recognition device, characterized in that... include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements a QR code color recognition method as described in any one of claims 1-6.

9. A storage medium storing processor-executable instructions, characterized in that, The processor-executable instructions, when executed by the processor, are used to perform a QR code color recognition method as described in any one of claims 1-6.