Two-dimensional code anti-counterfeiting verification method and system based on deep learning and digital watermark

By embedding the digital watermark generated by deep learning in the QR code and using the two-layer generation adversarial network for verification, the identification problem of existing QR code anti-counterfeiting technology in complex environments is solved, and the real-time watermark information is ensured through the synchronous update module, achieving high security and robust QR code anti-counterfeiting verification.

CN119204076BActive Publication Date: 2025-02-28BEIJING LINK TIMES TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411275096.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-02-28
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

The existing QR code anti-counterfeiting technology has poor accuracy and robustness in complex environments, making it difficult to cope with copying and tampering methods, and the system has shortcomings in real-time update and verification of watermark information.

Method used

The QR code anti-counterfeiting verification method based on deep learning and digital watermark is adopted. The hidden digital watermark information is embedded in the QR code image through a two-layer generation adversarial network, and the attack behavior is simulated in a complex environment for verification, and the real-time nature of the watermark information is ensured with the synchronous update module.

Benefits of technology

It improves the security and identification accuracy of QR code anti-counterfeiting, enhances the robustness of the system in different scenarios, ensures real-time update and effectiveness of watermark information, and effectively resists copying and tampering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention discloses a two-dimensional code anti-counterfeiting verification method and system based on deep learning and digital watermark, S1, generating a two-dimensional code image; S2, performing image preprocessing on the two-dimensional code image; S3, inputting the preprocessed two-dimensional code image into the first layer generator of a double-layer generative adversarial network; S4, optimizing the watermark embedding of the first layer generator through adversarial training; S5, storing the generated two-dimensional code image with watermark into a database; S6, inputting the two-dimensional code image to be verified into the second layer generator of the double-layer generative adversarial network; S7, judging the authenticity of the two-dimensional code; S8, the system jumps to a designated verification page; S9, the system regularly updates the digital watermark image; S10, the page provides a super anti-counterfeiting icon; S11, setting an electronic coating area on the product packaging, and the coating contains a digital watermark and / or a verification code value. The present invention improves the security of two-dimensional code anti-counterfeiting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of anti-counterfeiting verification technology, and in particular to a two-dimensional code anti-counterfeiting verification method and system based on deep learning and digital watermarking. Background Art

[0002] In the prior art, QR code anti-counterfeiting mainly relies on the technical means of QR code generation and printing. The anti-counterfeiting ability of the QR code is enhanced by setting complex QR code patterns or combining anti-counterfeiting inks and special materials. Although the security of the QR code can be improved to a certain extent, with the development of technology, the means of counterfeiting are also constantly upgrading, and the difficulty of copying and forging QR codes is gradually decreasing. In addition, the existing QR code anti-counterfeiting technology also has limitations in recognition accuracy and robustness in different scenarios. For example, under complex lighting conditions, different angles or noisy backgrounds, traditional QR code recognition technology is prone to misreading or missing, resulting in a significant reduction in the anti-counterfeiting effect.

[0003] Another anti-counterfeiting method is to enhance the anti-counterfeiting property of the QR code by adding digital watermarking technology. Digital watermarking is a technology that embeds secret information in digital media. However, in existing applications, the application of digital watermarking technology in QR codes still has some technical difficulties. First, how to embed the watermark information covertly into the QR code image without affecting its normal reading is a difficulty; secondly, how to accurately extract the watermark information in a complex environment to ensure that the anti-counterfeiting function of the QR code is not affected is also a problem that needs to be solved urgently.

[0004] In addition, with the diversification of QR code application scenarios, the system needs to have the ability to verify and update watermark information and QR code images in real time to cope with possible security threats in different environments. However, the existing technology still has shortcomings in system updates and maintenance, and cannot guarantee the real-time and effectiveness of watermark information. This leads to the failure of the QR code anti-counterfeiting system in some cases, which in turn affects user experience and information security.

[0005] To sum up, the existing technology has the following main shortcomings: First, the anti-counterfeiting ability of QR codes has gradually weakened with the development of counterfeiting technology, and it is difficult to cope with complex copying and tampering methods; second, the recognition accuracy and robustness of existing anti-counterfeiting technologies in different application scenarios are poor, and they are easily affected by environmental factors; finally, the existing system has deficiencies in the real-time update and verification of watermark information, and cannot effectively respond to dynamically changing security needs. Summary of the invention

[0006] One object of the present invention is to propose a two-dimensional code anti-counterfeiting verification method and system based on deep learning and digital watermarking, which improves the security of two-dimensional code anti-counterfeiting.

[0007] A two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermark according to an embodiment of the present invention comprises the following steps:

[0008] S1, generating two-dimensional code data, and using a two-dimensional code generation module to generate a two-dimensional code image containing original information;

[0009] S2, performing image preprocessing on the two-dimensional code image, including grayscale processing, binarization processing and denoising processing;

[0010] S3, inputting the preprocessed two-dimensional code image into the first-layer generator of the two-layer generative adversarial network, and the first-layer generator embeds the secret digital watermark information into the two-dimensional code image to generate a two-dimensional code image with a watermark;

[0011] S4, using the first layer discriminator to distinguish the QR code image with watermark from the QR code image without watermark, and optimizing the watermark embedding process of the first layer generator through adversarial training to make the watermark information more concealed;

[0012] S5, storing the generated two-dimensional code image with watermark in a database, and simultaneously saving its corresponding original watermark information;

[0013] S6. In the process of QR code anti-counterfeiting verification, the QR code image to be verified is obtained, and the QR code image to be verified is input into the second layer generator of the two-layer generative adversarial network, and the second layer generator simulates attack and tampering behaviors, including adding noise, changing brightness and contrast, to generate a QR code image after simulated attack;

[0014] S7, inputting the QR code image that has undergone the simulated attack into the second-layer discriminator, which extracts watermark information from it and compares it with the original watermark information stored in the database to determine the authenticity of the QR code;

[0015] S8. After the consumer scans the QR code, the system jumps to the designated verification page. A digital watermark is embedded in the background image of the page. The consumer does not need to do any additional operations. The system automatically detects the watermark. If the watermark information is valid and matches the UID, the product or item information is displayed. Otherwise, an error message is displayed.

[0016] S9. The system regularly updates the digital watermark image and sets the synchronization frequency. Every time a consumer scans the QR code, the system checks the timeliness of the watermark image. If the watermark image is within the validity period, it passes the verification. Otherwise, the user is prompted to rescan or contact the merchant.

[0017] S10. The page provides a super anti-counterfeiting icon. After the user clicks it, they can choose one-click verification or upload verification. In the case of one-click verification, the system automatically captures the current screen and uploads it to the server for verification. In the case of upload verification, the user takes a screenshot and uploads it to the server for verification. The server performs watermark detection on the uploaded image and returns the verification result.

[0018] S11. An electronic coating area is set on the product packaging. The coating contains a digital watermark and / or a verification code value. After the user scratches the electronic coating, he / she verifies by taking a photo or entering a verification code value. The system compares the information in the coating with the records in the database. If they are consistent, the verification is passed.

[0019] Optionally, the S1 step includes:

[0020] S11, obtaining an original data set D, wherein the original data set D includes information data I to be encoded and a two-dimensional code generation parameter P q ;

[0021] S12, generating parameter P according to original information data I and QR code q The two-dimensional code generation module is used to encode the data and convert the information data I into a two-dimensional code encoding matrix M. q , the two-dimensional code matrix M q Represented as a two-dimensional matrix, where each element represents a module in the QR code image:

[0022] M q ={m ij} i=1,2,...,n;j=1,2,...,n ;

[0023] Among them, m ij represents the encoding module of the i-th row and j-th column in the QR code image, and n is the resolution of the QR code image;

[0024] S13, based on the two-dimensional code encoding matrix M q A two-dimensional code image Q containing original information is generated according to the two-dimensional code standard specification. The two-dimensional code image Q is a two-dimensional image composed of black and white modules, wherein the black module represents a code with an information bit of 1, and the white module represents a code with an information bit of 0.

[0025] Optionally, the S3 step includes:

[0026] S31, input the two-dimensional code image Q to the first layer generator G1 of the two-layer generative adversarial network, the first layer generator G1 receives the two-dimensional code image Q and the secret digital watermark information W as input, and the first layer generator G1 minimizes the loss function Generate a QR code image with watermark information that is visually similar to the original QR code image:

[0027]

[0028] in, represents the expected value, D1 is the output probability of the first layer discriminator, λ1 is a hyperparameter used to balance visual consistency and watermark privacy, ||·|| F represents the Frobenius norm, representing the generated QR code image Q w The difference between the original QR code image Q;

[0029] S32, the secret digital watermark information W is a set of data generated by an encryption algorithm, and the data W is represented by a two-dimensional matrix that matches the size of the two-dimensional code image, W = {w′ ij} i=1,2,...,n;j=1,2,...,n , where w' ij Represents the watermark information in the i-th row and j-th column of the watermark matrix. The watermark information embedding process is realized by a nonlinear mapping function. The mapping function is realized by adjusting the parameter set θ w Optimize the embedding position and strength of watermark information:

[0030]

[0031] in, is the watermark information finally embedded in the QR code image, σ is the nonlinear activation function, θ w is the set of parameters that control the embedding process;

[0032] S33, the first layer generator G1 is based on the input two-dimensional code image Q and watermark information Generate a watermarked QR code image Q through the adversarial training process w :

[0033]

[0034] Among them, α1 is the factor that controls the watermark embedding strength, tanh is the hyperbolic tangent function, and θ g is the parameter set of the generator;

[0035] S34, through the adversarial training process, using the first layer discriminator D1 in the first layer of the generative adversarial network to generate the generated two-dimensional code image Q w To distinguish the original QR code image Q, the loss function of the first layer discriminator D1 is Defined as:

[0036]

[0037] Among them, D1(Q) is the judgment probability of the first layer discriminator for the real two-dimensional code image Q, D1(Q w ) is the first layer discriminator for the watermarked QR code image Qw The probability of judgment.

[0038] Optionally, the step S6 includes:

[0039] S61, generate a two-dimensional code image Q with a watermark w And its corresponding original watermark information W is stored in the database;

[0040] S62: During the QR code anti-counterfeiting verification process, obtain the QR code image Q to be verified. v , and input the QR code image to be verified into the second layer generator G2 of the two-layer generative adversarial network. The second layer generator G2 v Simulate various attacks and tampering behaviors to generate a QR code image Q′ after the simulated attack v , the simulated attack behavior is expressed as:

[0041] Q′ v =G2(Q v ,θ a )=T noise (Q v ,η)+T brightness (Q v ,ΔB)+T geometry (Q v ,ΔG)+∈(Q v ,λ);

[0042] Among them, θ a is the attack parameter set of the generator, T noise is the noise adding function, η is the noise matrix, T brightness is the function of adjusting brightness and contrast, ΔB is the brightness and contrast adjustment amount, T geometry is the geometric transformation function, ΔG is the geometric transformation parameter, ∈(Q v ,λ) is a fine-tuning function to control randomness and small changes, generating the QR code image Q′ after the simulated attack v ;

[0043] S63, the second layer generator continuously adjusts the attack parameter set to generate a series of two-dimensional code images after simulated attack, so that the generated two-dimensional code image Q′ after simulated attack v A QR code image that approaches a real attack situation;

[0044] S64: Generated QR code image Q′ after simulated attack v The second layer discriminator that will be input into the two-layer generative adversarial network is processed. The loss function of the second layer discriminator is defined as:

[0045]

[0046] Among them, D2(Q wc ) is the second layer discriminator for the compressed and encrypted two-dimensional code image Q stored in the database wc The judgment probability, D2(Q′ v ) is the second layer discriminator for the QR code image Q′ after the simulated attack v The judgment probability, λ2 is the regularization parameter, Dist(Q wc ,Q′ v ) is the distance measurement function between two-dimensional code images, and by optimizing the loss function Optimize the ability to distinguish between real QR code images and attacked QR code images;

[0047] S65, according to the output result of the second layer discriminator D2, compare the compressed and encrypted two-dimensional code image Q stored in the database wc And the QR code image Q′ after the simulated attack v , and finally determine the authenticity of the QR code.

[0048] Optionally, the step S8 includes:

[0049] S81. After the consumer scans the QR code using the terminal device, the system automatically obtains the scanned QR code image Q s and its associated unique identifier UID s , and jump to the designated verification page through the network;

[0050] S82: Embed the pre-generated digital watermark information W in the background image of the verification page b , digital watermark information W b Matching the watermark information W in the QR code image, the generation process of the background image is expressed as:

[0051] B w =G b (B,W b );

[0052] Among them, B w is the background image with the digital watermark embedded, B is the original background image, G b As the background image generator, it is responsible for converting the digital watermark information W b Embedded in background image B;

[0053] S83. When the verification page is loaded, the system automatically calls the watermark detection module to extract the digital watermark information embedded in the background image and compares it with the watermark information W in the scanned QR code image. s To match:

[0054]

[0055] Among them, M(W b ,W s ) represents the distance measurement function between digital watermark information, δ is the matching threshold, if the matching result is 1, it means that the watermark information is matched successfully, if it is 0, it means that the matching fails;

[0056] S84. If the watermark information is successfully matched and the associated unique identifier matches the record in the system database, the system automatically displays the product or item information corresponding to the QR code;

[0057] S85. If the watermark information fails to match, or the unique identifier does not match the database record, the system displays an error message on the verification page to remind consumers that the QR code may be risky.

[0058] Optionally, the step S9 includes:

[0059] S91, the system regularly generates and updates the digital watermark image W t , digital watermark image W t Contains timestamp information, which is used to indicate the time when the watermark image was generated;

[0060] S92, the system sends the updated digital watermark image W to the t Synchronize to the background image of all verification pages and store the associated timestamp information in the system database;

[0061] S93. Each time a consumer scans a QR code, the system automatically extracts the timestamp information T in the digital watermark image currently in use during the verification process. s and compare it with the current system time T c For comparison:

[0062] ΔT=T c -T s ;

[0063] Wherein, ΔT represents the time difference. If the time difference ΔT is within the preset validity period threshold, it means that the watermark image is within the validity period;

[0064] S94, if the time difference ΔT≤θ t , the system continues the anti-counterfeiting verification process, and the verification result will be based on the matching and verification steps in S8;

[0065] S95, if the time difference ΔT>θ t , the system prompts the user that the current watermark image has expired, and the displayed information suggests that the user rescan the QR code or contact the merchant to obtain the latest verification information.

[0066] A QR code anti-counterfeiting verification system based on deep learning and digital watermark, comprising:

[0067] A two-dimensional code generation module is used to generate a two-dimensional code image containing original information, and embed the secret digital watermark information into the two-dimensional code image to generate a two-dimensional code image with a watermark;

[0068] A database module is used to store the generated watermarked QR code image and its corresponding original watermark information, and to regularly update the digital watermark image, including storing timestamp information and synchronization frequency;

[0069] The scanning module is used to obtain the QR code image to be verified, and input the QR code image to be verified into the second layer generator of the two-layer generative adversarial network, simulate various attacks and tampering behaviors, and generate a QR code image after the simulated attack;

[0070] A deep learning module, comprising a two-layer generative adversarial network, wherein the network comprises a first-layer generator and a second-layer generator, for respectively generating a two-dimensional code image with a watermark and a two-dimensional code image subjected to a simulated attack, and a first-layer discriminator and a second-layer discriminator, for distinguishing and verifying the authenticity of the two-dimensional code image;

[0071] The verification module is used to jump to the designated verification page after the consumer scans the QR code, embed a digital watermark in the background image of the page, and automatically perform watermark detection. According to the validity of the watermark information and the match between the unique identifier, the product or item information is displayed or an error message is prompted;

[0072] The synchronization update module is used to regularly generate and update digital watermark images, synchronize the updated digital watermark images to all verification pages, and detect the timeliness of the watermark images.

[0073] The beneficial effects of the present invention are:

[0074] (1) The present invention embeds secret digital watermark information into the QR code image and uses a two-layer generative adversarial network to generate and verify the watermark information, thereby achieving deep encryption and anti-counterfeiting processing of the QR code image. Compared with traditional anti-counterfeiting methods, the present invention can effectively resist the copying and tampering of the QR code. The embedded watermark information is visually difficult to detect and can be accurately extracted and verified in complex environments through a two-layer generative adversarial network model, thereby improving the security of QR code anti-counterfeiting.

[0075] (2) The present invention enhances the recognition accuracy and robustness of the system in different scenarios through the application of a two-layer generative adversarial network. The system simulates various possible attacks and tampering behaviors. Through adversarial training, the generated two-dimensional code image can still maintain a high recognition accuracy in different environments, reducing the risk of misreading and missed reading.

[0076] (3) The present invention introduces a synchronous update module to regularly generate and update digital watermark images and detect the timeliness of watermark images to ensure that the watermark information in the system is always up to date. Each time a consumer scans a QR code, the system will automatically check the validity period of the watermark information to ensure the accuracy of the verification. This not only improves the dynamic anti-counterfeiting capability of the system, but also effectively prevents the verification failure caused by the expiration or tampering of the watermark information. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0078] Figure 1 This is a flow chart of a QR code anti-counterfeiting verification method and system based on deep learning and digital watermarking proposed by the present invention. DETAILED DESCRIPTION

[0079] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.

[0080] refer to Figure 1 , a two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermark, comprising the following steps:

[0081] S1, generating two-dimensional code data, and using a two-dimensional code generation module to generate a two-dimensional code image containing original information;

[0082] S2, performing image preprocessing on the two-dimensional code image, including grayscale processing, binarization processing and denoising processing;

[0083] S3, inputting the preprocessed two-dimensional code image into the first-layer generator of the two-layer generative adversarial network, and the first-layer generator embeds the secret digital watermark information into the two-dimensional code image to generate a two-dimensional code image with a watermark;

[0084] S4, using the first layer discriminator to distinguish the QR code image with watermark from the QR code image without watermark, and optimizing the watermark embedding process of the first layer generator through adversarial training to make the watermark information more concealed;

[0085] S5, storing the generated two-dimensional code image with watermark in a database, and simultaneously saving its corresponding original watermark information;

[0086] S6. In the process of QR code anti-counterfeiting verification, the QR code image to be verified is obtained, and the QR code image to be verified is input into the second layer generator of the two-layer generative adversarial network, and the second layer generator simulates attack and tampering behaviors, including adding noise, changing brightness and contrast, to generate a QR code image after simulated attack;

[0087] S7, inputting the QR code image that has undergone the simulated attack into the second-layer discriminator, which extracts watermark information from it and compares it with the original watermark information stored in the database to determine the authenticity of the QR code;

[0088] S8. After the consumer scans the QR code, the system jumps to the designated verification page. A digital watermark is embedded in the background image of the page. The consumer does not need to do any additional operations. The system automatically detects the watermark. If the watermark information is valid and matches the UID, the product or item information is displayed. Otherwise, an error message is displayed.

[0089] S9. The system regularly updates the digital watermark image and sets the synchronization frequency. Every time a consumer scans the QR code, the system checks the timeliness of the watermark image. If the watermark image is within the validity period, it passes the verification. Otherwise, the user is prompted to rescan or contact the merchant.

[0090] S10. The page provides a super anti-counterfeiting icon. After the user clicks it, they can choose one-click verification or upload verification. In the case of one-click verification, the system automatically captures the current screen and uploads it to the server for verification. In the case of upload verification, the user takes a screenshot and uploads it to the server for verification. The server performs watermark detection on the uploaded image and returns the verification result.

[0091] S11. An electronic coating area is set on the product packaging. The coating contains a digital watermark and / or a verification code value. After the user scratches the electronic coating, he / she verifies by taking a photo or entering a verification code value. The system compares the information in the coating with the records in the database. If they are consistent, the verification is passed.

[0092] In this implementation, step S1 includes:

[0093] S11, obtaining an original data set D, the original data set D including information data I to be encoded and a QR code generation parameter P q ;

[0094] S12, generating parameter P according to original information data I and QR code q Use the QR code generation module to encode data and convert the information data I into a QR code matrix M q , the two-dimensional code matrix M q Represented as a two-dimensional matrix, where each element represents a module in the QR code image:

[0095] M q={m ij} i=1,2,...,n;j=1,2,...,n ;

[0096] Among them, m ij represents the encoding module in the i-th row and j-th column of the QR code image, and n is the resolution of the QR code image;

[0097] S13, based on the two-dimensional code encoding matrix M q A two-dimensional code image Q containing original information is generated according to the two-dimensional code standard specification. The two-dimensional code image Q is a two-dimensional image composed of black and white modules, wherein the black module represents a code with an information bit of 1, and the white module represents a code with an information bit of 0.

[0098] In this implementation, step S3 includes:

[0099] S31, input the two-dimensional code image Q to the first layer generator G1 of the two-layer generative adversarial network, the first layer generator G1 receives the two-dimensional code image Q and the secret digital watermark information W as input, and the first layer generator G1 minimizes the loss function Generate a QR code image with watermark information that is visually similar to the original QR code image:

[0100]

[0101] in, represents the expected value, D1 is the output probability of the first layer discriminator, λ1 is a hyperparameter used to balance visual consistency and watermark privacy, ||·|| F represents the Frobenius norm, representing the generated QR code image Q w The difference between the original QR code image Q;

[0102] S32, the secret digital watermark information W is a set of data generated by an encryption algorithm, and the data W is represented by a two-dimensional matrix that matches the size of the two-dimensional code image, W = {w′ ij} i=1,2,...,n;j=1,2,...,n , where w' ij Represents the watermark information in the i-th row and j-th column of the watermark matrix. The watermark information embedding process is realized by a nonlinear mapping function. The mapping function is realized by adjusting the parameter set θ w Optimize the embedding position and strength of watermark information:

[0103]

[0104] in, is the watermark information finally embedded in the QR code image, σ is the nonlinear activation function, θ w is the set of parameters that control the embedding process;

[0105] S33, the first layer generator G1 is based on the input two-dimensional code image Q and watermark information Generate a watermarked QR code image Q through the adversarial training process w :

[0106]

[0107] Among them, α1 is the factor that controls the watermark embedding strength, tanh is the hyperbolic tangent function, and θ g is the parameter set of the generator;

[0108] S34, through the adversarial training process, using the first layer discriminator D1 in the first layer of the generative adversarial network to generate the generated two-dimensional code image Q w To distinguish the original QR code image Q, the loss function of the first layer discriminator D1 is Defined as:

[0109]

[0110] Among them, D1(Q) is the judgment probability of the first layer discriminator for the real two-dimensional code image Q, D1(Q w ) is the first layer discriminator for the watermarked QR code image Q w The probability of judgment.

[0111] In this implementation, step S6 includes:

[0112] S61, generate a two-dimensional code image Q with a watermark w And its corresponding original watermark information W is stored in the database;

[0113] S62: During the QR code anti-counterfeiting verification process, obtain the QR code image Q to be verified. v , and input the QR code image to be verified into the second layer generator G2 of the two-layer generative adversarial network. The second layer generator G2 v Simulate various attacks and tampering behaviors to generate a QR code image Q′ after the simulated attack v , the simulated attack behavior is expressed as:

[0114] Q′ v =G2(Q v ,θ a )=T noise (Q v ,η)+T brightness (Q v ,ΔB)+T geometry (Q v ,ΔG)+∈(Q v ,λ);

[0115] Among them, θ a is the attack parameter set of the generator, T noise is the noise adding function, η is the noise matrix, T brightness is the function of adjusting brightness and contrast, ΔB is the brightness and contrast adjustment amount, T geometry is the geometric transformation function, ΔG is the geometric transformation parameter, ∈(Q v ,λ) is a fine-tuning function to control randomness and small changes, generating the QR code image Q′ after the simulated attack v ;

[0116] S63, the second layer generator continuously adjusts the attack parameter set to generate a series of two-dimensional code images after simulated attack, so that the generated two-dimensional code image Q′ after simulated attack v A QR code image that approaches a real attack situation;

[0117] S64: Generated QR code image Q′ after simulated attack v The second layer discriminator that will be input into the two-layer generative adversarial network is processed. The loss function of the second layer discriminator is defined as:

[0118]

[0119] Among them, D2(Q wc ) is the second layer discriminator for the compressed and encrypted two-dimensional code image Q stored in the database wc The judgment probability, D2(Q′ v ) is the second layer discriminator for the QR code image Q′ after the simulated attack v The judgment probability, λ2 is the regularization parameter, Dist(Q wc ,Q′ v ) is the distance measurement function between two-dimensional code images, and by optimizing the loss function Optimize the ability to distinguish between real QR code images and attacked QR code images;

[0120] S65, according to the output result of the second layer discriminator D2, compare the compressed and encrypted two-dimensional code image Q stored in the database wc And the QR code image Q′ after the simulated attack v , and finally determine the authenticity of the QR code.

[0121] In this implementation, step S8 includes:

[0122] S81. After the consumer scans the QR code using the terminal device, the system automatically obtains the scanned QR code image Q s and its associated unique identifier UID s , and jump to the designated verification page through the network;

[0123] S82: Embed the pre-generated digital watermark information W in the background image of the verification page b , digital watermark information W b Matching the watermark information W in the QR code image, the generation process of the background image is expressed as:

[0124] B w =G b (B,W b );

[0125] Among them, B w is the background image with the digital watermark embedded, B is the original background image, G b As the background image generator, it is responsible for converting the digital watermark information W b Embedded in background image B;

[0126] S83. When the verification page is loaded, the system automatically calls the watermark detection module to extract the digital watermark information embedded in the background image and compares it with the watermark information W in the scanned QR code image. s To match:

[0127]

[0128] Among them, M(W b ,W s ) represents the distance measurement function between digital watermark information, δ is the matching threshold, if the matching result is 1, it means that the watermark information is matched successfully, if it is 0, it means that the matching fails;

[0129] S84. If the watermark information is successfully matched and the associated unique identifier matches the record in the system database, the system automatically displays the product or item information corresponding to the QR code;

[0130] S85. If the watermark information fails to match, or the unique identifier does not match the database record, the system displays an error message on the verification page to remind consumers that the QR code may be risky.

[0131] In this implementation, step S9 includes:

[0132] S91, the system regularly generates and updates the digital watermark image W t , digital watermark image W t Contains timestamp information, which is used to indicate the time when the watermark image was generated;

[0133] S92, the system sends the updated digital watermark image W to the t Synchronize to the background image of all verification pages and store the associated timestamp information in the system database;

[0134] S93. Each time a consumer scans a QR code, the system automatically extracts the timestamp information T in the digital watermark image currently in use during the verification process. s and compare it with the current system time T c For comparison:

[0135] ΔT=T c -T s ;

[0136] Wherein, ΔT represents the time difference. If the time difference ΔT is within the preset validity period threshold, it means that the watermark image is within the validity period;

[0137] S94, if the time difference ΔT≤θ t , the system continues the anti-counterfeiting verification process, and the verification result will be based on the matching and verification steps in S8;

[0138] S95, if the time difference ΔT>θ t , the system prompts the user that the current watermark image has expired, and the displayed information suggests that the user rescan the QR code or contact the merchant to obtain the latest verification information.

[0139] A QR code anti-counterfeiting verification system based on deep learning and digital watermark, comprising:

[0140] A two-dimensional code generation module is used to generate a two-dimensional code image containing original information, and embed the secret digital watermark information into the two-dimensional code image to generate a two-dimensional code image with a watermark;

[0141] A database module is used to store the generated watermarked QR code image and its corresponding original watermark information, and to regularly update the digital watermark image, including storing timestamp information and synchronization frequency;

[0142] The scanning module is used to obtain the QR code image to be verified, and input the QR code image to be verified into the second layer generator of the two-layer generative adversarial network, simulate various attacks and tampering behaviors, and generate a QR code image after the simulated attack;

[0143] A deep learning module, including a two-layer generative adversarial network, the network includes a first-layer generator and a second-layer generator, which are used to generate a watermarked QR code image and a simulated attacked QR code image, respectively, and a first-layer discriminator and a second-layer discriminator, which are used to distinguish and verify the authenticity of the QR code image;

[0144] The verification module is used to jump to the designated verification page after the consumer scans the QR code, embed a digital watermark in the background image of the page, and automatically perform watermark detection. According to the validity of the watermark information and the match between the unique identifier, the product or item information is displayed or an error message is prompted;

[0145] The synchronization update module is used to regularly generate and update digital watermark images, synchronize the updated digital watermark images to all verification pages, and detect the timeliness of the watermark images.

[0146] Embodiment 1:

[0147] In Example 1, a well-known international supermarket chain introduced a QR code anti-counterfeiting verification system based on deep learning and digital watermark in multiple branches in area A to enhance the anti-counterfeiting ability of high-value goods. High-value goods mainly include imported red wine, luxury watches and high-end electronic products. The system generates and prints a QR code with a hidden digital watermark on the packaging of each product. Consumers can verify the authenticity of the product by scanning the QR code.

[0148] During the trial operation period from July 15 to July 30, 2023, the system conducted anti-counterfeiting verification tests on five branches in Area A. The main goal of the test was to verify the system's recognition accuracy and anti-counterfeiting capabilities under different environmental conditions. The following are specific test scenarios and data analysis.

[0149] Verification test in low-light environment: On July 18, 2023, at 10:30 am, Supermarket A in Area A conducted a verification test on imported red wine in low-light environment. During the test, the lighting equipment in the store was partially damaged, resulting in poor lighting in the scanning area, with the illuminance measured at 80 Lux. The consumer scanned a bottle of French imported red wine worth RMB 1,000, and the system recognized the QR code and extracted the watermark information.

[0150] Data Records:

[0151] QR code scanning time: July 18, 2023 10:32

[0152] Product type: French imported red wine, Scanning environment: Low light (80 Lux), Recognition result: Success

[0153] Watermark matching: Success, Verification time: 2 seconds, Result feedback: The product is authentic.

[0154] Verification test at different scanning angles: On July 19, 2023, at 14:00 in the afternoon, at store B in area A, researchers conducted QR code scanning tests on luxury watches at different angles. Since the angle at which the customer scanned with the mobile phone was tilted by 20 degrees, the researchers recorded the performance of the system in this case.

[0155] Data Records:

[0156] QR code scanning time: July 19, 2023 14:03, Product type: Swiss luxury watches, Scanning environment: Angle deviation (20 degrees), Recognition result: Success, Watermark matching: Success, Verification time: 3 seconds, Result feedback: The product is authentic.

[0157] Verification test under surface wear: On July 20, 2023, at 19:45, when scanning an electronic product, Supermarket C Store found that the QR code area on the packaging surface was slightly worn due to transportation. After the customer scanned the QR code, the system still successfully extracted and verified the watermark information.

[0158] Data record: QR code scanning time: July 20, 2023 19:46, product type: high-end smartphone, scanning environment: QR code surface is worn, recognition result: successful, watermark matching: successful, verification time: 4 seconds, result feedback: the product is authentic.

[0159] Detection and anti-counterfeiting of counterfeit goods: On July 22, 2023, at 15:20 pm, Supermarket Store D received a complaint from a customer claiming that the packaging of the purchased red wine was different from before. The system administrator scanned the QR code of the product and found that the watermark information in the QR code did not match the original watermark stored in the system database. Further investigation revealed that the product was a counterfeit.

[0160] Data record: QR code scanning time: July 22, 2023 15:23, product type: French imported red wine, scanning environment: normal lighting (300Lux), recognition result: failed, watermark matching: failed, verification time: 2 seconds, result feedback: the product is counterfeit.

[0161] Real-time watermark update and detection: On July 25, 2023, the system automatically performed routine updates of digital watermark images. At 10:00 a.m., when a customer at Supermarket E Store scanned the QR code of a luxury watch, the system detected that the watermark information of the QR code had expired. The system prompted the customer to rescan the QR code or contact the store clerk for further verification. After rescanning and using the latest watermark information, the system successfully verified the authenticity of the product.

[0162] Data record: QR code scanning time: July 25, 2023 10:05, Product type: Swiss luxury watches, Scanning environment: normal lighting (300Lux), Recognition result: Failed the first time (expired watermark), succeeded the second time, Watermark matching: failed the first time, succeeded the second time, Verification time: 3 seconds the first time, 2 seconds the second time, Result feedback: The product is authentic.

[0163] In order to prove the effectiveness of the method of the present invention, a comparative test was conducted on the traditional two-dimensional code anti-counterfeiting system and the anti-counterfeiting system of the present invention. The test data are shown in Table 1 below:

[0164] Table 1 Comparison table of test scenario data between traditional two-dimensional code anti-counterfeiting system and the present invention

[0165]

[0166] Through the above data analysis, the method of the present invention significantly improves the success rate of QR code recognition and the verification speed in complex scenarios. In particular, under the conditions of insufficient lighting, skewed scanning angles and wear on the QR code surface, the recognition accuracy of traditional methods is significantly reduced, while the method of the present invention still maintains efficient recognition capabilities. In addition, the system's counterfeit product detection function performs well, which can effectively prevent counterfeit products from entering the circulation link and protect the rights and interests of consumers. Finally, the present invention effectively solves the problem of expired QR codes by updating watermark information in real time, thereby ensuring the reliability and real-time nature of the verification process.

[0167] The present invention embeds secret digital watermark information into the QR code image and uses a two-layer generative adversarial network to generate and verify the watermark information, thereby achieving deep encryption and anti-counterfeiting processing of the QR code image. Compared with traditional anti-counterfeiting methods, the present invention can effectively resist the copying and tampering of the QR code. The embedded watermark information is visually difficult to detect and can be accurately extracted and verified in complex environments through the two-layer generative adversarial network model, thereby improving the security of QR code anti-counterfeiting.

[0168] The present invention enhances the recognition accuracy and robustness of the system in different scenarios through the application of a two-layer generative adversarial network. The system simulates various possible attacks and tampering behaviors. Through adversarial training, the generated two-dimensional code image can still maintain a high recognition accuracy in different environments, reducing the risk of misreading and missed reading.

[0169] The present invention introduces a synchronous update module to regularly generate and update digital watermark images and detect the timeliness of watermark images to ensure that the watermark information in the system is always up to date. Each time a consumer scans a QR code, the system will automatically check the validity period of the watermark information to ensure the accuracy of the verification. This not only improves the dynamic anti-counterfeiting capability of the system, but also effectively prevents verification failures caused by expired or tampered watermark information.

[0170] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A QR code anti-counterfeiting verification method based on deep learning and digital watermark, characterized in that: The steps include: S1, generating two-dimensional code data, and using a two-dimensional code generation module to generate a two-dimensional code image containing original information; S2, performing image preprocessing on the two-dimensional code image; S3, inputting the preprocessed two-dimensional code image into the first-layer generator of the two-layer generative adversarial network, and the first-layer generator embeds the secret digital watermark information into the two-dimensional code image to generate a two-dimensional code image with a watermark; S4, using the first layer discriminator to distinguish the QR code image with watermark from the QR code image without watermark, and optimizing the watermark embedding process of the first layer generator through adversarial training; S5, storing the generated two-dimensional code image with watermark in a database, and simultaneously saving its corresponding original watermark information; S6. During the QR code anti-counterfeiting verification process, the QR code image to be verified is obtained, and the QR code image to be verified is input into the second layer generator of the two-layer generative adversarial network, where the second layer generator simulates attack and tampering behaviors; S7, inputting the QR code image that has undergone the simulated attack into the second-layer discriminator, which extracts watermark information from it and compares it with the original watermark information stored in the database to determine the authenticity of the QR code; S8. After the consumer scans the QR code, the system jumps to the designated verification page. A digital watermark is embedded in the background image of the page. The consumer does not need to do any additional operations. The system automatically detects the watermark. If the watermark information is valid and matches the UID, the product or item information is displayed. Otherwise, an error message is displayed. S9. The system regularly updates the digital watermark image and sets the synchronization frequency. Every time a consumer scans the QR code, the system checks the timeliness of the watermark image. If the watermark image is within the validity period, it passes the verification. Otherwise, the user is prompted to rescan or contact the merchant. S10. The page provides a super anti-counterfeiting icon. After the user clicks it, they can choose one-click verification or upload verification. In the case of one-click verification, the system automatically captures the current screen and uploads it to the server for verification. In the case of upload verification, the user takes a screenshot and uploads it to the server for verification. The server performs watermark detection on the uploaded image and returns the verification result. S11. An electronic coating area is set on the product packaging. The coating contains a digital watermark and / or a verification code value. After the user scratches the electronic coating, he / she verifies by taking a photo or entering a verification code value. The system compares the information in the coating with the records in the database. If they are consistent, the verification is passed.

2. According to claim 1, a two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermarking is characterized in that: The S1 step includes: S11, obtaining an original data set D, wherein the original data set D includes information data I to be encoded and a two-dimensional code generation parameter P q ; S12, generating parameter P according to original information data I and QR code q The two-dimensional code generation module is used to encode the data and convert the information data I into a two-dimensional code encoding matrix M. q , the two-dimensional code matrix M q Represented as a two-dimensional matrix, where each element represents a module in the QR code image: M q ={m ij } i=1,2,...,n;j=1,2,...,n ; Among them, m ij represents the encoding module in the i-th row and j-th column of the QR code image, and n is the resolution of the QR code image; S13, based on the two-dimensional code encoding matrix M q A two-dimensional code image Q containing original information is generated according to the two-dimensional code standard specification. The two-dimensional code image Q is a two-dimensional image composed of black and white modules, wherein the black module represents a code with an information bit of 1, and the white module represents a code with an information bit of 0.

3. According to claim 1, a two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermarking is characterized in that: The S3 step includes: S31, input the two-dimensional code image Q to the first layer generator G1 of the two-layer generative adversarial network, the first layer generator G1 receives the two-dimensional code image Q and the secret digital watermark information W as input, and the first layer generator G1 minimizes the loss function L G1 , generate a QR code image with watermark information and visually similar to the original QR code image: in, represents the expected value, D1 is the output probability of the first layer discriminator, λ1 is a hyperparameter used to balance visual consistency and watermark privacy, ||·|| F represents the Frobenius norm, representing the generated QR code image Q w The difference between the original QR code image Q; S32, the secret digital watermark information W is a set of data generated by an encryption algorithm, and the data W is represented by a two-dimensional matrix that matches the size of the two-dimensional code image, W = {w′ ij } i=1,2,...,n;j=1,2,...,n , where w′ ij Represents the watermark information in the i-th row and j-th column of the watermark matrix. The watermark information embedding process is realized by a nonlinear mapping function. The mapping function is realized by adjusting the parameter set θ w Optimize the embedding position and strength of watermark information: in, is the watermark information finally embedded in the QR code image, σ is the nonlinear activation function, θ w is the set of parameters that control the embedding process; S33, the first layer generator G1 is based on the input two-dimensional code image Q and watermark information Generate a watermarked QR code image Q through the adversarial training process w : Among them, α1 is the factor that controls the watermark embedding strength, tanh is the hyperbolic tangent function, and θ g is the parameter set of the generator; S34, through the adversarial training process, using the first layer discriminator D1 in the first layer of the generative adversarial network to generate the generated two-dimensional code image Q w To distinguish the original QR code image Q, the loss function of the first layer discriminator D1 is Defined as: Among them, D1(Q) is the judgment probability of the first layer discriminator for the real two-dimensional code image Q, D1(Q w ) is the first layer discriminator for the watermarked QR code image Q w The probability of judgment.

4. According to claim 1, a two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermarking is characterized in that: The S6 step includes: S61, generate a two-dimensional code image Q with a watermark w And its corresponding original watermark information W is stored in the database; S62, in the process of two-dimensional code anti-counterfeiting verification, obtain the two-dimensional code image Q to be verified v , and input the QR code image to be verified into the second layer generator G2 of the two-layer generative adversarial network. The second layer generator G2 v Simulate various attacks and tampering behaviors to generate a QR code image Q′ after the simulated attack v , the simulated attack behavior is expressed as: Q′ v =G2(Q v ,θ a )=T noise (Q v ,η)+T brightness (Q v ,ΔB)+T geometry (Q v ,ΔG)+∈(Q v ,λ); Among them, θ a is the attack parameter set of the generator, T noise is the noise adding function, η is the noise matrix, T brightness is the function of adjusting brightness and contrast, ΔB is the brightness and contrast adjustment amount, T geometry is the geometric transformation function, ΔG is the geometric transformation parameter, ∈(Q v ,λ) is a fine adjustment function; S63, the second layer generator continuously adjusts the attack parameter set to generate a series of two-dimensional code images after simulated attack, so that the generated two-dimensional code image Q′ after simulated attack v A QR code image that approaches a real attack situation; S64: Generated QR code image Q′ after simulated attack v The second layer discriminator that will be input into the two-layer generative adversarial network is processed. The loss function of the second layer discriminator is defined as: Among them, D2(Q wc ) is the second layer discriminator for the compressed and encrypted two-dimensional code image Q stored in the database wc The judgment probability, D2(Q′ v ) is the second layer discriminator for the QR code image Q′ after the simulated attack v The judgment probability, λ2 is the regularization parameter, Dist(Q wc ,Q′ v ) is the distance measurement function between two-dimensional code images; S65, according to the output result of the second layer discriminator D2, compare the compressed and encrypted two-dimensional code image Q stored in the database wc And the QR code image Q′ after the simulated attack v , and finally determine the authenticity of the QR code.

5. According to claim 1, a two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermarking is characterized in that: The step S8 comprises: S81. After the consumer scans the QR code using the terminal device, the system automatically obtains the scanned QR code image Q s and its associated unique identifier UID s , and jump to the designated verification page through the network; S82: Embed the pre-generated digital watermark information W in the background image of the verification page b , digital watermark information W b Matching the watermark information W in the QR code image, the generation process of the background image is expressed as: B w =G b (B,W b ); Among them, B w is the background image with the digital watermark embedded, B is the original background image, G b As the background image generator, it is responsible for converting the digital watermark information W b Embedded in background image B; S83. When the verification page is loaded, the system automatically calls the watermark detection module to extract the digital watermark information embedded in the background image and compares it with the watermark information W in the scanned QR code image. s To match: Among them, M(W b ,W s ) represents the distance measurement function between digital watermark information, δ is the matching threshold, if the matching result is 1, it means that the watermark information is matched successfully, if it is 0, it means that the matching fails; S84. If the watermark information is successfully matched and the associated unique identifier matches the record in the system database, the system automatically displays the product or item information corresponding to the QR code; S85. If the watermark information fails to match, or the unique identifier does not match the database record, the system displays an error message on the verification page to remind consumers that the QR code may be risky.

6. According to claim 1, a two-dimensional code anti-counterfeiting verification method based on deep learning and digital watermarking is characterized in that: The S9 step includes: S91, the system regularly generates and updates the digital watermark image W t , digital watermark image W t Contains timestamp information, which is used to indicate the time when the watermark image was generated; S92, the system sends the updated digital watermark image W to the t Synchronize to the background image of all verification pages and store the associated timestamp information in the system database; S93. Each time a consumer scans a QR code, the system automatically extracts the timestamp information T in the digital watermark image currently in use during the verification process. s and compare it with the current system time T c For comparison: ΔT=T c -T s ; Wherein, ΔT represents the time difference. If the time difference ΔT is within the preset validity period threshold, it means that the watermark image is within the validity period; S94, if the time difference ΔT≤θ t , the system continues the anti-counterfeiting verification process, and the verification result will be based on the matching and verification steps in S8; S95, if the time difference ΔT>θ t , the system prompts the user that the current watermark image has expired, and the displayed information suggests that the user rescan the QR code or contact the merchant to obtain the latest verification information.

7. A QR code anti-counterfeiting verification system based on deep learning and digital watermark, characterized in that: include: A two-dimensional code generation module is used to generate a two-dimensional code image containing original information, and embed the secret digital watermark information into the two-dimensional code image to generate a two-dimensional code image with a watermark; A database module is used to store the generated watermarked QR code image and its corresponding original watermark information, and to regularly update the digital watermark image, including storing timestamp information and synchronization frequency; The scanning module is used to obtain the QR code image to be verified, and input the QR code image to be verified into the second layer generator of the two-layer generative adversarial network, simulate various attacks and tampering behaviors, and generate a QR code image after the simulated attack; A deep learning module, comprising a two-layer generative adversarial network, wherein the network comprises a first-layer generator and a second-layer generator, for respectively generating a two-dimensional code image with a watermark and a two-dimensional code image subjected to a simulated attack, and a first-layer discriminator and a second-layer discriminator, for distinguishing and verifying the authenticity of the two-dimensional code image; The verification module is used to jump to the designated verification page after the consumer scans the QR code, embed a digital watermark in the background image of the page, and automatically perform watermark detection. According to the validity of the watermark information and the match between the unique identifier, the product or item information is displayed or an error message is prompted; The synchronization update module is used to regularly generate and update digital watermark images, synchronize the updated digital watermark images to all verification pages, and detect the timeliness of the watermark images.

Citation Information

Patent Citations

  • Image two-dimensional code and preparation method, analysis device and analysis method thereof

    CN112183150A

  • Graphic code decoding method and device, computer equipment and storage medium

    CN114648038A