Two-dimensional code image recognition method and device, equipment and storage medium
By using pre-stored QR code positioning templates and image enhancement technology in QR code recognition, the recognition failure problem caused by displacement or blur in manual recognition is solved, and the high accuracy and success rate of QR code images are achieved Identify.
Patent Information
- Application Number
- CN202411182716.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2025-01-10
AI Technical Summary
In the prior art, the process of manually identifying QR code images cannot guarantee the imaging effect, resulting in the failure of QR code recognition, especially the failure of identification caused by displacement or blur.
The pre-stored QR code positioning template is used to determine the QR code location information in the image to be identified, and the clarity of the QR code is improved through at least one image enhancement operation, ultimately improving the recognition accuracy and success rate.
Solve the position offset problem through the QR code positioning template, ensure the high definition of the QR code image, and significantly improve the accuracy and success rate of QR code recognition.
Smart Images

Figure CN119294422A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a method, device, equipment and storage medium for recognizing a two-dimensional code image. Background Art
[0002] During the product production process, a QR code image is usually printed on the back of the product cover. By scanning the QR code image, the configuration and information of the product, such as the serial number, model, brand and other information, can be viewed.
[0003] In the process of identifying a QR code image, the related technology can manually identify the QR code image. However, the process of manually identifying the QR code image cannot guarantee the imaging effect. If the QR code image is displaced or blurred, it will affect the recognition result of the QR code image and even cause the QR code image recognition to fail. Summary of the invention
[0004] In view of this, the present application provides a method and device for recognizing a two-dimensional code image, the main purpose of which is to solve the problem in the prior art that the process of manually recognizing a two-dimensional code image cannot guarantee the imaging effect and even causes the failure of two-dimensional code image recognition.
[0005] According to a first aspect of the present application, a method for recognizing a two-dimensional code image is provided, comprising:
[0006] Determine the position information of the two-dimensional code image in the image to be identified by using a pre-stored two-dimensional code positioning template, wherein the two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic;
[0007] Performing at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image;
[0008] After each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized to obtain a recognition result of the two-dimensional code image.
[0009] Furthermore, before determining the position information of the two-dimensional code graphic in the two-dimensional code image to be identified by using the pre-stored two-dimensional code positioning template, the method further includes:
[0010] According to a standard image including a two-dimensional code graphic, determining an image area of the two-dimensional code graphic in the standard image;
[0011] The image area of the two-dimensional code graphic is processed into the two-dimensional code positioning template.
[0012] Furthermore, the processing of the image area of the two-dimensional code graphic into the two-dimensional code positioning template specifically includes:
[0013] Performing a grayscale closing operation on the image area of the two-dimensional code graphic so as to merge the internal points in the two-dimensional code graphic;
[0014] A preset pattern obtained by fusing the internal points in the two-dimensional code pattern is determined as the two-dimensional code positioning template.
[0015] Furthermore, performing at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image specifically includes:
[0016] Performing a first image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image;
[0017] If the recognition result of the two-dimensional code image fails after the first image enhancement process, a second image enhancement operation is performed on the two-dimensional code image according to the position information of the two-dimensional code image.
[0018] Furthermore, performing a first image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image specifically includes:
[0019] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0020] Calculating a first updated pixel grayscale value according to the grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering;
[0021] A first image enhancement operation is performed on the two-dimensional code image using the set enhancement factor, so that the two-dimensional code image after the first image enhancement operation has a first updated pixel grayscale value.
[0022] Furthermore, performing a second image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image specifically includes:
[0023] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0024] Calculating a second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering;
[0025] Based on the pixel grayscale value of the two-dimensional code image, a second image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image after the second image enhancement operation has a second updated pixel grayscale value.
[0026] Further, the calculating of the second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering specifically includes:
[0027] According to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering, use a preset grayscale formula to perform at least one grayscale enhancement process on the pixel grayscale value of the two-dimensional code image;
[0028] The second updated pixel grayscale value is determined according to the pixel grayscale value of the two-dimensional code image after at least one grayscale enhancement process.
[0029] Furthermore, after each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized to obtain a recognition result of the two-dimensional code image, which specifically includes:
[0030] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0031] Generate a two-dimensional code background image according to the image grayscale mean of the two-dimensional code image after mean filtering, wherein the size of the two-dimensional code background image is consistent with that of the two-dimensional code image;
[0032] After each image enhancement operation, performing a two-dimensional code graphic extraction on the two-dimensional code image after the image enhancement operation according to the two-dimensional code background image to obtain a two-dimensional code image area;
[0033] The two-dimensional code graphic area is identified to obtain a recognition result of the two-dimensional code image.
[0034] Furthermore, after each image enhancement operation, the two-dimensional code image after the image enhancement operation is subjected to two-dimensional code graphic extraction according to the two-dimensional code background image to obtain a two-dimensional code graphic area, specifically including:
[0035] After each image enhancement operation, calculating the grayscale difference between the pixel grayscale value of the two-dimensional code background image and the pixel grayscale value of the two-dimensional code image after the image enhancement operation;
[0036] Pixels whose grayscale difference in the two-dimensional code image after the image enhancement operation is greater than a preset threshold are extracted to obtain the two-dimensional code graphic area.
[0037] Furthermore, after each image enhancement operation, after performing a two-dimensional code graphic extraction on the two-dimensional code image after the image enhancement operation according to the two-dimensional code background image, and obtaining the two-dimensional code graphic area, the method further includes:
[0038] The two-dimensional code graphic area is subjected to noise filtering by at least one image processing operation.
[0039] According to a second aspect of the present application, a device for recognizing a two-dimensional code image is provided, comprising:
[0040] A first determining unit is used to determine the position information of the two-dimensional code image in the image to be identified by using a pre-stored two-dimensional code positioning template, wherein the two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic;
[0041] an enhancement unit, configured to perform at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image;
[0042] The recognition unit is used to recognize the two-dimensional code image after each image enhancement operation to obtain a recognition result of the two-dimensional code image.
[0043] Furthermore, the device also includes:
[0044] A second determining unit is used to determine an image area of the two-dimensional code graphic in the standard image according to the standard image containing the two-dimensional code graphic;
[0045] A processing unit is used to process the image area of the two-dimensional code graphic into the two-dimensional code positioning template.
[0046] Furthermore, the processing unit includes:
[0047] A grayscale closing operation module, used for performing a grayscale closing operation on the image area of the two-dimensional code graphic so as to merge the internal points in the two-dimensional code graphic;
[0048] The determination module is used to determine a preset pattern obtained by fusing the internal points in the two-dimensional code pattern as the two-dimensional code positioning template.
[0049] Furthermore, the enhancement unit comprises:
[0050] A first enhancement module, used for performing a first image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image;
[0051] The second enhancement module is used to perform a second image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image if the recognition result of the two-dimensional code image fails after the first image enhancement processing.
[0052] Furthermore, the first enhancement module is specifically used to:
[0053] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0054] Calculating a first updated pixel grayscale value according to the grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering;
[0055] A first image enhancement operation is performed on the two-dimensional code image using the set enhancement factor, so that the two-dimensional code image after the first image enhancement operation has a first updated pixel grayscale value.
[0056] Furthermore, the second enhancement module is specifically used to:
[0057] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0058] Calculating a second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering;
[0059] Based on the pixel grayscale value of the two-dimensional code image, a second image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image after the second image enhancement operation has a second updated pixel grayscale value.
[0060] Furthermore, the second enhancement module is further configured to:
[0061] According to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering, use a preset grayscale formula to perform at least one grayscale enhancement process on the pixel grayscale value of the two-dimensional code image;
[0062] The second updated pixel grayscale value is determined according to the pixel grayscale value of the two-dimensional code image after at least one grayscale enhancement process.
[0063] Furthermore, the identification unit includes:
[0064] A mean filtering module, used for performing mean filtering processing on the two-dimensional code image according to the position information of the two-dimensional code image;
[0065] A generating module, used to generate a two-dimensional code background image according to the image grayscale mean of the two-dimensional code image after mean filtering, wherein the size of the two-dimensional code background image is consistent with that of the two-dimensional code image;
[0066] A graphics extraction module, used for performing a two-dimensional code graphics extraction on the two-dimensional code image after the image enhancement operation according to the two-dimensional code background image after each image enhancement operation, to obtain a two-dimensional code image area;
[0067] The recognition module is used to recognize the two-dimensional code graphic area and obtain the recognition result of the two-dimensional code image.
[0068] Furthermore, the graphic extraction module is specifically used for:
[0069] After each image enhancement operation, calculating the grayscale difference between the pixel grayscale value of the two-dimensional code background image and the pixel grayscale value of the two-dimensional code image after the image enhancement operation;
[0070] Pixels whose grayscale difference in the two-dimensional code image after the image enhancement operation is greater than a preset threshold are extracted to obtain the two-dimensional code graphic area.
[0071] Furthermore, the identification unit further includes:
[0072] The noise filtering module is used to extract the two-dimensional code graphic from the two-dimensional code image after each image enhancement operation according to the two-dimensional code background image, and after obtaining the two-dimensional code graphic area, perform noise filtering on the two-dimensional code graphic area through at least one image processing operation.
[0073] According to a third aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in the first aspect when executing the computer program.
[0074] According to a fourth aspect of the present application, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0075] By means of the above technical scheme, the present application provides a method, device, equipment and storage medium for identifying a two-dimensional code image. Compared with the current prior art that relies on manual operation to realize the identification of a two-dimensional code image, the present application uses a pre-stored two-dimensional code positioning template to determine the position information of the two-dimensional code image in the image to be identified. The two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic; at least one image enhancement operation is performed on the two-dimensional code image according to the position information of the two-dimensional code image; after each image enhancement operation, the two-dimensional code image after the image enhancement operation is identified to obtain the identification result of the two-dimensional code image. The whole process uses the two-dimensional code positioning template to solve the problem of the position offset of the two-dimensional code image. On the basis of determining the position of the two-dimensional code image, at least one image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image has a higher clarity, and the accuracy and success rate of the two-dimensional code image recognition are improved.
[0076] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0078] Figure 1 It is a flow chart of a method for recognizing a two-dimensional code image provided in an embodiment of the present application;
[0079] Figure 2 is a flow chart of another method for recognizing a two-dimensional code image provided in an embodiment of the present application;
[0080] Figure 3 yes Figure 1 A schematic flow chart of a specific implementation of step 102;
[0081] Figure 4 yes Figure 3 A schematic flow chart of a specific implementation of step 301;
[0082] Figure 5 yes Figure 3 A schematic flow chart of a specific implementation of step 302;
[0083] Figure 6 yes Figure 1 A schematic flow chart of a specific implementation of step 103;
[0084] Figure 7 It is a flowchart of a method for recognizing a two-dimensional code image provided in an embodiment of the present application;
[0085] Figure 8 It is a structural schematic diagram of a two-dimensional code image recognition device provided in an embodiment of the present application;
[0086] Fig. 9 It is a schematic diagram of the device structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0087] Now the content of the present invention will be discussed with reference to several exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and thus implement the content of the present invention, rather than implying any limitation on the scope of the present invention.
[0088] As used herein, the term "including" and variations thereof are to be interpreted as open-ended terms meaning "including but not limited to." The term "based on" is to be interpreted as "based, at least in part, on." The terms "one embodiment" and "an embodiment" are to be interpreted as "at least one embodiment." The term "another embodiment" is to be interpreted as "at least one other embodiment."
[0089] In the process of identifying a QR code image, the related technology can manually identify the QR code image. However, the process of manually identifying the QR code image cannot guarantee the imaging effect. If the QR code image is displaced or blurred, it will affect the recognition result of the QR code image and even cause the QR code image recognition to fail.
[0090] In order to solve this problem, this embodiment provides a method for recognizing a two-dimensional code image. Figure 1 As shown, the method comprises the following steps:
[0091] 101. Determine the position information of the two-dimensional code image in the image to be identified by using a pre-stored two-dimensional code positioning template.
[0092] Among them, the QR code positioning template is obtained by performing regional processing based on a standard image containing a QR code graphic. Here, the standard image can be an image of a fixed size or an image of a fixed graphic position. Specifically, the image area containing the QR code graphic can be framed in the standard image. Considering that the image area of the QR code graphic is the area that needs to be identified, visual enhancement processing can be performed on the image area containing the QR code graphic, and the graphic after visual enhancement processing is used as the QR code positioning template. The visual processing can use grayscale closing operation or a combination of grayscale expansion and erosion operations. It can be understood that the image area after visual processing can change the grayscale value of the image by increasing the pixel value of the image without changing the size of the image itself, which will make the image look clearer and more coherent.
[0093] In this embodiment, the image to be identified is an unknown recognizable QR code image. Usually, the image to be identified is an unrecognizable QR code image. In order to improve the recognition efficiency of the QR code image, the QR code image recognition can be directly performed on the image to be identified before positioning the image to be identified. If the QR code image recognition fails, the QR code image positioning is performed on the image to be identified.
[0094] Specifically, after obtaining the image to be identified, similar to the processing process of the QR code positioning template, the image to be identified is also visually enhanced, and then the image to be identified after the visual enhancement processing is regionally matched with the QR code positioning template through matching to determine the location information of the QR code image.
[0095] 102. Perform at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image.
[0096] It is understandable that the area of the QR code graphic can be directly and accurately obtained through the position information of the QR code image. The area of the QR code graphic is equivalent to the QR code image, and then the QR code image is subjected to at least one image enhancement process.
[0097] In this embodiment, performing at least one enhancement process on the two-dimensional code image may include but is not limited to performing image contrast enhancement, image grayscale stretching enhancement, etc. on the two-dimensional code image. Specifically, each image enhancement process may use an image enhancement factor to change the grayscale value of the two-dimensional code image, and change the clarity of the two-dimensional code image by the changed grayscale value. It should be noted that the image enhancement factor controls the increase in the contrast in the two-dimensional code image and affects the difference between different grayscale levels in the two-dimensional code image. The image enhancement operation can improve the visual effect of the image by taking the value of the image enhancement factor. A larger image enhancement factor will significantly increase the contrast of the two-dimensional code image, making the details in the two-dimensional code image more prominent. However, if the image enhancement factor is too large, it may cause the two-dimensional code image to be over-contrasted or even distorted.
[0098] 103. After each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized to obtain a recognition result of the two-dimensional code image.
[0099] In this embodiment, after each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized, and if the recognition is successful, there is no need to perform the next image enhancement operation on the two-dimensional code image. For example, after the first image enhancement operation, the two-dimensional code image after the first enhancement operation is recognized, and if the recognition is successful, there is no need to perform the second image enhancement operation on the two-dimensional code image, and if the recognition fails, the second image enhancement operation is performed on the two-dimensional code image.
[0100] Compared with the current prior art method of realizing the recognition of two-dimensional code images by manual operation, the recognition method of two-dimensional code images provided by the embodiment of the present application uses a pre-stored two-dimensional code positioning template to determine the position information of the two-dimensional code image in the image to be recognized. The two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic; at least one image enhancement operation is performed on the two-dimensional code image according to the position information of the two-dimensional code image; after each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized to obtain the recognition result of the two-dimensional code image. The whole process uses the two-dimensional code positioning template to solve the position offset problem of the two-dimensional code image. On the basis of determining the position of the two-dimensional code image, at least one image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image has a higher clarity, thereby improving the accuracy and success rate of two-dimensional code image recognition.
[0101] In the above embodiment, the two-dimensional code positioning template is not a template of a two-dimensional code graphic, but a template for positioning the two-dimensional code area in the image to be recognized. For the generation process of the two-dimensional code positioning template, further, as Figure 2 As shown, before the above step 101, the method further includes the following steps:
[0102] 201. According to a standard image including a two-dimensional code graphic, determine an image area of the two-dimensional code graphic in the standard image.
[0103] 202. Process the image area of the two-dimensional code graphic into the two-dimensional code positioning template.
[0104] It can be understood that a standard image containing a QR code graphic is equivalent to a scannable QR code image, that is, a QR code image with an imaging effect. By scanning the standard image, the configuration and information of the corresponding product can be successfully identified.
[0105] Specifically, in the process of processing the image area of the two-dimensional code graphic into a two-dimensional code positioning template, a grayscale closing operation is performed on the image area of the two-dimensional code graphic so that the internal points in the two-dimensional code graphic are merged, and then the preset graphic obtained by merging the internal points in the two-dimensional code graphic is determined as the two-dimensional code positioning template. In this embodiment, since the pixel points in the image area of the two-dimensional code graphic are closely spaced, the image area of the two-dimensional code graphic will be merged into a rectangle after the grayscale closing operation is performed on the image area of the two-dimensional code graphic, and the merged rectangle is used as the two-dimensional code positioning template. Subsequently, the position information of the two-dimensional code image can be determined in the image to be identified through the two-dimensional code positioning template.
[0106] It can be understood that the positioning function of the QR code positioning template takes advantage of the fact that the grayscale of the QR code is different from the background and the distance is relatively close, and uses the grayscale rectangular closing operation to merge the QR code graphics into a rectangle as a rectangular template for subsequent matching. In this way, it is only necessary to perform a grayscale closing operation on the image to be tested and then perform rectangular template matching to accurately locate the position of the QR code image.
[0107] Specifically, Figure 3 As shown, the above step 102 includes the following steps:
[0108] 301. Perform a first image enhancement operation on the two-dimensional code image according to position information of the two-dimensional code image.
[0109] 302. If the recognition result of the two-dimensional code image after the first image enhancement processing fails, perform a second image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image.
[0110] In this embodiment, each image enhancement operation is a process of updating the pixel grayscale value in the two-dimensional code image. Each pixel grayscale value update can be determined based on the average value of the pixel grayscale value in the two-dimensional code image. If the two-dimensional code image recognition fails after the first pixel grayscale value update, the pixel grayscale value of the two-dimensional code image is updated for a second time. The updated pixel grayscale value can greatly improve the recognition accuracy when the image is blurred.
[0111] Specifically, each image enhancement operation can be obtained by calculating the grayscale mean of the two-dimensional code image and the grayscale mean of the filtered two-dimensional code image. For example, the first image enhancement operation is to calculate the updated pixel grayscale value based on the grayscale mean of the two-dimensional code image and the grayscale mean of the filtered two-dimensional code image on the basis of the image enhancement factor. The second image enhancement operation is to multiply the grayscale mean of the two-dimensional code image by itself and divide it by the background mean to calculate the updated pixel grayscale value.
[0112] It can be understood that the image enhancement operation is equivalent to enhancing the useful information in the QR code image. This process is a distortion process, and its purpose is to improve the visual effect of the QR code image. By purposefully emphasizing the overall or local characteristics of the image, the originally unclear QR code image becomes clear or emphasizes certain features of interest, expands the differences between the features of different objects in the QR code image, and suppresses features of no interest, so as to improve the image quality, enrich the amount of information, and enhance the image interpretation and recognition effect.
[0113] For the first image enhancement operation, specifically, Figure 4 As shown, step 301 includes the following steps:
[0114] 401. Perform mean filtering on the two-dimensional code image according to the position information of the two-dimensional code image.
[0115] 402. Calculate a first updated pixel grayscale value according to the grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering.
[0116] 403. Perform a first image enhancement operation on the two-dimensional code image using the set enhancement factor, so that the two-dimensional code image after the first image enhancement operation has a first updated pixel grayscale value.
[0117] In this embodiment, according to the grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering, the first updated pixel grayscale value can be calculated using the following formula:
[0118] new=round((orig-mean)×Factor)+orig
[0119] Among them, new is the first updated pixel grayscale value, round means rounding the result, orig is the grayscale value of the two-dimensional code image, mean is the grayscale value of the two-dimensional code image after mean filtering, and Factor is the set enhancement factor.
[0120] For the second image enhancement operation, specifically, Figure 5As shown, step 302 includes the following steps:
[0121] 501. Perform mean filtering on the two-dimensional code image according to the position information of the two-dimensional code image.
[0122] 502. Calculate a second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering.
[0123] 503. Based on the pixel grayscale value of the two-dimensional code image, perform a second image enhancement operation on the two-dimensional code image, so that the two-dimensional code image after the second image enhancement operation has a second updated pixel grayscale value.
[0124] Specifically, in the process of calculating the second updated pixel grayscale value, the pixel grayscale value of the two-dimensional code image can be grayscale enhanced at least once using a preset grayscale formula according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering, and the second updated pixel grayscale value is determined according to the pixel grayscale value of the two-dimensional code image after at least one grayscale enhancement process. The pixel grayscale value of the two-dimensional code image after at least one grayscale enhancement process has a higher contrast, which is helpful for two-dimensional code recognition.
[0125] In this embodiment, a preset grayscale formula is used to perform a first grayscale enhancement process on the pixel grayscale value of the two-dimensional code image, which can be calculated using the following formula:
[0126] g′=g1*g1*Mult+Add
[0127] Wherein, Mult=1 / mean, mean is the gray value of the two-dimensional code image after mean filtering, g1 is the pixel gray value of the two-dimensional code image, and Add is the compensation value, which is usually set to 0.
[0128] In this embodiment, a preset grayscale formula is used to perform a second grayscale enhancement process on the pixel grayscale value of the two-dimensional code image, which can be calculated using the following formula:
[0129] g″=g′*g′*Mult+Add
[0130] Wherein, Mult=1 / mean, mean is the gray value of the two-dimensional code image after mean filtering, g′ is the pixel gray value of the two-dimensional code image after the first gray enhancement processing, and Add is the compensation value, which is usually set to 0.
[0131] It should be noted that after each image enhancement operation, in order to further improve the recognition effect of the two-dimensional code image, the background segmentation of the two-dimensional code image after the image enhancement operation may be performed before the two-dimensional code image after the image enhancement operation is recognized. Specifically, Figure 6 As shown, step 103 includes the following steps:
[0132] 601. Perform mean filtering on the two-dimensional code image according to the position information of the two-dimensional code image.
[0133] 602. Generate a two-dimensional code background image according to the image grayscale mean of the two-dimensional code image after the mean filtering process.
[0134] 603. After each image enhancement operation, perform a two-dimensional code graphic extraction on the two-dimensional code image after the image enhancement operation according to the two-dimensional code background image to obtain a two-dimensional code image region.
[0135] 604. Identify the two-dimensional code graphic area to obtain a recognition result of the two-dimensional code image.
[0136] Among them, the size of the QR code background image is consistent with that of the QR code image. In the specific process of QR code graphic extraction, after each image enhancement operation, the grayscale difference between the pixel grayscale value of the QR code background image and the pixel grayscale value of the QR code image after the image enhancement operation can be calculated, and the pixel points in the QR code image after the image enhancement operation whose grayscale difference is greater than a preset threshold are extracted to obtain the QR code graphic area.
[0137] During the generation and printing process of the two-dimensional code image, some noise or impurities may appear in the two-dimensional code due to factors such as the accuracy of the printing equipment and the quality of the paper. These noises will affect the recognition rate of the two-dimensional code. In order to more accurately identify the two-dimensional code image, after extracting the two-dimensional code graphic area, the embodiment of the present invention performs noise filtering on the two-dimensional code graphic area through at least one image processing operation. Here, the image processing operation can be implemented through morphological operations. For example, an erosion operation is used to eliminate edges and noises. Specifically, the erosion operation can shrink the two-dimensional code image area, thereby helping to remove noise and noises in the two-dimensional code image.
[0138] As Figure 1-Figure 6 The specific implementation of the method, in the actual application scenario, the embodiment of the present application provides a two-dimensional code image recognition process flow chart, such as Figure 7As shown, after the image to be recognized is input, the QR code image area is selected using the pre-stored QR code positioning template frame, and then after the first image enhancement operation is performed on the QR code image, the QR code image after the first image enhancement operation is recognized, and it is determined whether the QR code image after the first image enhancement is recognized successfully. If so, the recognition result of the QR code image is obtained, and the recognition and process are terminated. If not, the QR code image is subjected to a second image enhancement operation, and the QR code image after the second image enhancement operation is recognized, and it is determined whether the QR code image after the second image enhancement is recognized successfully. If so, the recognition result of the QR code image is obtained, and the recognition and process are terminated. If not, the recognition process is terminated.
[0139] Further, as Figure 1-Figure 6 The specific implementation of the method, the embodiment of the present application provides a two-dimensional code image recognition device, such as Figure 8 As shown, the device includes: a first determination unit 71, an enhancement unit 72, and an identification unit 73.
[0140] A first determining unit 71 is used to determine the position information of the two-dimensional code image in the image to be identified by using a pre-stored two-dimensional code positioning template, wherein the two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic;
[0141] An enhancement unit 72, configured to perform at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image;
[0142] The recognition unit 73 is used to recognize the two-dimensional code image after each image enhancement operation to obtain a recognition result of the two-dimensional code image.
[0143] Compared with the current prior art method of realizing the recognition of the two-dimensional code image by manual operation, the two-dimensional code image recognition device provided by the embodiment of the present invention uses a pre-stored two-dimensional code positioning template to determine the position information of the two-dimensional code image in the image to be recognized. The two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic; at least one image enhancement operation is performed on the two-dimensional code image according to the position information of the two-dimensional code image; after each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized to obtain the recognition result of the two-dimensional code image. The whole process uses the two-dimensional code positioning template to solve the position offset problem of the two-dimensional code image. On the basis of determining the position of the two-dimensional code image, at least one image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image has a higher clarity, thereby improving the accuracy and success rate of the two-dimensional code image recognition.
[0144] In an actual application scenario, the device further includes:
[0145] A second determining unit is used to determine an image area of the two-dimensional code graphic in the standard image according to the standard image containing the two-dimensional code graphic;
[0146] A processing unit is used to process the image area of the two-dimensional code graphic into the two-dimensional code positioning template.
[0147] In an actual application scenario, the processing unit includes:
[0148] A grayscale closing operation module, used for performing a grayscale closing operation on the image area of the two-dimensional code graphic so as to merge the internal points in the two-dimensional code graphic;
[0149] The determination module is used to determine a preset pattern obtained by fusing the internal points in the two-dimensional code pattern as the two-dimensional code positioning template.
[0150] In an actual application scenario, the enhancement unit includes:
[0151] A first enhancement module, configured to perform a first image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image;
[0152] The second enhancement module is used to perform a second image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image if the recognition result of the two-dimensional code image fails after the first image enhancement processing.
[0153] In an actual application scenario, the first enhancement module is specifically used to:
[0154] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0155] Calculating a first updated pixel grayscale value according to the grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering;
[0156] A first image enhancement operation is performed on the two-dimensional code image using the set enhancement factor, so that the two-dimensional code image after the first image enhancement operation has a first updated pixel grayscale value.
[0157] In an actual application scenario, the second enhancement module is specifically used to:
[0158] According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image;
[0159] Calculating a second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering;
[0160] Based on the pixel grayscale value of the two-dimensional code image, a second image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image after the second image enhancement operation has a second updated pixel grayscale value.
[0161] In an actual application scenario, the second enhancement module is further used to:
[0162] According to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering, use a preset grayscale formula to perform at least one grayscale enhancement process on the pixel grayscale value of the two-dimensional code image;
[0163] The second updated pixel grayscale value is determined according to the pixel grayscale value of the two-dimensional code image after at least one grayscale enhancement process.
[0164] In an actual application scenario, the identification unit includes:
[0165] A mean filtering module, used for performing mean filtering processing on the two-dimensional code image according to the position information of the two-dimensional code image;
[0166] A generating module, used to generate a two-dimensional code background image according to the image grayscale mean of the two-dimensional code image after mean filtering, wherein the size of the two-dimensional code background image is consistent with that of the two-dimensional code image;
[0167] A graphics extraction module, used for performing a two-dimensional code graphics extraction on the two-dimensional code image after the image enhancement operation according to the two-dimensional code background image after each image enhancement operation, to obtain a two-dimensional code image area;
[0168] The recognition module is used to recognize the two-dimensional code graphic area and obtain the recognition result of the two-dimensional code image.
[0169] In actual application scenarios, the graphics extraction module is specifically used to:
[0170] After each image enhancement operation, calculating the grayscale difference between the pixel grayscale value of the two-dimensional code background image and the pixel grayscale value of the two-dimensional code image after the image enhancement operation;
[0171] Pixels whose grayscale difference in the two-dimensional code image after the image enhancement operation is greater than a preset threshold are extracted to obtain the two-dimensional code graphic area.
[0172] In an actual application scenario, the identification unit further includes:
[0173] The noise filtering module is used to extract the two-dimensional code graphic from the two-dimensional code image after each image enhancement operation according to the two-dimensional code background image, and after obtaining the two-dimensional code graphic area, perform noise filtering on the two-dimensional code graphic area through at least one image processing operation.
[0174] It should be noted that for other corresponding descriptions of the functional units involved in the two-dimensional code image recognition device provided in this embodiment, please refer to Figure 1-Figure 6 The corresponding description in will not be repeated here.
[0175] Based on the above Figure 1-Figure 6 The method shown in the embodiment of the present application accordingly provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned Figure 1-Figure 6 The recognition method of the two-dimensional code image shown.
[0176] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0177] Based on the above Figure 1-Figure 6 The method shown, and Figure 8 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides a physical device for recognizing a two-dimensional code image, which can be a computer, a smart phone, a tablet computer, a smart watch, a server, or a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1-Figure 6 The recognition method of the two-dimensional code image shown.
[0178] Optionally, the physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0179] In an exemplary embodiment, see Fig. 9The physical device includes a communication bus, a processor, a memory and a communication interface, and may also include an input / output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the two-dimensional code image recognition method in the above embodiment.
[0180] Those skilled in the art will appreciate that the physical device structure for recognizing a two-dimensional code image provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0181] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device for the recognition and processing of the two-dimensional code image, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0182] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the technical solution of the present application, compared with the current existing methods, the present application uses a two-dimensional code positioning template to solve the position offset problem of the two-dimensional code image. On the basis of determining the position of the two-dimensional code image, at least one image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image has a higher definition, thereby improving the accuracy and success rate of two-dimensional code image recognition.
[0183] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0184] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A method for recognizing a two-dimensional code image, characterized in that: include: Determine the position information of the two-dimensional code image in the image to be identified by using a pre-stored two-dimensional code positioning template, wherein the two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic; Performing at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image; After each image enhancement operation, the two-dimensional code image after the image enhancement operation is recognized to obtain a recognition result of the two-dimensional code image.
2. The method according to claim 1, characterized in that Before determining the position information of the two-dimensional code graphic in the two-dimensional code image to be identified by using the pre-stored two-dimensional code positioning template, the method further includes: According to a standard image including a two-dimensional code graphic, determining an image area of the two-dimensional code graphic in the standard image; The image area of the two-dimensional code graphic is processed into the two-dimensional code positioning template.
3. The method according to claim 2, characterized in that The processing of the image area of the two-dimensional code graphic into the two-dimensional code positioning template specifically includes: Performing a grayscale closing operation on the image area of the two-dimensional code graphic so as to merge the internal points in the two-dimensional code graphic; A preset pattern obtained by fusing the internal points in the two-dimensional code pattern is determined as the two-dimensional code positioning template.
4. The method according to claim 1, characterized in that The performing at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image specifically includes: Performing a first image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image; If the recognition result of the two-dimensional code image fails after the first image enhancement process, a second image enhancement operation is performed on the two-dimensional code image according to the position information of the two-dimensional code image.
5. The method according to claim 4, characterized in that The performing a first image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image specifically includes: According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image; Calculating a first updated pixel grayscale value according to the grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering; A first image enhancement operation is performed on the two-dimensional code image using the set enhancement factor, so that the two-dimensional code image after the first image enhancement operation has a first updated pixel grayscale value.
6. The method according to claim 4, characterized in that The performing a second image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image specifically includes: According to the position information of the two-dimensional code image, performing mean filtering processing on the two-dimensional code image; Calculating a second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering; Based on the pixel grayscale value of the two-dimensional code image, a second image enhancement operation is performed on the two-dimensional code image, so that the two-dimensional code image after the second image enhancement operation has a second updated pixel grayscale value.
7. The method according to claim 6, characterized in that The step of calculating the second updated pixel grayscale value according to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering processing specifically includes: According to the pixel grayscale value of the two-dimensional code image and the grayscale value of the two-dimensional code image after mean filtering, use a preset grayscale formula to perform at least one grayscale enhancement process on the pixel grayscale value of the two-dimensional code image; The second updated pixel grayscale value is determined according to the pixel grayscale value of the two-dimensional code image after at least one grayscale enhancement process.
8. A device for recognizing a two-dimensional code image, characterized in that: include: A first determining unit is used to determine the position information of the two-dimensional code image in the image to be identified by using a pre-stored two-dimensional code positioning template, wherein the two-dimensional code positioning template is obtained by performing regional processing on a standard image containing a two-dimensional code graphic; an enhancement unit, configured to perform at least one image enhancement operation on the two-dimensional code image according to the position information of the two-dimensional code image; The recognition unit is used to recognize the two-dimensional code image after each image enhancement operation to obtain a recognition result of the two-dimensional code image.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the two-dimensional code image recognition method described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the two-dimensional code image recognition method described in any one of claims 1 to 7 are implemented.