Two-dimensional code identification method and device

By using pre-trained QR code detection and classification models, the QR code type is determined based on the confidence and decoding results, the problems of low efficiency and poor accuracy of QR code recognition in the prior art are solved, and efficient identification of distorted or deformed QR codes are achieved.

CN120449908APending Publication Date: 2025-08-08SHANGHAI BILIBILI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510571994.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

In the prior art, users have low efficiency in identifying QR codes through manual methods, and it is difficult for QR code recognition tools to accurately identify distorted or deformed preset QR codes.

Method used

The pre-trained QR code detection model and classification model are used to obtain the location information and confidence of the QR code through the detection model. The confidence level is higher than the preset value and the classification model is recognized when it is lower than the preset value to determine whether the QR code is a preset type.

Benefits of technology

It improves the accuracy and efficiency of QR code recognition, and can identify distorted or deformed preset QR codes, improving the accuracy and efficiency of identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120449908A_ABST
    Figure CN120449908A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a two-dimensional code recognition method and device, computer equipment, a medium and a program product. Relates to the technical field of computers. The method comprises the following steps: acquiring a to-be-detected image; inputting the to-be-detected image into a pre-trained two-dimensional code detection model, and outputting the position information of the two-dimensional code contained in the to-be-detected image and the confidence coefficient of the two-dimensional code through the two-dimensional code detection model; when the confidence coefficient is greater than or equal to a preset value, decoding the two-dimensional code image, and determining whether the two-dimensional code is a two-dimensional code of a preset type according to a decoding result; and when the confidence coefficient is smaller than the preset value, inputting the two-dimensional code image into a pre-trained two-dimensional code classification model, outputting a two-dimensional code classification result through the two-dimensional code classification model, and determining whether the two-dimensional code is a two-dimensional code of a preset type according to the two-dimensional code classification result. According to the technical scheme of the embodiment of the invention, the accuracy and the recognition efficiency of two-dimensional code recognition can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a two-dimensional code recognition method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] In today's Internet environment, with the rapid development of various online businesses such as social platforms, e-commerce, and games, the application scenarios of QR codes are becoming more and more numerous.

[0003] In the prior art, some users place some preset types of QR codes in images and guide users to scan these preset types of QR codes to achieve the purpose of spreading specific types of URLs.

[0004] To identify these pre-set QR codes, manual methods or QR code recognition tools are generally used. However, manual methods are inefficient. Using QR code recognition tools can only identify normal QR codes, while some pre-set QR codes often exhibit distortion or deformation, making them inaccurately recognized by the tools.

[0005] It should be noted that the above content is not necessarily prior art, nor is it intended to limit the scope of patent protection of this application. Summary of the Invention

[0006] The embodiments of the present application provide a two-dimensional code recognition method, apparatus, computer equipment, computer-readable storage medium, and computer program product to solve or alleviate one or more of the technical problems raised above.

[0007] One aspect of an embodiment of the present application provides a method for recognizing a two-dimensional code, the method comprising: Obtain the image to be detected; Inputting the image to be detected into a pre-trained QR code detection model, and outputting the position information of the QR code contained in the image to be detected and the confidence level of the QR code through the QR code detection model; If the confidence level is greater than or equal to a preset value, decoding the QR code image and determining whether the QR code is a preset type of QR code based on the decoding result, wherein the QR code image is intercepted from the image to be detected based on the position information; When the confidence level is less than the preset value, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and whether the QR code is a preset type of QR code is determined based on the QR code classification result.

[0008] Optionally, the QR code classification result includes a normal QR code, a deformed QR code, and a non-QR code. When the confidence level is less than the preset value, the QR code image is input into a pre-trained QR code classification model, the QR code classification model outputs a QR code classification result, and determining whether the QR code is a preset type of QR code based on the QR code classification result includes: When the confidence level is less than the preset value, inputting the two-dimensional code image into a pre-trained two-dimensional code classification model, and outputting a two-dimensional code classification result through the two-dimensional code classification model; If the classification result of the QR code is a normal QR code, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result; When the classification result of the two-dimensional code is a deformed two-dimensional code, it is determined that the two-dimensional code is a preset type of two-dimensional code.

[0009] Optionally, when the classification result of the QR code is a normal QR code, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result includes: If the classification result of the two-dimensional code is a normal two-dimensional code, decoding the two-dimensional code image; If the decoding is successful, the decoding result is obtained, and the decoding result is the website information; Performing matching processing on the URL information based on preset URL matching rules; If the matching is successful, it is determined that the QR code is a QR code of a preset type.

[0010] Optionally, the method further includes: In the event of a decoding failure, the two-dimensional code is determined to be a non-two-dimensional code.

[0011] Optionally, when the confidence level is greater than or equal to a preset value, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result include: When the confidence level is greater than or equal to a preset value, decoding the QR code image; If the decoding is successful, the decoding result is obtained, and the decoding result is the website information; Performing matching processing on the URL information based on preset URL matching rules; If the matching is successful, it is determined that the QR code is a QR code of a preset type.

[0012] Optionally, the method further includes: In the event of decoding failure, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and it is determined whether the QR code is a preset type of QR code based on the QR code classification result.

[0013] Optionally, decoding the two-dimensional code image includes: Performing image transformation processing on the two-dimensional code image, wherein the image transformation processing includes at least one of brightness adjustment processing, resolution adjustment processing, and contrast adjustment processing; Decode the two-dimensional code image after image transformation.

[0014] Another aspect of an embodiment of the present application provides a two-dimensional code recognition device, the device comprising: An acquisition module, used for acquiring an image to be detected; An output module is used to input the image to be detected into a pre-trained QR code detection model, and output the position information of the QR code contained in the image to be detected and the confidence level of the QR code through the QR code detection model; a first determining module, configured to decode the QR code image if the confidence level is greater than or equal to a preset value, and determine whether the QR code is a preset type of QR code based on the decoding result, the QR code image being intercepted from the image to be detected based on the position information; The second determination module is used to input the QR code image into a pre-trained QR code classification model when the confidence level is less than the preset value, output the QR code classification result through the QR code classification model, and determine whether the QR code is a preset type of QR code based on the QR code classification result.

[0015] Another aspect of an embodiment of the present application provides a computer device, including: at least one processor; and a memory communicatively coupled to the at least one processor; Wherein: the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described above.

[0016] Another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method described above is implemented.

[0017] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which implements the above-mentioned method when executed by a processor.

[0018] The embodiments of the present application employing the above-mentioned technical solution may have the following advantages: by acquiring an image to be detected and inputting it into a pre-trained QR code detection model, the QR code detection model can output the location information of the QR code contained in the image to be detected and the confidence level of the QR code. When the confidence level is greater than or equal to a preset value (e.g., 0.85), it indicates that the image to be detected is likely to contain a normal QR code image. In this case, the QR code image can be directly decoded to promptly determine whether the QR code is of a preset type based on the decoding result, thereby improving the recognition efficiency of the preset type of QR code. When the confidence level is less than the preset value, it indicates that the image to be detected is likely not to contain a normal QR code image. In this case, the QR code image is input into a pre-trained QR code classification model, which outputs a QR code classification result. Based on the classification result, it is determined whether the QR code is of the preset type. This allows the detection of whether the image to be detected contains a QR code of the preset type even when the image to be detected does not contain a normal QR code image, thereby improving the accuracy of QR code recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings illustrate exemplary embodiments and constitute a part of the specification. Together with the description of the specification, they serve to explain exemplary implementation of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. Throughout the drawings, the same reference numerals designate similar, but not necessarily identical, elements.

[0020] Figure 1 The following diagram schematically illustrates an operating environment of a QR code recognition method according to the first embodiment of the present application; Figure 2 The following schematically shows a flow chart of a QR code recognition method according to the first embodiment of the present application; Figure 3 Schematically shows Figure 1 Flowchart of sub-steps in step S206; Figure 4 Schematically shows Figure 3 Flowchart of sub-steps of step S302; Figure 5 A flowchart schematically illustrates the steps of decoding a QR code image and determining whether the QR code is a preset type of QR code based on the decoding result when the confidence level is greater than or equal to a preset value; Figure 6 A schematic diagram shows a detailed flow chart of steps for decoding a two-dimensional code image; Figure 7 A block diagram of a two-dimensional code recognition device according to the second embodiment of the present application is schematically shown; and Figure 8 The following schematically shows a hardware architecture diagram of a computer device according to the third embodiment of the present application. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solutions and advantages of this application more clear, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0022] It should be noted that the descriptions of "first", "second", etc. in the embodiments of the present application are for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0023] In the description of this application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed. They are only used to facilitate the description of this application and to distinguish each step. Therefore, they cannot be understood as limitations on this application.

[0024] First, an explanation of the terms involved in this application is provided: Preset QR codes: These are QR codes that contain a pre-set URL or have an unusual shape, such as a twisted or deformed QR code. Pre-set URLs are user-defined URLs, typically non-compliant URLs. These include URLs that don't comply with information security regulations or network security standards.

[0025] To facilitate those skilled in the art to understand the technical solutions provided in the embodiments of the present application, the following describes the relevant technologies: In the prior art, identifying preset QR codes typically involves manual methods or using QR code recognition tools. However, manual methods are inefficient. Using QR code recognition tools can only identify normal QR codes, while some preset QR codes often exhibit distortion or deformation, making them inaccurately recognized by the tools.

[0026] To this end, an embodiment of the present application provides a technical solution for QR code recognition. In this technical solution, an image to be detected is obtained and input into a pre-trained QR code detection model so that the QR code detection model can output the location information of the QR code contained in the image to be detected and the confidence level of the QR code. When the confidence level is greater than or equal to a preset value (e.g., 0.85), it indicates that the image to be detected is likely to contain a normal QR code image. At this time, the QR code image can be directly decoded so that it can be determined in a timely manner based on the decoding result whether the QR code is a preset type of QR code, thereby improving the recognition efficiency of the preset type of QR code. When the confidence level is less than the preset value, it indicates that the image to be detected most likely does not contain a normal QR code image. In this case, the QR code image will be input into a pre-trained QR code classification model so that the model can output a QR code classification result. Based on the QR code classification result, it is determined whether the QR code is a preset type of QR code. In this way, even if the image to be detected does not contain a normal QR code image, it can still be detected from the image to be detected whether it contains a preset type of QR code, thereby improving the accuracy of QR code recognition. See below for details.

[0027] Finally, for ease of understanding, an exemplary operating environment is provided below.

[0028] like Figure 1 As shown, the environment diagram includes a service platform 2, a network 4, and a client 6, wherein: The service platform 2 can be comprised of a single or multiple computing devices. These multiple computing devices can include virtualized computing instances. Virtualized computing instances can include virtual machines, such as emulations of computer systems, operating systems, servers, and the like. A computing device can load a virtual machine based on a virtual image and / or other data defining the specific software (e.g., operating system, specialized application, server) used for the emulation. As demand for different types of processing services changes, different virtual machines can be loaded and / or terminated on one or more computing devices. A hypervisor can be implemented to manage the use of different virtual machines on the same computing device.

[0029] The service platform 2 can be configured to communicate with clients 6 and the like via a network 4. The network 4 includes various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and / or the like. The network 4 can include physical links, such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, or wireless links, such as cellular links, satellite links, Wi-Fi links, and the like.

[0030] The service platform 2 can provide storage, reading, writing, querying, deleting and other services, such as providing QR code recognition services for the client.

[0031] Client 6 can be an electronic device running an operating system such as Windows, Android™, or iOS, such as a smartphone, tablet, laptop, virtual reality device, gaming device, set-top box, in-vehicle terminal, or smart TV. Based on these operating systems, various applications, such as QR code recognition applications, can be run.

[0032] The client 6 may provide / configure a user access page for manipulating the service platform 2 or uploading objects, etc.

[0033] It should be noted that the above devices are exemplary, and the number and type of devices can be adjusted in different scenarios or according to different needs.

[0034] The technical solutions of the present application are described below through a number of embodiments. It should be noted that these embodiments can be implemented in a variety of different forms and should not be construed as being limited to the embodiments described herein.

[0035] Example 1 Figure 2 The flowchart of the QR code recognition method according to the first embodiment of the present application is schematically shown.

[0036] like Figure 2 As shown, the QR code recognition method may include steps S200 to S206, wherein: Step S200: Acquire an image to be detected.

[0037] In step S202, the image to be detected is input into a pre-trained two-dimensional code detection model, and the two-dimensional code detection model outputs the position information of the two-dimensional code contained in the image to be detected and the confidence level of the two-dimensional code.

[0038] Step S204, when the confidence level is greater than or equal to a preset value, the QR code image is decoded and it is determined whether the QR code is a preset type of QR code based on the decoding result, and the QR code image is intercepted from the image to be detected based on the position information.

[0039] Step S206, when the confidence level is less than the preset value, input the QR code image into a pre-trained QR code classification model, output the QR code classification result through the QR code classification model, and determine whether the QR code is a preset type of QR code based on the QR code classification result.

[0040] The QR code recognition method provided in this embodiment obtains an image to be detected and inputs it into a pre-trained QR code detection model, so that the QR code detection model can output the location information of the QR code contained in the image to be detected and the confidence level of the QR code. When the confidence level is greater than or equal to a preset value (e.g., 0.85), it indicates that the image to be detected is likely to contain a normal QR code image. In this case, the QR code image can be directly decoded to promptly determine whether the QR code is a preset type of QR code based on the decoding result, thereby improving the recognition efficiency of the preset type of QR code. When the confidence level is less than the preset value, it indicates that the image to be detected is likely not to contain a normal QR code image. In this case, the QR code image is input into a pre-trained QR code classification model, so that the QR code classification model can output a QR code classification result. Based on the QR code classification result, it is determined whether the QR code is a preset type of QR code. This allows the detection of whether the image to be detected contains a preset type of QR code even when the image to be detected does not contain a normal QR code image, thereby improving the accuracy of QR code recognition.

[0041] The following combination Figure 1 , each step in steps S200~S206 and other optional steps are described in detail.

[0042] Step S200 , obtain the image to be detected.

[0043] The image to be detected is an image that needs to be detected. The image to be detected may contain a QR code or may not contain a QR code.

[0044] Step S202 , input the image to be detected into a pre-trained QR code detection model, and output the position information of the QR code contained in the image to be detected and the confidence of the QR code through the QR code detection model.

[0045] The two-dimensional code detection model is a model that can detect and output the position information of the two-dimensional code contained in the image to be detected and the confidence level of the two-dimensional code.

[0046] The position information of a QR code can generally be represented by the coordinates of the upper left vertex, lower left vertex, upper right vertex, and lower right vertex of the QR code. When the QR code contained in the image to be detected is not a normal QR code, the position information of the QR code can also be represented by the matrix information of the position of the QR code.

[0047] It should be noted that the normal QR code mentioned above refers to a QR code that has not been distorted or deformed.

[0048] The confidence level of a QR code refers to the likelihood that the image to be detected contains a QR code. A higher confidence level indicates a higher likelihood that the image to be detected contains a QR code; a lower confidence level indicates a lower likelihood that the image to be detected contains a QR code. For example, a confidence level of 1 indicates that the image to be detected definitely contains a QR code; a confidence level of 0 indicates that the image to be detected definitely does not contain a QR code.

[0049] In some embodiments, the QR code detection model can be obtained by training the YOLO model through a QR code-related data set, so that the obtained QR code detection model can locate the QR code in the image, and for each located QR code, the confidence level of the QR code contained in the image will be marked.

[0050] The YOLO (You Only Look Once) model is a revolutionary real-time object detection algorithm first proposed by Joseph Redmon and Ali Farhadi in 2015. The core concept of the YOLO model is to treat the object detection task as a regression problem, directly mapping image pixels to bounding box coordinates and class probabilities. The YOLO model primarily consists of convolutional layers, fully connected layers, anchor boxes, and regression and classification heads. Convolutional layers extract features from images; fully connected layers predict bounding boxes and class probabilities; anchor boxes introduce predefined anchor boxes to accommodate objects of varying sizes and aspect ratios, simplifying prediction. The regression and classification heads are responsible for predicting bounding box coordinates and determining object categories, respectively.

[0051] In other embodiments, the QR code detection model can also be obtained by training a FasterR-CNN model, an SSD model, a DETR model, etc. using a QR code-related data set.

[0052] Among them, Faster R-CNN is a classic object detection model proposed by Ross Girshick et al. It further improves on Fast R-CNN by introducing the Region Proposal Network (RPN), thus achieving end-to-end training and faster detection speed.

[0053] The SSD (Single Shot MultiBox Detector) model is a single-stage target detection model proposed by Wei Liu et al. It can simultaneously predict the location and category of multiple targets by detecting on feature maps of different scales.

[0054] The DETR (DEtection TRansformer) model is a Transformer-based target detection model proposed by the Facebook team in 2020. It treats target detection as a set prediction problem, simplifying the detection pipeline.

[0055] Step S204 When the confidence level is greater than or equal to a preset value, the two-dimensional code image is decoded and it is determined whether the two-dimensional code is a preset type of two-dimensional code based on the decoding result. The two-dimensional code image is intercepted from the image to be detected based on the position information.

[0056] The preset value can be set according to actual conditions. For example, the preset value is 0.85.

[0057] When the confidence level is greater than or equal to a preset value, it indicates that the image to be detected is likely to contain a normal QR code. In this case, the QR code image is directly decoded to obtain the information contained in the QR code image. In this embodiment, the specific content of the information is not limited.

[0058] In one embodiment, the information may be text information, such as a website address, phone number, email address, or personal business card (vCard). In another embodiment, the information may be digital information, such as purely digital content like a product number or serial number. In another embodiment, the information may be a URL link, such as a link that directly jumps to a specific webpage or online resource.

[0059] In some embodiments, when decoding a QR code image, an existing QR code decoding model can be used. For example, the open-source QR code decoding model of WeChat can be used to decode the QR code image to obtain a decoding result. The QR code image is captured from the image to be detected based on the position information, so that the captured QR code image only retains the QR code image and removes the background image from the image to be detected, facilitating subsequent decoding of the QR code image.

[0060] In one embodiment, when determining whether the two-dimensional code is a preset type of two-dimensional code based on the decoding result, the following methods may be used to determine whether the two-dimensional code is a preset type of two-dimensional code.

[0061] Method 1: If the content in the decoding result is of a preset type, it can be determined that the QR code is a QR code of the preset type.

[0062] Method 2: If the decoding result is URL information, when determining whether the QR code is a preset type of QR code, you can first determine whether the URL information is a preset type of URL. If the URL information is a preset type of URL, you can determine that the QR code is a preset type of QR code.

[0063] Method 3: If the decoding result is a URL link, when determining whether the QR code is a preset type of QR code, you can first determine whether the web page content corresponding to the URL link contains content of the preset type. If it contains content of the preset type, you can determine that the QR code is a preset type of URL.

[0064] The preset type of content refers to the content type set by the user according to actual conditions, which generally refers to a type of non-standard content, and may include content that does not comply with information security specifications and content that does not comply with network security specifications.

[0065] It should be noted that the method of determining whether the QR code is a preset type of QR code based on the decoding result is not limited to the three methods described above, and other methods can also be used to determine whether the QR code is a preset type of QR code. For example, when the decoding result is a decoding failure, it is also possible to directly determine that the QR code is a preset type of QR code. For another example, when the decoding result is a decoding failure, other means can be combined to determine whether the QR code is a preset type of QR code. For example, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and whether the QR code is a preset type of QR code is determined based on the QR code classification result.

[0066] Step S206When the confidence level is less than the preset value, the two-dimensional code image is input into a pre-trained two-dimensional code classification model, the two-dimensional code classification result is output by the two-dimensional code classification model, and whether the two-dimensional code is a preset type of two-dimensional code is determined based on the two-dimensional code classification result.

[0067] When the confidence level is less than a preset value, it indicates that the image to be detected is most likely not to contain a normal QR code. At this time, in order to realize the recognition of the QR code image in the image to be detected, the QR code image will be input into a pre-trained QR code classification model so that the QR code can be classified by the QR code classification model, so that the QR code can be accurately determined by the QR code classification result whether it is a preset type of QR code.

[0068] In some embodiments, the QR code classification model can be obtained by training a resnet50 model using a sample dataset, so that the obtained QR code classification model can accurately output a QR code classification result. The QR code classification result can include two categories: normal QR codes and deformed QR codes. In another embodiment, to improve classification accuracy, the QR code classification result can also include three categories: normal QR codes, deformed QR codes, and non-QR codes.

[0069] In other embodiments, the QR code classification model can be obtained by training a convolutional neural network model, a Transformer model, etc. using a sample dataset.

[0070] The sample data set may include normal two-dimensional code sample images, deformed two-dimensional code sample images, and non-two-dimensional code sample images.

[0071] Normal QR code sample images can be obtained from various websites and platforms. For example, normal QR code sample images can be obtained from the Baidu platform. After obtaining normal QR code sample images from the website platform, they can be combined with normal QR code images obtained from the community where the image to be tested is published as QR code sample images to increase the diversity of sample images. Afterwards, key points in the QR code sample images can be annotated to serve as normal QR code sample images for subsequent training.

[0072] The deformed QR code sample images can be obtained by performing a random perspective transformation on a normal QR code image. In addition, to improve the recognition accuracy of the model, the deformed QR code sample images can also include QR code images of a preset type obtained from the community.

[0073] Non-QR code sample images can be obtained using the following process: First, collect regular images posted within the community. Then, feed these collected regular images into the QR code detection model and select images with a confidence score below a certain threshold (e.g., 0.01). These images are then randomly sliced and used as non-QR code sample images.

[0074] In this embodiment, by constructing a sample dataset as described above, the trained classification model can meet the algorithm requirements while also having training parameters that conform to the data distribution within the community. Thus, the QR code classification model trained with this sample dataset can more accurately classify QR code images.

[0075] The normal QR code refers to an existing common QR code that has not been deformed.

[0076] The deformed QR code refers to a QR code that has undergone a deformation process, and the deformation process includes a distortion process, a process of changing the shape of corners of the QR code, etc. The process of changing the shape of corners may be changing right angles into rounded corners.

[0077] The non-QR code refers to that the QR code image is not a QR code.

[0078] In an optional embodiment, if Figure 3 As shown, the QR code classification results include normal QR codes, deformed QR codes and non-QR codes. Step S206 may include: Step S300: When the confidence level is less than the preset value, the two-dimensional code image is input into a pre-trained two-dimensional code classification model, and a two-dimensional code classification result is output through the two-dimensional code classification model.

[0079] Step S302: If the classification result of the QR code is a normal QR code, decoding the QR code image and determining whether the QR code is a preset type of QR code based on the decoding result; Step S304: If the classification result of the QR code is a deformed QR code, determine that the QR code is a preset type of QR code.

[0080] In this embodiment, when the confidence level is less than the preset value, it indicates that the image to be detected is most likely not to contain a normal two-dimensional code image. At this time, in order to avoid misdetection by the two-dimensional code detection model and improve the accuracy of two-dimensional code recognition, the two-dimensional code image will be input into a pre-trained two-dimensional code classification model to determine the category of the two-dimensional code image through the two-dimensional code classification model, that is, whether the two-dimensional code image is a normal two-dimensional code, a deformed two-dimensional code or a non-two-dimensional code. In the case that the two-dimensional code classification result is a normal two-dimensional code, the two-dimensional code image will continue to be decoded and whether the two-dimensional code is a preset type of two-dimensional code will be determined based on the decoding result. Among them, how to determine whether the two-dimensional code is a preset type of two-dimensional code based on the decoding result has been described in detail in the above embodiment and will not be repeated in this embodiment. In the case that the two-dimensional code classification result is a deformed two-dimensional code, it can be directly determined that the two-dimensional code is a preset type of two-dimensional code.

[0081] In this embodiment, when the QR code classification result is a normal QR code, the QR code image will still be decoded and processed, and whether the QR code is a preset type of QR code will be determined based on the decoding result. When the QR code classification result is a deformed QR code, the QR code will be directly determined to be a preset type of QR code, thereby improving the accuracy of QR code recognition.

[0082] It should be noted that, in other embodiments, in order to improve the efficiency of QR code recognition, when the QR code classification result is a normal QR code, it can also be directly determined that the QR code is not a preset type of QR code, and the QR code image will no longer be decoded, and it can be determined whether the QR code is a preset type of QR code based on the decoding result.

[0083] In an optional embodiment, if Figure 4 As shown, step S302 may include: Step S400: When the classification result of the two-dimensional code is a normal two-dimensional code, decoding processing is performed on the two-dimensional code image.

[0084] Step S402: If the decoding is successful, obtain the decoding result, which is the website information.

[0085] Step S404: performing matching processing on the website information based on a preset website matching rule; Step S406: If the matching is successful, determine that the QR code is a preset type of QR code.

[0086] In this embodiment, when a QR code is determined to be a normal QR code, the information contained in a normal QR code may not conform to the standard. To improve the readiness of QR code recognition, the QR code image is decoded. If the decoding is successful, the decoding result is obtained, thereby obtaining the URL information contained in the QR code image. After the URL information is obtained, it is matched based on pre-set URL matching rules. If the match is successful, it indicates that the QR code is of the preset type; if the match fails, it indicates that the QR code is not of the preset type, but is a normal QR code.

[0087] The URL matching rule is a pre-set rule for matching URL information to see whether it is a URL of a preset type. The URL matching rule may be a regular matching rule.

[0088] In this embodiment, the URL information obtained by successful decoding is matched based on the preset URL matching rules, and if the match is successful, the QR code is determined to be a preset type of QR code, thereby improving the accuracy of preset type URL recognition.

[0089] In an optional embodiment, the method further comprises: In the event of a decoding failure, the two-dimensional code is determined to be a non-two-dimensional code.

[0090] In this embodiment, if the classification result of the QR code is a normal QR code, after decoding the QR code image, if the decoding fails, it indicates that the QR code is misclassified. In this case, it can be determined that the QR code is not a QR code.

[0091] In this embodiment, when decoding fails, the QR code is directly determined to be a non-QR code without further processing the QR code, thereby improving the recognition efficiency of the QR code.

[0092] It should be noted that, in other embodiments, if decoding fails, it indicates that the QR code has been misclassified. In this case, there is a certain probability that the QR code is a QR code of the preset type. In other words, if decoding fails, it can also be determined that the QR code is a QR code of the preset type. To improve recognition accuracy, further manual verification can be performed to determine whether the QR code is a QR code of the preset type.

[0093] In an alternative embodiment, see Figure 5 , when the confidence level is greater than or equal to a preset value, decoding the two-dimensional code image, and determining whether the two-dimensional code is a preset type of two-dimensional code according to the decoding result, including: Step S500: When the confidence level is greater than or equal to a preset value, decoding the two-dimensional code image is performed.

[0094] Step S502: If the decoding is successful, obtain the decoding result, which is the website information.

[0095] Step S504: performing matching processing on the website information based on a preset website matching rule; Step S506: If the matching is successful, determine that the QR code is a QR code of a preset type.

[0096] The method for determining whether the QR code is a preset type of QR code in this embodiment is substantially the same as the method for determining whether the QR code is a preset type of QR code in the above embodiment when the QR code classification result is a normal QR code. The only difference is that the decoding time allowed for the QR code image in this embodiment is shorter. For example, in this embodiment, the maximum decoding time allowed is 2 seconds, while when the QR code classification result is a normal QR code, the maximum decoding time allowed may be 5 seconds.

[0097] In this embodiment, the URL information obtained by successful decoding is matched based on the preset URL matching rules, and if the match is successful, the QR code is determined to be a preset type of QR code, thereby improving the accuracy of preset type URL recognition.

[0098] In an alternative embodiment, see Figure 5 , the method further comprises: Step S508: If decoding fails, the QR code image is input into a pre-trained QR code classification model, the QR code classification model outputs a QR code classification result, and determines whether the QR code is a preset type of QR code based on the QR code classification result.

[0099] In this embodiment, how to output the QR code classification result through the QR code classification model and determine whether the QR code is a preset type of QR code based on the QR code classification result has been described in detail in the above embodiment and will not be repeated in this embodiment.

[0100] In this embodiment, in the event of decoding failure, the QR code image will still be input into a pre-trained QR code classification model, and the QR code classification result will be output by the QR code classification model. Based on the QR code classification result, it is determined whether the QR code is a preset type of QR code, thereby improving the accuracy of QR code recognition.

[0101] It should be noted that, in other implementations, when decoding fails, it is also possible to directly determine that the QR code is a preset type of QR code.

[0102] In an optional embodiment, if Figure 6 As shown, decoding the two-dimensional code image may include: Step S600: performing image transformation processing on the two-dimensional code image, wherein the image transformation processing includes at least one of brightness adjustment processing, resolution adjustment processing, and contrast adjustment processing.

[0103] Step S602: Decode the two-dimensional code image after image transformation.

[0104] In some embodiments, multiple parameters can be set in advance for brightness, resolution, and contrast. For example, for brightness, 3 brightness parameters can be set; for resolution, 7 resolution parameters can be set; and for contrast, 10 contrast parameters can be set. Through the above settings, when performing image transformation processing on the two-dimensional code image, one or more parameters can be randomly selected from these parameters to perform image transformation processing on the two-dimensional code image. After the image transformation processing is completed, the two-dimensional code image that has undergone image transformation processing is decoded. After the decoding fails, attempts will continue to be made to select other parameters to perform image transformation processing on the two-dimensional code image, and then the decoding processing will continue on the two-dimensional code image that has undergone image transformation processing. And so on, until the decoding is successful, or until the maximum time allowed for decoding is consumed, the image transformation processing of the two-dimensional code image is terminated.

[0105] In this embodiment, when decoding a QR code image, the QR code image is first transformed to improve the recognizability of the QR code. Only then is the transformed QR code image decoded, thereby improving the decoding success rate of the QR code image. In addition, the above processing method can also effectively decode AI-generated images.

[0106] Example 2 Figure 7 The block diagram of the two-dimensional code recognition device 700 according to the second embodiment of the present application is schematically shown. The device can be divided into one or more program modules, one or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can perform specific functions. The following description will specifically introduce the functions of each program module in this embodiment. Figure 7 As shown, the apparatus 700 may include: an acquisition module 710, an output module 720, a first determination module 730, and a second determination module 740, wherein: An acquisition module 710 is used to acquire an image to be detected; An output module 720 is configured to input the image to be detected into a pre-trained QR code detection model, and output the position information of the QR code contained in the image to be detected and the confidence level of the QR code through the QR code detection model; a first determining module 730 configured to, if the confidence level is greater than or equal to a preset value, decode the QR code image and determine, based on the decoding result, whether the QR code is a preset type of QR code, the QR code image being intercepted from the image to be detected based on the position information; The second determination module 740 is used to input the QR code image into a pre-trained QR code classification model when the confidence level is less than the preset value, output the QR code classification result through the QR code classification model, and determine whether the QR code is a preset type of QR code based on the QR code classification result.

[0107] As an optional embodiment, the QR code classification result includes a normal QR code, a deformed QR code, and a non-QR code. When the confidence level is less than the preset value, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and whether the QR code is a preset type of QR code is determined based on the QR code classification result, including: When the confidence level is less than the preset value, inputting the two-dimensional code image into a pre-trained two-dimensional code classification model, and outputting a two-dimensional code classification result through the two-dimensional code classification model; If the classification result of the QR code is a normal QR code, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result; When the classification result of the two-dimensional code is a deformed two-dimensional code, it is determined that the two-dimensional code is a preset type of two-dimensional code.

[0108] As an optional embodiment, when the classification result of the QR code is a normal QR code, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result includes: If the classification result of the two-dimensional code is a normal two-dimensional code, decoding the two-dimensional code image; If the decoding is successful, the decoding result is obtained, and the decoding result is the website information; Performing matching processing on the URL information based on preset URL matching rules; If the matching is successful, it is determined that the QR code is a QR code of a preset type.

[0109] As an optional embodiment, the second determining module 740 is further configured to: In the event of a decoding failure, the two-dimensional code is determined to be a non-two-dimensional code.

[0110] As an optional embodiment, when the confidence level is greater than or equal to a preset value, decoding the QR code image and determining whether the QR code is a preset type of QR code based on the decoding result includes: When the confidence level is greater than or equal to a preset value, decoding the QR code image; If the decoding is successful, the decoding result is obtained, and the decoding result is the website information; Performing matching processing on the URL information based on preset URL matching rules; If the matching is successful, it is determined that the QR code is a QR code of a preset type.

[0111] As an optional embodiment, the first determining module 730 is further configured to: In the event of decoding failure, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and it is determined whether the QR code is a preset type of QR code based on the QR code classification result.

[0112] As an optional embodiment, decoding the two-dimensional code image includes: Performing image transformation processing on the two-dimensional code image, wherein the image transformation processing includes at least one of brightness adjustment processing, resolution adjustment processing, and contrast adjustment processing; Decode the two-dimensional code image after image transformation.

[0113] Example 3 Figure 8 The following schematically shows a hardware architecture diagram of a computer device 10000 suitable for implementing a two-dimensional code recognition method according to the third embodiment of the present application. In some embodiments, the computer device 10000 may be a terminal device such as a smart phone, a wearable device, a tablet computer, a personal computer, a vehicle-mounted terminal, a game console, a virtual device, a workbench, a digital assistant, a set-top box, a robot, etc. In other embodiments, the computer device 10000 may be a rack server, a blade server, a tower server, or a cabinet server (including an independent server or a server cluster composed of multiple servers), etc. Figure 8 As shown, the computer device 10000 includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other via a system bus. Memory 10010 includes at least one type of computer-readable storage medium, including flash memory, a hard disk, a multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, a magnetic disk, an optical disk, and the like. In some embodiments, memory 10010 may be an internal storage module of computer device 10000, such as a hard disk or memory of computer device 10000. In other embodiments, memory 10010 may also be an external storage device of computer device 10000, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, and the like equipped on computer device 10000. Of course, memory 10010 may also include both internal storage modules and external storage devices of computer device 10000. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed on the computer device 10000, such as the program code of the QR code recognition method, etc. In addition, the memory 10010 can also be used to temporarily store various data that has been output or will be output.

[0114] In some embodiments, processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. Processor 10020 is typically used to control the overall operation of computer device 10000, such as performing control and processing related to data exchange or communication with computer device 10000. In this embodiment, processor 10020 is used to execute program code stored in memory 10010 or process data.

[0115] Network interface 10030 may include a wireless network interface or a wired network interface. Network interface 10030 is typically used to establish a communication link between computer device 10000 and other computer devices. For example, network interface 10030 is used to connect computer device 10000 to an external terminal via a network, establishing a data transmission channel and a communication link between computer device 10000 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile Communications (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth, or Wi-Fi.

[0116] It should be pointed out that Figure 8 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementing all of the shown components is not a requirement, and greater or fewer components may alternatively be implemented.

[0117] In this embodiment, the two-dimensional code recognition method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as processor 10020) to complete the embodiment of the present application.

[0118] Example 4 An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the two-dimensional code recognition method in the embodiment are implemented.

[0119] In this embodiment, computer-readable storage media include flash memory, hard disks, multimedia cards, card-type memories (e.g., SD or DX memories), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, magnetic disks, optical disks, and the like. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as the computer device's hard disk or memory. In other embodiments, the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash memory card, and the like. Of course, the computer-readable storage medium may also include both the internal storage unit and external storage devices of the computer device. In this embodiment, the computer-readable storage medium is typically used to store the operating system and various application software installed on the computer device, such as the program code of the QR code recognition method described in the embodiment. In addition, the computer-readable storage medium may also be used to temporarily store various types of data that has been output or is about to be output.

[0120] Example 5 An embodiment of the present application further provides a computer program product, including a computer program, which implements the method in the above embodiment when executed by a processor.

[0121] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented using general-purpose computer devices. They can be concentrated on a single computer device or distributed on a network composed of multiple computer devices. Alternatively, they can be implemented using program codes executable by the computer device, so that they can be stored in a storage device and executed by the computer device. In some cases, the steps shown or described can be performed in a different order than herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0122] It should be noted that the above are only preferred embodiments of the present application and do not limit the scope of patent protection of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the scope of patent protection of the present application.

Claims

1. A two-dimensional code recognition method, characterized in that: The method comprises: Obtain the image to be detected; Inputting the image to be detected into a pre-trained QR code detection model, and outputting the position information of the QR code contained in the image to be detected and the confidence level of the QR code through the QR code detection model; If the confidence level is greater than or equal to a preset value, decoding the QR code image and determining whether the QR code is a preset type of QR code based on the decoding result, wherein the QR code image is intercepted from the image to be detected based on the position information; When the confidence level is less than the preset value, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and whether the QR code is a preset type of QR code is determined based on the QR code classification result.

2. The method according to claim 1, characterized in that The two-dimensional code classification result includes a normal two-dimensional code, a deformed two-dimensional code, and a non-two-dimensional code. When the confidence level is less than the preset value, the two-dimensional code image is input into a pre-trained two-dimensional code classification model, the two-dimensional code classification model outputs a two-dimensional code classification result, and whether the two-dimensional code is a preset type of two-dimensional code is determined according to the two-dimensional code classification result, including: When the confidence level is less than the preset value, the two-dimensional code image is input into a pre-trained two-dimensional code classification model, and a two-dimensional code classification result is outputted by the two-dimensional code classification model; If the classification result of the QR code is a normal QR code, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result; When the classification result of the two-dimensional code is a deformed two-dimensional code, it is determined that the two-dimensional code is a preset type of two-dimensional code.

3. The method according to claim 2, characterized in that When the classification result of the two-dimensional code is a normal two-dimensional code, decoding the two-dimensional code image and determining whether the two-dimensional code is a preset type of two-dimensional code according to the decoding result includes: If the classification result of the two-dimensional code is a normal two-dimensional code, decoding the two-dimensional code image; If the decoding is successful, the decoding result is obtained, and the decoding result is the website information; Performing matching processing on the URL information based on preset URL matching rules; If the match is successful, it is determined that the QR code is a QR code of a preset type.

4. The method according to claim 3, characterized in that The method further comprises: In the event of a decoding failure, it is determined that the two-dimensional code is not a two-dimensional code.

5. The method according to claim 1, wherein When the confidence level is greater than or equal to a preset value, decoding the QR code image and determining whether the QR code is a preset type of QR code according to the decoding result include: When the confidence level is greater than or equal to a preset value, decoding the QR code image; If the decoding is successful, the decoding result is obtained, and the decoding result is the website information; Performing matching processing on the URL information based on preset URL matching rules; If the match is successful, it is determined that the QR code is a QR code of a preset type.

6. The method according to claim 5, characterized in that The method further comprises: In the event of decoding failure, the QR code image is input into a pre-trained QR code classification model, the QR code classification result is output by the QR code classification model, and it is determined whether the QR code is a preset type of QR code based on the QR code classification result.

7. The method according to any one of claims 1 to 5, characterized in that Decoding the QR code image includes: Performing image transformation processing on the two-dimensional code image, wherein the image transformation processing includes at least one of brightness adjustment processing, resolution adjustment processing, and contrast adjustment processing; Decode the two-dimensional code image after image transformation.

8. A two-dimensional code recognition device, characterized in that: The device comprises: An acquisition module, used for acquiring an image to be detected; An output module is used to input the image to be detected into a pre-trained QR code detection model, and output the position information of the QR code contained in the image to be detected and the confidence level of the QR code through the QR code detection model; a first determining module, configured to decode the QR code image if the confidence level is greater than or equal to a preset value, and determine whether the QR code is a preset type of QR code based on the decoding result, the QR code image being intercepted from the image to be detected based on the position information; The second determination module is used to input the QR code image into a pre-trained QR code classification model when the confidence level is less than the preset value, output the QR code classification result through the QR code classification model, and determine whether the QR code is a preset type of QR code based on the QR code classification result.

9. A computer device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the method according to any one of claims 1 to 7.

11. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to claims 1 to 7 are implemented.