A code scanning authenticity verification method, system, device and storage medium
By generating a disturbance layer in the QR code image and performing consistency comparison, the problem of difficulty in identifying counterfeit scanning behavior in existing technologies is solved, efficient scanning authenticity verification is achieved, and risk control capabilities and security are improved.
Patent Information
- Application Number
- CN202511046135.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-29
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-07-29
AI Technical Summary
Existing technologies lack a mechanism to verify the scanned code image itself, resulting in difficulty in identifying forged scanned code behavior, a high misjudgment rate, a poor experience, and low bypass costs, making it impossible to effectively protect the security of marketing resources.
By generating a perturbation layer before generating the QR code image, combining the perturbation type and injection intensity, the expected perturbation structure characteristics are constructed, and consistency comparison is performed during the scanning process to identify counterfeit scanning behavior.
Effectively identify forged scanning behaviors such as screenshots, photo-taking, and simulators, improve the risk control capabilities of scanning interactions, and ensure the authenticity of QR codes in bill verification and anti-counterfeiting traceability scenarios.
Smart Images

Figure CN120542454B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to QR code processing technology, and in particular to a method, system, device and storage medium for verifying the authenticity of a scanned code. Background Art
[0002] With the widespread adoption of interactive QR code scanning applications, such as sweepstakes, points redemption, electronic check-in, and anti-counterfeiting authentication, QR codes have become a crucial medium for brand marketing and user engagement, serving as a vehicle for information delivery and interaction. However, the widespread adoption of QR code scanning has also led to a surge in unauthorized scanning practices, such as simulating others' scans by taking screenshots and reproducing them, using simulators to perform batch scanning to gain benefits, synthesizing counterfeit QR code images through image processing, and leveraging proxy networks or virtual device environments for large-scale QR code manipulation. These counterfeit scanning attacks not only severely disrupt normal marketing operations but also lead to wasted prize resources, distorted data statistics, a decline in user trust, and even brand risk management crises.
[0003] To mitigate these risks, some platforms have experimented with introducing technical measures, including behavior frequency monitoring, IP or device fingerprint blocking, verification code pop-up verification, and account blacklisting mechanisms. While these methods can identify anomalous accounts or devices to a certain extent, they primarily rely on information from the network interaction layer and user behavior layer, lacking the ability to verify the authenticity of the image itself during the scanning process. Consequently, they still face issues such as high false positive rates, poor user experience, low bypass costs, and unexplainable images. For example, by simulating the scanning process through screenshots or photocopying, existing risk control mechanisms can be bypassed and platform benefits can be obtained.
[0004] In summary, existing technologies lack an authenticity verification mechanism that can verify the scanned image itself, demonstrates robustness, has a low false positive rate, and is easily integrated and deployed. Especially in interactive marketing campaigns, determining directly from the image layer whether the scanned QR code is genuine and whether it is an original, rather than a forged, image source has become a pressing technical challenge to improve risk control capabilities for scanning and ensure the security of marketing resources. Summary of the Invention
[0005] This application provides a method, system, device and storage medium for verifying the authenticity of code scanning. Through the generation and identification mechanism of the disturbance layer, it judges the authenticity of the user's code scanning behavior, identifies forged code scanning attacks such as screenshots, reshoots, and simulators, and improves the risk control capability of code scanning interaction.
[0006] In a first aspect, the present application provides a method for verifying the authenticity of a code scan, comprising:
[0007] Perturbation layer logical structure generation: before the QR code image is generated, the perturbation type and perturbation injection intensity level are dynamically configured based on the perturbation parameters according to the perturbation type selection mechanism, the perturbation layer logical structure is generated in combination with the perturbation injection strategy, and the corresponding expected perturbation structure features are constructed based on the perturbation layer logical structure;
[0008] QR code image generation: in the QR code image generation stage, a disturbance layer is generated based on the disturbance layer logical structure, and the disturbance layer is integrated with the QR code standard logical structure to generate a QR code image including the disturbance layer;
[0009] QR code image acquisition and target perturbation structure construction: the user terminal scans the target QR code, extracts the target QR code image and constructs the corresponding target perturbation structure features;
[0010] The authenticity verification of the QR code image is based on the unique identifier of the perturbation layer corresponding to the target QR code. The expected perturbation structure features stored on the server are extracted. According to the consistency comparison strategy, the target perturbation structure features are compared with the expected perturbation structure features to obtain an authenticity score. According to the authenticity judgment rules, the authenticity of the target QR code is judged.
[0011] Optionally, the disturbance parameters include a unique identifier of the disturbance layer, a QR code usage type, and a disturbance level;
[0012] The types of QR code usage include static display codes, dynamic refresh codes, lottery or event codes, internal codes for jumps, and high-risk verification codes;
[0013] The disturbance levels include light disturbance, medium disturbance and strong disturbance.
[0014] Optionally, the disturbance type includes high-frequency interference dot matrix disturbance, pixel-level offset disturbance and semi-transparent watermark disturbance;
[0015] The disturbance injection intensity levels include primary injection intensity, secondary injection intensity and tertiary injection intensity.
[0016] Optionally, the generation of the disturbance layer logical structure includes:
[0017] Performing the initialization operation of the perturbation parameters before generating the QR code image;
[0018] Based on the disturbance parameters, executing a disturbance type selection mechanism to dynamically configure the disturbance type;
[0019] Based on the disturbance parameters, executing an injection intensity selection mechanism to dynamically configure a disturbance injection intensity level;
[0020] Determine the effective structural bounding box of the QR code based on the standard logical structure of the QR code, and accordingly eliminate the QR code functional module area, and mark the remaining area as the candidate disturbance injection area;
[0021] Based on the configured disturbance type and injection intensity level, the disturbance layer logical structure is constructed according to the disturbance injection strategy;
[0022] Based on the perturbation layer logical structure and the QR code standard logical structure, the expected perturbation structure features are structurally encapsulated.
[0023] Optionally, the disturbance type selection mechanism includes:
[0024] When the QR code usage type is identified as a static display code and the disturbance level is light disturbance, the disturbance type is configured as semi-transparent watermark disturbance;
[0025] When the QR code usage type is identified as a static display code and the disturbance level is medium disturbance or strong disturbance, the disturbance type is configured as a combined disturbance structure including high-frequency interference dot matrix disturbance and semi-transparent watermark disturbance;
[0026] When the QR code usage type is identified as a dynamic refresh code, the perturbation type is configured as pixel-level offset perturbation;
[0027] When the QR code usage type is identified as a lottery or activity code, the perturbation type is configured as a semi-transparent watermark perturbation;
[0028] When the QR code usage type is identified as an internal code for jump, the perturbation type is configured as pixel-level offset perturbation;
[0029] When the usage type of the QR code is identified as a high-risk verification code, the configured disturbance type is a combined disturbance structure including high-frequency interference dot matrix disturbance, pixel-level offset disturbance and semi-transparent watermark disturbance.
[0030] Optionally, the disturbance injection strategy includes:
[0031] When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level one, 30% of the image center area is selected, the dot matrix spacing is 32px, and the dot matrix grayscale value range is 128~144;
[0032] When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level 2, 40% of the image center area is selected, the dot matrix spacing is 24px, and the dot matrix grayscale value range is 128~152;
[0033] When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level 3, 50% of the image center area is selected, the dot matrix spacing is 16px, and the dot matrix grayscale value range is 128~160;
[0034] When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 1, 10% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±0.5px, and the perturbation direction is horizontal or vertical;
[0035] When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 2, 20% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±1px, and the perturbation direction is horizontal or vertical;
[0036] When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 3, 30% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±1.5px, and the perturbation direction is horizontal or vertical;
[0037] When the perturbation type is semi-transparent watermark perturbation and the injection intensity level is level one, the watermark transparency is set to 20%, the superimposed pattern complexity is set to simple icon, and the layer area is the main area;
[0038] When the perturbation type is semi-transparent watermark perturbation and the injection intensity level is level 2, the watermark transparency is set to 35%, the superimposed pattern complexity is the brand icon, and the layer area is the entire bottom layer of the image;
[0039] When the disturbance type is semi-transparent watermark disturbance and the injection intensity level is level three, the watermark transparency is selected as 50%, the superimposed pattern complexity is a multi-element pattern, and the layer area is the entire bottom layer.
[0040] Optionally, the consistency comparison strategy includes: separately calculating the perturbation dot matrix primitive position consistency score, primitive offset vector matching score and watermark layer matching score, and generating an authenticity score by weighted average.
[0041] In a second aspect, the present application provides a code scanning authenticity verification system, comprising:
[0042] A disturbance layer logical structure generation module dynamically configures the disturbance type and disturbance injection intensity level based on the disturbance parameters according to the disturbance type selection mechanism before generating the QR code image, generates the disturbance layer logical structure in combination with the disturbance injection strategy, and constructs the corresponding expected disturbance structure features based on the disturbance layer logical structure;
[0043] A QR code image generation module generates a disturbance layer based on the disturbance layer logical structure during the QR code image generation phase, fuses the disturbance layer with the QR code standard logical structure, and generates a QR code image including the disturbance layer;
[0044] The QR code image acquisition and target perturbation structure construction module extracts the target QR code image and constructs the corresponding target perturbation structure features through the user terminal scanning the target QR code;
[0045] The QR code image authenticity verification module extracts the expected perturbation structure features stored on the server based on the unique identifier of the perturbation layer corresponding to the target QR code. Based on the consistency comparison strategy, it compares the target perturbation structure features with the expected perturbation structure features to obtain an authenticity score, and judges the authenticity of the target QR code based on the authenticity judgment rules.
[0046] In a third aspect, the present application provides an electronic device, comprising:
[0047] processor; and,
[0048] a memory for storing executable instructions of the processor;
[0049] The processor is configured to perform any possible method described in the first aspect by executing the executable instructions.
[0050] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement any possible method described in the first aspect.
[0051] This application provides a method, system, device, and storage medium for verifying the authenticity of a scanned QR code. By injecting a structured, restorable disturbance layer into a QR code image and combining the disturbance type and injection intensity to construct the expected disturbance structure, the system compares the disturbance consistency between the scanned image and the generated image. This method effectively identifies counterfeit scans, such as screenshots, photocopies, and simulators, without affecting normal scan recognition. This improves the authenticity assurance of QR codes in scenarios such as bill verification and anti-counterfeiting tracing. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0053] Figure 1 This is a flowchart of a code scanning authenticity verification method according to an exemplary embodiment of the present application;
[0054] Figure 2 This is a schematic diagram of a process for generating a disturbance layer logic structure according to an exemplary embodiment of the present application;
[0055] Figure 3 1 is a schematic diagram of a system for verifying authenticity by scanning a barcode according to an exemplary embodiment of the present application;
[0056] Figure 42 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application.
[0057] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0058] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0059] In order to solve the above problems, this application provides a method, system, device and storage medium for verifying the authenticity of code scanning, which aims to judge the authenticity of user code scanning behavior through the generation and identification mechanism of the disturbance layer, identify fake code scanning attacks such as screenshots, reshoots, and simulators, and improve the risk control capabilities of code scanning interactions.
[0060] In this specification, for ease of understanding and distinction, this embodiment uses the following term definitions:
[0061] QR code: The main body of QR code encoding refers to a data graphic structure with certain encoding rules. It usually consists of an encoded data area, a locator module, a fault-tolerant area, a format information area, etc. It is a logical encoding carrier that can be used to represent content such as URLs, identifiers or encrypted information.
[0062] QR code standard logical architecture: refers to the structural model derived from the QR code generation parameters (including version number, error correction level, module size and margin parameters) in accordance with the international QR code standards (such as ISO / IEC 18004:2015). It is used to describe the module-level functional distribution and logical coordinate framework of the QR code, serving as the basic reference for generating QR code images and constructing disturbance injection areas.
[0063] QR Code Image: refers to the graphical representation of a QR code during its generation or display, specifically the image data generated by rendering the QR code structure and the perturbation layer. The QR code image is the actual visual representation that users recognize by scanning the code.
[0064] Perturbation layer logical structure: refers to the perturbation layer logical structure generated based on perturbation parameters, perturbation type and injection intensity level. It defines the injection rules, perturbation area and perturbation method of the perturbation element. It has not yet been integrated with the standard logical structure of the QR code to form an image entity.
[0065] Perturbation layer: refers to the layer content constructed according to the perturbation layer logical structure and superimposed on the standard logical structure of the QR code during the QR code image generation stage.
[0066] Figure 1 This is a flow chart of a code scanning authenticity verification method according to an exemplary embodiment of the present application. Figure 1 As shown, the code scanning authenticity verification method provided in this embodiment includes:
[0067] S101. Generate a perturbation layer logical structure. Before generating a QR code image, dynamically configure the perturbation type and perturbation injection intensity level based on perturbation parameters according to a perturbation type selection mechanism. Combined with the perturbation injection strategy, generate a perturbation layer logical structure. Based on the perturbation layer logical structure, construct the corresponding expected perturbation structure features.
[0068] In this embodiment, the perturbation layer logical structure generation step includes perturbation parameter initialization, dynamic configuration of perturbation type and injection intensity level, screening of candidate perturbation injection areas, construction of the perturbation layer logical structure, and encapsulation of expected perturbation structure features. Specifically, perturbation parameters are first obtained before the QR code image is generated. The perturbation type and injection intensity level are dynamically determined through a perturbation type selection mechanism and an injection intensity selection mechanism based on the QR code usage type and perturbation level. Subsequently, the effective structural bounding box of the QR code is derived based on the standard logical structure of the QR code, and the non-perturbable areas are eliminated according to the functional module distribution rules, and the remaining areas are marked as candidate perturbation injection areas. On this basis, based on the configured perturbation type and injection intensity level, combined with the preset perturbation injection strategy, the perturbation layer logical structure is constructed. The expected position set of the dot matrix perturbation element, the element coordinate offset vector set, and the watermark perturbation layer feature parameter set field are constructed to form the expected perturbation structure features for the subsequent QR code image generation and authenticity verification process.
[0069] S102, generating a QR code image. In the QR code image generation stage, a disturbance layer is generated based on the disturbance layer logical structure, and the disturbance layer is integrated with the QR code standard logical structure to generate a QR code image including the disturbance layer.
[0070] In this embodiment, the QR code image generation stage is based on the established perturbation layer logical structure and the QR code standard logical structure, through layer rendering and image synthesis operations, to generate a QR code image containing a perturbation layer for subsequent QR code image authenticity verification. Specifically, it includes:
[0071] When the disturbance type is high-frequency interference dot matrix disturbance, a pseudo-random primitive generation algorithm is used based on the expected position set of the dot matrix disturbance primitives to render the grayscale disturbance dot matrix layer in the center area of the image.
[0072] When the perturbation type is pixel-level offset perturbation, during the rendering of the standard logical structure of the QR code, a pixel-level offset of a specified direction and amplitude is applied to some primitives to generate an image output after the structure is offset.
[0073] When the disturbance type is semi-transparent watermark disturbance, the corresponding pattern resource is loaded from the watermark template library according to the transparency setting value and the complexity of the superimposed pattern, and the superimposed watermark layer is generated by combining the set layer area through layer blending technology (such as alpha blending and transparency fusion).
[0074] Finally, layer fusion mechanisms (such as image channel overlay and transparency synthesis) are used to fuse the perturbed layer with the standard logical structure of the QR code at the image level, outputting a QR code image with perturbation features. This image not only meets the requirements for code scanning and recognition, but also contains structured perturbation information, which can be used in subsequent QR code image authenticity verification processes.
[0075] S103, QR code image acquisition and target perturbation structure construction, the target QR code is scanned by the user end, the target QR code image is extracted and the corresponding target perturbation structure features are constructed.
[0076] In this embodiment, a QR code image scanning module with the ability to recognize perturbation layers is deployed in user-side applications (such as mini-programs and App clients) to perform real-time acquisition and perturbation structure feature extraction operations on the target QR code image while the user is scanning the target QR code.
[0077] Specifically, the user first calls the device camera to obtain image frame data during the QR code scanning process, and uses the QR code detection and positioning algorithm (such as WeChat QR code scanning SDK, OpenCV) to extract the target QR code image from the image frame.
[0078] Then, after the target QR code image is extracted, the target disturbance structure features corresponding to the target QR code image are extracted by using image edge detection, sub-pixel offset estimation, and frequency domain texture analysis image processing technology, including:
[0079] Observation position set of dot matrix perturbation element: When there are regularly distributed high-frequency grayscale perturbation points in the target QR code image, their grayscale features and spatial positions are extracted to construct the observation position set of the dot matrix element.
[0080] Observation offset vector set of primitive coordinates: When there is a local pixel offset feature at the primitive boundary in the target QR code image, the logical position, offset amplitude and perturbation direction of the disturbed primitive are extracted to construct the observation vector set of the primitive offset;
[0081] Watermark perturbation layer observation parameter set: When the visible overlay layer in the target QR code image has watermark pattern characteristics, the layer transparency setting value, superimposed pattern complexity and layer area setting value are extracted to construct the observation parameter set of the watermark perturbation layer.
[0082] Finally, the above feature information will be uniformly encapsulated as the target disturbance structure feature, and used as the data basis for the subsequent QR code image authenticity comparison, and compared with the expected disturbance structure feature for authenticity verification.
[0083] S104: Verify the authenticity of the QR code image. Based on the unique identifier of the perturbation layer corresponding to the target QR code, extract the expected perturbation structure features stored on the server. According to the consistency comparison strategy, compare the target perturbation structure features with the expected perturbation structure features to obtain an authenticity score. According to the authenticity determination rules, judge the authenticity of the target QR code.
[0084] In this embodiment, after constructing the target perturbation structure feature, the corresponding perturbation structure feature is retrieved from the platform database based on the unique identifier of the perturbation layer corresponding to the target QR code, and the authenticity score is obtained according to the consistency comparison strategy.
[0085] The consistency comparison strategy includes: calculating the consistency score of the disturbed dot matrix element position, the element offset vector matching score and the watermark layer matching score respectively, and generating the authenticity score by weighted average method.
[0086] The calculation formula for the perturbation dot matrix element position consistency score is:
[0087]
[0088] in, is the coordinate set of the lattice perturbation element in the expected perturbation structure feature; is the coordinate set of the lattice perturbation primitives in the target perturbation structure feature.
[0089] The calculation formula for the primitive offset vector matching score is:
[0090]
[0091] Where N is the number of primitives involved in the perturbation; is the parameter value of the i-th element in the target perturbation structure feature, is the parameter value of the i-th element in the expected disturbance structure feature; When the parameter value in the target disturbance structure feature is consistent with the parameter value in the expected disturbance structure feature, the function value is 1, otherwise the function value is 0.
[0092] The calculation formula for the watermark layer matching score is:
[0093]
[0094] in, Set the transparency value for the layer in the target disturbance structure feature; Set the value for the transparency of the layer in the expected disturbance structure feature; Setting a value for the complexity of the superimposed pattern in the target perturbation structure feature; Setting a value for the complexity of the superimposed pattern in the expected perturbation structure features; The layer area setting value in the target disturbance structure feature; Set a value for the area of the layer in the expected disturbance structure feature; is the normalization function, which is calculated as ; Need to meet .
[0095] The final authenticity score is calculated by weighted average by fusing the perturbed dot matrix element position consistency score, the element offset vector matching score and the watermark layer matching score.
[0096] The formula for calculating the authenticity score is:
[0097]
[0098] in, 、 、 is the disturbance type weight, which must satisfy .
[0099] The authenticity determination rules include:
[0100] When the disturbance authenticity score is greater than or equal to a preset credibility threshold, the target two-dimensional code image is determined to be an authentic scan code;
[0101] When the disturbance authenticity score is greater than or equal to the preset untrustworthy threshold and less than the preset trustworthy threshold, the target QR code image is determined to be a medium-trustworthy scan code, triggering secondary verification;
[0102] When the disturbance authenticity score is less than a preset untrustworthy threshold, the target QR code image is determined to be a suspected forged scan code, triggering an alarm and restricting business operations.
[0103] The authenticity verification of QR code images can achieve the trusted traceability of the target QR code image and accurately judge the authenticity of the interactive behavior.
[0104] Figure 2 This is a flow chart of generating a disturbance layer logic structure according to an example embodiment of the present application. Figure 2 As shown, the disturbance layer generation process provided in this embodiment includes:
[0105] S1011. Initializing the disturbance parameters before generating the two-dimensional code image.
[0106] In this embodiment, the disturbance parameters include:
[0107] Perturbation layer unique identifier: a unique number used to identify the perturbation layer. Each time a QR code image with a perturbation structure is generated, a corresponding perturbation layer unique identifier is generated.
[0108] QR code usage type: used to indicate the business scenario for which the QR code is used. It is one of the criteria for determining the disturbance type selection mechanism. It includes static display codes, dynamic refresh codes, lottery or event codes, internal codes for jumps, and high-risk verification codes. The details are as follows:
[0109] Static display codes are QR codes that are displayed publicly for a long time, such as store poster QR codes and brochure distribution codes.
[0110] Dynamic refresh codes are QR codes that change in real time, such as login authorization QR codes and dynamic bill verification codes.
[0111] A lottery or activity code is a QR code used by users to participate in interactive activities, such as a sweepstakes participation code or a holiday points redemption code.
[0112] Internal redirect codes are QR codes used for internal logic purposes such as page redirection and content binding. For example, a QR code on a product package redirects to the product details page, or a QR code redirects to an internal platform page. The perturbation level for internal redirect codes can only be set to light.
[0113] High-risk verification codes are QR codes that involve user permission verification or sensitive information access, such as payment authorization QR codes for financial operations and user real-name authentication QR codes. The perturbation level for these high-risk verification codes can only be set to strong.
[0114] Perturbation Level: This value indicates the intensity level of the perturbation layer that should be used for the QR code image. It is one of the criteria used in the perturbation type selection mechanism, including:
[0115] Light disturbance: The disturbance intensity is relatively weak, and the efficiency of QR code scanning and decoding is prioritized. It is suitable for scenarios that are sensitive to QR code scanning speed.
[0116] Medium disturbance: The disturbance intensity is moderate. It introduces interference structure without significantly affecting the QR code scanning performance. It is suitable for use scenarios with active QR codes and medium security requirements.
[0117] Strong disturbance: The disturbance intensity is relatively high, which mainly ensures the authenticity and anti-counterfeiting effect of the QR code. It is suitable for high-risk business scenarios involving account verification, fund operations, etc.
[0118] S1012: Based on the disturbance parameters, execute a disturbance type selection mechanism to dynamically configure the disturbance type.
[0119] In this embodiment, the disturbance type is dynamically configured after the disturbance parameter initialization is completed.
[0120] The disturbance types include high-frequency interference dot matrix disturbance, pixel-level offset disturbance and semi-transparent watermark disturbance.
[0121] The disturbance type selection mechanism includes:
[0122] When the QR code usage type is set to static display code and the perturbation level is set to light, configure the perturbation type to semi-transparent watermark perturbation. This is used to enhance the verifiability and structural recognizability of the QR code image without interfering with the code scanning and recognition performance.
[0123] When the QR code usage type is identified as a static display code and the perturbation level is medium or strong, the configured perturbation type is a combined perturbation structure that includes high-frequency interference dot matrix perturbation and semi-transparent watermark perturbation. This perturbation type acts on the central area and underlying background area of the QR code image, significantly enhancing the anti-counterfeiting capabilities and image verifiability of the perturbation layer without affecting the code's readability.
[0124] When the QR code usage type is identified as a dynamic refresh code, the perturbation type is configured as pixel-level offset perturbation. Small coordinate perturbations (e.g., ±0.5 to ±1 pixel) are injected into the boundaries of the QR code image's primitives to effectively enhance the uniqueness and non-reproducibility of the perturbation layer, thereby protecting against risks such as screenshots and image forgeries, while ensuring that code scanning and recognition efficiency is not significantly affected.
[0125] When the QR code usage type is marked as a lottery or event code, configure the perturbation type as a semi-transparent watermark perturbation. This perturbation type is used to overlay template elements such as brand logos and event patterns on the bottom layer of the QR code image to enhance the QR code image's attribution verification capabilities and visual cueing effect.
[0126] When the QR code usage type is identified as internal code for jump, the perturbation type is configured as pixel-level offset perturbation. This perturbation type introduces low-amplitude coordinate perturbations at the boundary elements of the QR code image, enhancing the uniqueness and authenticity of the QR code image in a low-interference manner.
[0127] When the QR code usage type is identified as a high-risk verification code, the configured perturbation type is a combined perturbation structure consisting of high-frequency interference dot matrix perturbation, pixel-level offset perturbation, and semi-transparent watermark perturbation. This perturbation type acts on the central area, primitive boundary areas, and bottom layer of the QR code image, creating a triple perturbation mechanism of frequency domain perturbation, structural perturbation, and layer watermarking to comprehensively improve the anti-counterfeiting capability and authenticity verifiability of the QR code image.
[0128] It should be noted that when the QR code usage type is identified as a dynamic refresh code, its disturbance type is configured as pixel-level offset disturbance regardless of whether the disturbance level is light disturbance, medium disturbance or strong disturbance.
[0129] When the QR code usage type is identified as a lottery or activity code, the disturbance type is configured as semi-transparent watermark disturbance regardless of whether the disturbance level is light disturbance, medium disturbance or strong disturbance.
[0130] By initializing the perturbation parameters and dynamically configuring the perturbation type, it is possible to maximize the anti-counterfeiting and recognizability of the QR code image without affecting the scanning success rate.
[0131] S1013. Based on the disturbance parameters, execute an injection intensity selection mechanism to dynamically configure a disturbance injection intensity level.
[0132] In this embodiment, the disturbance injection intensity level is used to represent the intensity control parameter of the disturbance layer, including the first-level injection intensity, the second-level injection intensity, and the third-level injection intensity.
[0133] Level 1 injection intensity is the lowest level of disturbance injection and is suitable for scenarios with high requirements for scanning efficiency and low disturbance requirements.
[0134] The second-level injection intensity is a medium-level disturbance injection, which takes into account the recognizability of the QR code image and the disturbance security, and is suitable for general interactive QR code scenarios.
[0135] Level 3 injection intensity is the highest level of disturbance injection and is mainly used in scenarios with high requirements for authenticity verification of QR code images and strong security requirements.
[0136] The injection intensity selection mechanism includes:
[0137] When the QR code usage type is identified as a static display code and the disturbance level is light disturbance, the disturbance injection intensity level is level 2 injection intensity;
[0138] When the QR code usage type is identified as a static display code and the disturbance level is medium disturbance or strong disturbance, the disturbance injection intensity level is level 3 injection intensity;
[0139] When the QR code usage type is identified as dynamic refresh code and the disturbance level is light disturbance, the disturbance injection intensity level is level one injection intensity;
[0140] When the QR code usage type is identified as dynamic refresh code and the disturbance level is medium disturbance, the disturbance injection intensity level is level 2 injection intensity;
[0141] When the QR code usage type is identified as dynamic refresh code and the disturbance level is strong disturbance, the disturbance injection intensity level is level 3 injection intensity;
[0142] When the QR code usage type is identified as a lottery or activity code and the disturbance level is light disturbance, the disturbance injection intensity level is level one injection intensity;
[0143] When the QR code usage type is identified as a lottery or activity code and the disturbance level is medium disturbance, the disturbance injection intensity level is level 2 injection intensity;
[0144] When the QR code usage type is identified as a lottery or activity code and the disturbance level is medium disturbance, the disturbance injection intensity level is level 2 injection intensity;
[0145] When the QR code usage type is identified as a lottery or activity code and the disturbance level is strong disturbance, the disturbance injection intensity level is level three injection intensity;
[0146] When the QR code usage type is identified as internal code for jump, the disturbance injection intensity level is level one;
[0147] When the QR code usage type is identified as a high-risk verification code, the disturbance injection intensity level is level three injection intensity.
[0148] S1014: Determine a valid structural bounding box of the QR code based on the standard logical structure of the QR code, remove the QR code functional module area accordingly, and mark the remaining area as a candidate disturbance injection area.
[0149] In this embodiment, after completing the dynamic configuration of the disturbance type and the disturbance injection intensity level, the labeling operation of the candidate disturbance injection area is performed based on the standard logical structure of the QR code, aiming to identify the spatial area in the QR code image that can be used for disturbance injection.
[0150] The standard logical structure of the QR code can be deterministically derived and constructed according to the QR code image generation parameters, including version number, error correction level, module size and margin width, in accordance with the international standard for QR codes (such as ISO / IEC 18004:2015).
[0151] Specifically, first, a valid structural bounding box of the QR code is determined by a grid deduction method, which is used to define the outermost boundary range of the QR code in the standard logical structure of the QR code.
[0152] Then, according to the functional module distribution rules defined in the QR code international standard (such as ISO / IEC 18004:2015), the QR code functional module area that cannot be disturbed is identified as the reserved area, including:
[0153] The locator module area is used for image positioning and geometric correction. The number is fixed at 3, located at the upper left corner, upper right corner and lower left corner of the QR code respectively. Each locator consists of a 7×7 module.
[0154] The format information area is located in the strip area between each locator module and is used to store error correction level and mask information.
[0155] The version information area appears when the QR code version number is greater than or equal to 7. It is located in the area adjacent to the upper right and lower left corners of the QR code and is used to store version number information.
[0156] The error correction code block area is distributed in multiple fixed position blocks inside the QR code and is used for fault tolerance and recovery functions.
[0157] The encoded data edge buffer is located in several module rows or columns near the boundary of the QR code, which is used to buffer disturbance interference and ensure the stability of the graphic element structure.
[0158] According to the QR code version and the standard logical structure of the QR code, the QR code functional module area is accurately marked through the derivation of grid coordinate offsets and uniformly marked as a reserved area.
[0159] S1015. Based on the configured disturbance type and injection intensity level, a disturbance layer logical structure is constructed according to the disturbance injection strategy.
[0160] In this embodiment, after the candidate disturbance injection areas are marked, the final disturbance map area is screened out from the candidate disturbance injection areas based on the configured disturbance type and injection intensity level and the disturbance injection strategy, and a disturbance map logical structure is constructed.
[0161] The disturbance injection strategy includes:
[0162] When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level one, 30% of the image center area is selected, the dot matrix spacing is 32px, and the dot matrix grayscale value range is 128~144.
[0163] When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level 2, 40% of the image center area is selected, the dot matrix spacing is 24px, and the dot matrix grayscale value range is 128~152.
[0164] When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level 3, 50% of the image center area is selected, the dot matrix spacing is 16px, and the dot matrix grayscale value range is 128~160.
[0165] When the perturbation type is pixel-level offset perturbation and the injection intensity level is level one, 10% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±0.5px, and the perturbation direction is horizontal or vertical.
[0166] When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 2, 20% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±1px, and the perturbation direction is horizontal or vertical.
[0167] When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 3, 30% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±1.5px, and the perturbation direction is horizontal or vertical.
[0168] When the disturbance type is semi-transparent watermark disturbance and the injection intensity level is level one, the watermark transparency is 20%, the superimposed pattern complexity is a simple icon, and the layer area is the main area.
[0169] When the disturbance type is semi-transparent watermark disturbance and the injection intensity level is level 2, the watermark transparency is 35%, the complexity of the superimposed pattern is the brand icon, and the layer area is the bottom layer of the entire image.
[0170] When the disturbance type is semi-transparent watermark disturbance and the injection intensity level is level three, the watermark transparency is selected as 50%, the superimposed pattern complexity is a multi-element pattern, and the layer area is the entire bottom layer.
[0171] It should be noted that when the selected perturbation type is a combined perturbation structure (for example, including both high-frequency interference dot matrix perturbation and semi-transparent watermark perturbation), a corresponding perturbation layer logical structure is constructed for each subtype within the perturbation type. The perturbation layer logical structures corresponding to each subtype are integrated into the final perturbation layer logical structure for subsequent perturbation layer generation and expected perturbation structure feature encapsulation.
[0172] S1016. Based on the disturbance layer logic structure and the QR code standard logic structure, the expected disturbance structure features are structurally encapsulated.
[0173] In this embodiment, based on the cross-analysis results of the perturbation layer logical structure and the standard logical structure of the QR code, and by structurally encapsulating each field in the expected perturbation structure feature, a complete expected perturbation structure feature is constructed to support the authenticity verification of the subsequent target QR code image.
[0174] Expected disturbance structure characteristics, including:
[0175] Expected position set of dot matrix perturbation elements: When the perturbation type is high-frequency interference dot matrix perturbation, the corresponding injection ratio, dot matrix spacing and image center area division standard are obtained from the perturbation injection strategy according to the injection intensity level. The logical position of the perturbation element is selected in the candidate perturbation injection area and structured and recorded as the expected position set of dot matrix perturbation elements for subsequent authenticity verification of the QR code image.
[0176] Element coordinate offset vector set: When the perturbation type is pixel-level offset perturbation, the corresponding injection element selection ratio, offset amplitude and perturbation direction are obtained from the perturbation injection strategy based on the injection intensity level, and the logical position, offset amplitude and perturbation direction of the selected perturbation element are structured and recorded as an element coordinate offset vector set for subsequent authenticity verification of the QR code image.
[0177] Watermark perturbation layer feature parameter set: When the perturbation type is semi-transparent watermark perturbation, the corresponding layer transparency setting value, superimposed pattern complexity and layer area setting value are obtained from the perturbation injection strategy according to the injection intensity level, and are structured and recorded as parameters of the watermark perturbation layer for subsequent authenticity verification of the QR code image.
[0178] Finally, the above fields are uniformly encapsulated into structured expected disturbance structure features, bound to the unique identifier of the disturbance layer corresponding to the QR code, and stored in the database or platform cache for subsequent authenticity verification of the target QR code image.
[0179] Figure 3 This is a schematic diagram of the structure of a code scanning authenticity verification system according to an exemplary embodiment of the present application. Figure 3 As shown, the code scanning authenticity verification system 300 provided in this embodiment includes:
[0180] The perturbation layer logical structure generation module 301 dynamically configures the perturbation type and perturbation injection intensity level based on the perturbation parameters according to the perturbation type selection mechanism before generating the QR code image, generates a perturbation layer logical structure in combination with the perturbation injection strategy, and constructs the corresponding expected perturbation structure features based on the perturbation layer logical structure.
[0181] The QR code image generation module 302 generates a perturbation layer based on the perturbation layer logical structure during the QR code image generation phase, and fuses the perturbation layer with the QR code standard logical structure to generate a QR code image including the perturbation layer.
[0182] The QR code image acquisition and target disturbance structure construction module 303 extracts the target QR code image and constructs the corresponding target disturbance structure features by scanning the target QR code through the user terminal;
[0183] The QR code image authenticity verification module 304 extracts the expected perturbation structure features stored on the server based on the unique identifier of the perturbation layer corresponding to the target QR code, compares the target perturbation structure features with the expected perturbation structure features according to the consistency comparison strategy to obtain an authenticity score, and determines the authenticity of the target QR code according to the authenticity determination rules.
[0184] Figure 4 FIG. 1 is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present application. Figure 4 As shown, this embodiment provides an electronic device 400 including: a processor 401 and a memory 402; wherein:
[0185] The memory 402 is used to store computer programs. The memory may also be a flash memory.
[0186] The processor 401 is configured to execute the execution instructions stored in the memory to implement each step in the above method. For details, please refer to the relevant description in the above method embodiment.
[0187] Optionally, the memory 402 may be independent or integrated with the processor 401 .
[0188] When the memory 402 is a device independent of the processor 401, the electronic device 400 may further include:
[0189] The bus 403 is used to connect the memory 402 and the processor 401 .
[0190] This embodiment further provides a readable storage medium, in which a computer program is stored. When at least one processor of an electronic device executes the computer program, the electronic device executes the methods provided in the various aforementioned embodiments.
[0191] This embodiment further provides a program product, which includes a computer program stored in a readable storage medium. At least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor can execute the computer program to cause the electronic device to implement the methods provided in the various embodiments described above.
[0192] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered merely as exemplary, and the true scope and spirit of the present application are indicated by the claims.
[0193] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A code scanning authenticity verification method, characterized in that: include: Perturbation layer logical structure generation: before the QR code image is generated, the perturbation type and perturbation injection intensity level are dynamically configured based on the perturbation parameters according to the perturbation type selection mechanism, the perturbation layer logical structure is generated in combination with the perturbation injection strategy, and the corresponding expected perturbation structure features are constructed based on the perturbation layer logical structure; QR code image generation: in the QR code image generation stage, a disturbance layer is generated based on the disturbance layer logical structure, and the disturbance layer is integrated with the QR code standard logical structure to generate a QR code image including the disturbance layer; QR code image acquisition and target perturbation structure construction: the user terminal scans the target QR code, extracts the target QR code image and constructs the corresponding target perturbation structure features; The authenticity verification of the QR code image is based on the unique identifier of the perturbation layer corresponding to the target QR code. The expected perturbation structure features stored on the server are extracted. According to the consistency comparison strategy, the target perturbation structure features are compared with the expected perturbation structure features to obtain an authenticity score. According to the authenticity judgment rules, the authenticity of the target QR code is judged.
2. The code scanning authenticity verification method according to claim 1, characterized in that: The disturbance parameters include the unique identifier of the disturbance layer, the type of QR code usage, and the disturbance level; The types of QR code usage include static display codes, dynamic refresh codes, lottery or event codes, internal codes for jumps, and high-risk verification codes; The disturbance levels include light disturbance, medium disturbance and strong disturbance.
3. The code scanning authenticity verification method according to claim 1, characterized in that: The disturbance types include high-frequency interference dot matrix disturbance, pixel-level offset disturbance and semi-transparent watermark disturbance; The disturbance injection intensity levels include primary injection intensity, secondary injection intensity and tertiary injection intensity.
4. The code scanning authenticity verification method according to claim 1, characterized in that: The generation of the disturbance layer logical structure includes: Performing the initialization operation of the perturbation parameters before generating the QR code image; Based on the disturbance parameters, executing a disturbance type selection mechanism to dynamically configure the disturbance type; Based on the disturbance parameters, executing an injection intensity selection mechanism to dynamically configure a disturbance injection intensity level; Determine the effective structural bounding box of the QR code based on the standard logical structure of the QR code, and accordingly remove the QR code functional module area, and mark the remaining area as the candidate disturbance injection area; Based on the configured disturbance type and injection intensity level, the disturbance layer logical structure is constructed according to the disturbance injection strategy; Based on the perturbation layer logical structure and the QR code standard logical structure, the expected perturbation structure features are structurally encapsulated.
5. The code scanning authenticity verification method according to claim 2, characterized in that: The disturbance type selection mechanism includes: When the QR code usage type is identified as a static display code and the disturbance level is light disturbance, the disturbance type is configured as semi-transparent watermark disturbance; When the QR code usage type is identified as a static display code and the disturbance level is medium disturbance or strong disturbance, the disturbance type is configured as a combined disturbance structure including high-frequency interference dot matrix disturbance and semi-transparent watermark disturbance; When the QR code usage type is identified as a dynamic refresh code, the perturbation type is configured as pixel-level offset perturbation; When the QR code usage type is identified as a lottery or activity code, the disturbance type is configured as a semi-transparent watermark disturbance; When the QR code usage type is identified as an internal code for jump, the perturbation type is configured as pixel-level offset perturbation; When the usage type of the two-dimensional code is identified as a high-risk verification code, the configured disturbance type is a combined disturbance structure including high-frequency interference dot matrix disturbance, pixel-level offset disturbance and semi-transparent watermark disturbance.
6. The code scanning authenticity verification method according to claim 3, characterized in that: The disturbance injection strategy includes: When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level one, 30% of the image center area is selected, the dot matrix spacing is 32px, and the dot matrix grayscale value range is 128~144; When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level 2, 40% of the image center area is selected, the dot matrix spacing is 24px, and the dot matrix grayscale value range is 128~152; When the disturbance type is high-frequency interference dot matrix disturbance and the injection intensity level is level 3, 50% of the image center area is selected, the dot matrix spacing is 16px, and the dot matrix grayscale value range is 128~160; When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 1, 10% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±0.5px, and the perturbation direction is horizontal or vertical; When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 2, 20% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±1px, and the perturbation direction is horizontal or vertical; When the perturbation type is pixel-level offset perturbation and the injection intensity level is level 3, 30% of the pixels are randomly selected from the pixel boundary area, the offset amplitude is ±1.5px, and the perturbation direction is horizontal or vertical; When the perturbation type is semi-transparent watermark perturbation and the injection intensity level is level one, the watermark transparency is set to 20%, the superimposed pattern complexity is set to simple icon, and the layer area is the main area; When the perturbation type is semi-transparent watermark perturbation and the injection intensity level is level 2, the watermark transparency is set to 35%, the superimposed pattern complexity is the brand icon, and the layer area is the entire bottom layer of the image; When the disturbance type is semi-transparent watermark disturbance and the injection intensity level is level three, the watermark transparency is selected as 50%, the superimposed pattern complexity is a multi-element pattern, and the layer area is the entire bottom layer.
7. The code scanning authenticity verification method according to claim 1, characterized in that: The consistency comparison strategy includes: calculating the consistency score of the disturbed dot matrix element position, the element offset vector matching score and the watermark layer matching score respectively, and generating the authenticity score by weighted average method.
8. A code scanning authenticity verification system, characterized in that: include: A disturbance layer logical structure generation module dynamically configures the disturbance type and disturbance injection intensity level based on the disturbance parameters according to the disturbance type selection mechanism before generating the QR code image, generates the disturbance layer logical structure in combination with the disturbance injection strategy, and constructs the corresponding expected disturbance structure features based on the disturbance layer logical structure; A QR code image generation module generates a disturbance layer based on the disturbance layer logical structure during the QR code image generation phase, fuses the disturbance layer with the QR code standard logical structure, and generates a QR code image including the disturbance layer; The QR code image acquisition and target perturbation structure construction module extracts the target QR code image and constructs the corresponding target perturbation structure features through the user terminal scanning the target QR code; The QR code image authenticity verification module extracts the expected perturbation structure features stored on the server based on the unique identifier of the perturbation layer corresponding to the target QR code. Based on the consistency comparison strategy, it compares the target perturbation structure features with the expected perturbation structure features to obtain an authenticity score, and judges the authenticity of the target QR code based on the authenticity judgment rules.
9. An electronic device, characterized in that: include: processor; as well as, a memory for storing executable instructions of the processor; The processor is configured to perform the method according to any one of claims 1 to 7 by executing the executable instructions.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Patent Citations
Verification code generation method and device, verification code verification method and device and electronic equipment
CN117349817A
Verification code generation method and device, equipment, medium and product
CN119834963A