Face feature extraction-based anti-counterfeiting code generation method
By dynamically generating anti-counterfeiting codes using a lightweight facial feature extraction model and contextual information, the problem of easy copying and replay of anti-counterfeiting codes is solved. This achieves high security and multi-carrier application on low-power devices, reduces computing costs, and enhances the reliability of the anti-counterfeiting system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU CITY BRAIN CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-24
AI Technical Summary
Existing anti-counterfeiting codes are easy to copy, have high computational and storage costs, are not suitable for low-power terminal devices, and static anti-counterfeiting codes are easily replayed and reused, causing anti-counterfeiting to fail.
It adopts a lightweight face feature extraction model, dynamically generates anti-counterfeiting codes by combining context information, extracts face feature embedding vectors through a lightweight neural network model, performs feature encryption and encoding, integrates context parameters and uses an irreversible encryption algorithm to generate a security code, and supports multiple carrier formats.
It achieves high security and low computational cost in anti-counterfeiting code generation, can be deployed on edge devices, effectively resists replay attacks, and has privacy protection and multi-carrier application capabilities.
Smart Images

Figure CN121920403A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of anti-counterfeiting technology, specifically relating to a method for generating anti-counterfeiting codes based on facial feature extraction. Background Technology
[0002] Existing anti-counterfeiting codes (such as barcodes, QR codes, or random serial numbers) are easily copied, resulting in limited anti-counterfeiting effectiveness. Although some technologies have attempted to incorporate biometrics into anti-counterfeiting systems, existing methods generally rely on large-scale deep learning models, which are computationally intensive and have high storage costs, making them unsuitable for deployment on low-power terminal devices.
[0003] In addition, most existing methods generate static anti-counterfeiting codes from fixed biometric features. Once intercepted, these codes can be replayed and reused, thus rendering the anti-counterfeiting measures ineffective. Summary of the Invention
[0004] To overcome the shortcomings of existing technologies, this invention provides a method for generating anti-counterfeiting codes based on facial feature extraction. It utilizes a lightweight facial feature extraction model and combines contextual information to dynamically generate anti-counterfeiting codes, thereby achieving a high-security, low-computing-cost, and edge-deployable anti-counterfeiting code generation method.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A method for generating anti-counterfeiting codes based on facial feature extraction includes the following steps:
[0007] S10, real-time acquisition of user information and user facial images;
[0008] S20: Lightweight feature extraction is performed on the user's face image, and the face feature embedding vector is output after extraction through a lightweight neural network model.
[0009] S30 embeds facial features into vectors for feature encryption and encoding, and outputs a security code after fusing with context parameters obtained from the sensor and performing irreversible encryption operations.
[0010] S40 maps the security code into multiple carrier formats, outputting at least one of QR codes, barcodes, NFC signals, and RFID tags.
[0011] In one possible implementation, the context parameters include light-sensing data, timestamps, device identifiers, or geographic location data.
[0012] In one possible implementation, in S10, an RGB three-channel face image with a height of 128 pixels and a width of 128 pixels is acquired by using a mobile device camera, PC camera, or embedded camera in conjunction with an Ultra small model.
[0013] In one possible implementation, in S20, the lightweight neural network model extraction includes performing pruning on the ResNet-50 model W, including pruning based on the importance score of multi-index fusion of convolutional kernels, quantization based on importance-guided adaptive bit allocation, and knowledge distillation, to form a lightweight face feature extraction model.
[0014] One possible implementation involves pruning based on multi-metric fusion importance scoring using convolutional kernels, including:
[0015] Let the l-th convolutional layer have N l One convolutional kernel: W l ={w l,1 w l,2 , ..., w l,Nl For the i-th convolutional kernel in the l-th layer, w l,i We define three importance measures based on weight strength, BN scaling magnitude, and feature response energy: Where ||·||1 represents the L1 norm of the vector; γ l,i f is the scaling factor for the batch normalization layer; l,i (x) represents the feature response of the convolutional kernel to the input sample x; E x∈D [·] represents the mathematical expectation of a sample x in the training set D;
[0016] The overall importance score is a weighted fusion form: Where α, β, and δ are adjustable coefficients and α + β + δ = 1, the scoring is normalized because the number and scale of convolutional kernels differ in different layers: Next, the scores are globally sorted, and the convolutional kernels and corresponding BN channels with the lowest scores in the bottom 30% are deleted, and the model is reconstructed.
[0017] The score is updated periodically during the training phase and recalculated every K epoch. Where λ∈[0,1] represents the update coefficient. This represents the new score value obtained from the recalculation. Using this dynamic update mechanism, the model can adaptively learn changes in importance during pruning. By reducing redundant convolutional kernels layer by layer through the above pruning method, a sparse network W′ is obtained.
[0018] In one possible implementation, quantization for importance-guided adaptive bit allocation includes:
[0019] The pruned model is further sparsed into a network W′ using adaptive bit allocation quantization, which increases the importance score S of the convolutional kernel. i Binding to quantization bit width: Where τ h ,τ l These are the high importance threshold and the low importance threshold, respectively, bi Each convolutional kernel is quantized independently with a wider bit width, and more bits are allocated to high-importance channels. This minimizes accuracy loss while compressing the model as much as possible. The weight quantization process is as follows: in
[0020] In one possible implementation, knowledge distillation includes:
[0021] Let the ResNet-50 model be used as the teacher network f T (x), the pruned and quantized model is the student network f S (x), joint training, the soft label output by the teacher network is: P T =softmax(z T / τ), the output of the student network is: P S =softmax(z S / τ); Distillation loss function: L=(1-λ)L CE (y,P s )+λτ 2 KL(P T ||P S ), where: L CE τ is the cross-entropy loss; KL is the Kullback-Leibler divergence; τ is the temperature parameter; λ is the distillation weight coefficient. Through multi-objective joint optimization, the pruned and low-bit network relearns the high-precision feature distribution, and finally forms a lightweight face feature extraction model. The lightweight face feature extraction model is used to extract features from the face image I to form the face feature vector F.
[0022] In one possible implementation, the feature encryption and encoding of the face feature embedding vector in S30 includes error correction and fault-tolerant encoding. Specifically, the face feature vector F is introduced into a pre-trained correction mapping matrix C. This correction mapping matrix is obtained by performing linear discriminant analysis (LDA) on a large-scale multi-light, multi-angle dataset. The original features are projected into a noise suppression subspace to maximize the inter-class distance between different people and minimize the intra-class variance of the same person in different environments. The formula for calculating the corrected feature vector F′ is: Where: b is the bias vector, used to center the feature distribution, and the denominator represents L2 normalization to ensure that the feature vector lies on the unit hypersphere and to eliminate the change in vector magnitude caused by differences in illumination intensity.
[0023] The continuous feature vector is then converted into discrete binary feature codes, and fault-tolerant coding is performed using a threshold quantization function with dead zone. For the i-th element f in the correction vector F′... i Its encoding rules are as follows: Where: δ is the fault tolerance threshold, and X is marked as an unstable bit. During the final face comparison, the weighted Hamming distance is calculated, and the system automatically ignores the unstable bits marked as X, only comparing those feature bits with high confidence, i.e., Code. i The eigenvector after the above processing is denoted as K, where the eigenbit is 1.
[0024] In one possible implementation, the fusion of context parameters acquired by the sensor in S30 includes: the system synchronously collecting dynamic parameters related to the usage scenario, including: acquiring light-sensing data L, timestamp T, device unique identifier D (device unique serial number or hardware fingerprint) and geographical location P (latitude and longitude obtained through GPS or base station positioning), and constructing a context vector: C = [L, T, D, P].
[0025] In one possible implementation, feature fusion and encryption in S30 includes:
[0026] The facial feature vector K is fused with the context parameter C using a weighted concatenation method:
[0027] Where α and β are the weights automatically learned by the lightweight attention module;
[0028] The fused feature vector V is input into the SM3 encryption algorithm for SM3 encryption: Code = SM3(V);
[0029] A collision-resistant and irreversible security code is formed with a fixed length of 256 bits.
[0030] The present invention has the following beneficial effects:
[0031] (1) Lightweight face feature extraction can be achieved by using convolutional kernel multi-index fusion importance score pruning, importance-guided adaptive bit allocation quantization, and knowledge distillation. It can achieve efficient face feature extraction on edge devices and significantly reduce computing power requirements compared with traditional large-scale convolutional neural networks.
[0032] (2) The anti-counterfeiting code not only comes from facial features, but also combines contextual parameters (light sensing data, timestamp, device ID, geographical location) to achieve dynamic context fusion, one-time password, effectively resisting replay attacks and forgery.
[0033] (3) Introduce a fuzzy extractor and error correction coding technology to ensure that stable and consistent anti-counterfeiting codes can still be generated under changes in lighting, angle, noise interference, etc.
[0034] (4) The original face image and embedded features are not directly stored or transmitted, but are transformed by an irreversible encryption algorithm to generate an anti-counterfeiting code, thereby achieving privacy protection through encrypted encoding, thereby improving privacy security and reducing the risk of face information leakage.
[0035] (5) The generated anti-counterfeiting code can be embedded in multiple carriers such as QR code, NFC, and RFID, realizing multi-carrier anti-counterfeiting deployment and expanding practical application scenarios. Attached Figure Description
[0036] Figure 1 This is a flowchart illustrating the steps of an anti-counterfeiting code generation method based on facial feature extraction, according to an embodiment of the present invention. Detailed Implementation
[0037] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] See Figure 1 The diagram shows a flowchart of a method for generating anti-counterfeiting codes based on facial feature extraction according to an embodiment of the present invention, including the following steps:
[0039] S10, real-time acquisition of user information and user facial images;
[0040] S20: Lightweight feature extraction is performed on the user's face image, and the face feature embedding vector is output after extraction through a lightweight neural network model.
[0041] S30 embeds facial features into a vector for feature encryption and encoding, and outputs a security code after fusing with context parameters obtained from the sensor and performing irreversible encryption operations; the context parameters may include light sensing data, timestamps, device identifiers or geographic location data.
[0042] S40 maps the security code into multiple carrier formats, outputting at least one of QR codes, barcodes, NFC signals, and RFID tags.
[0043] In a specific application example, in S10, an RGB three-channel face image with a height of 128 pixels and a width of 128 pixels is acquired through a mobile device camera, PC camera, or embedded camera combined with an Ultra mini-model. The RGB three-channel face image is converted into an array: I∈R 128×128×3 .
[0044] In a specific application example, in S20, the lightweight neural network model extraction includes pruning of the ResNet-50 model W based on the importance score of multi-index fusion of convolutional kernels, quantization based on importance-guided adaptive bit allocation, and knowledge distillation, to form a lightweight face feature extraction model, so that the final model parameters are less than 10MB.
[0045] The pruning process, which involves multi-metric fusion importance scoring based on convolutional kernels, includes:
[0046] Let the l-th convolutional layer have N l One convolutional kernel: For the i-th convolutional kernel in the l-th layer w l,i We define three importance measures based on weight strength, BN scaling magnitude, and feature response energy: Where ||·||1 represents the L1 norm of the vector; γ l,i f is the scaling factor for the batch normalization layer; l,i (x) represents the feature response of the convolutional kernel to the input sample x; E x∈D [·] represents the mathematical expectation of a sample x in the training set D;
[0047] The overall importance score is a weighted fusion form: Where α, β, and δ are adjustable coefficients and α + β + δ = 1, the scoring is normalized because the number and scale of convolutional kernels differ in different layers: Next, the scores are globally sorted, and the convolutional kernels and corresponding BN channels with the lowest scores in the bottom 30% are deleted, and the model is reconstructed.
[0048] The score is updated periodically during the training phase and recalculated every K epoch. Where λ∈[0,1] represents the update coefficient. This represents the new score value obtained from the recalculation. Using this dynamic update mechanism, the model can adaptively learn changes in importance during pruning. By reducing redundant convolutional kernels layer by layer through the above pruning method, a sparse network W′ is obtained. The above settings can reduce ResNet-50 from 25MB to about 12MB.
[0049] Furthermore, the quantization of the pruned model using importance-guided adaptive bit allocation includes:
[0050] The pruned model is further sparsed into a network W′ using adaptive bit allocation quantization, which increases the importance score S of the convolutional kernel. i Binding to quantization bit width: Where τ h ,τ l These are the high importance threshold and the low importance threshold, respectively, b iEach convolutional kernel is quantized independently with a wider bit width, and more bits are allocated to high-importance channels. This minimizes accuracy loss while compressing the model as much as possible. The weight quantization process is as follows: in By using quantized perceptual training, the model's accuracy is prevented from decreasing during inference. The model size is further reduced by 60%, and the operation is changed from floating-point to integer operations, resulting in an approximately 2x increase in inference speed.
[0051] Furthermore, to compensate for the decrease in accuracy of lightweight models, this invention introduces a distillation mechanism to perform knowledge distillation processing, including:
[0052] Let the ResNet-50 model be used as the teacher network f T (x), the pruned and quantized model is the student network f S (x), joint training, the soft label output by the teacher network is: P T =softmax(z T / τ), the output of the student network is: P S =softmax(z S / τ); Distillation loss function: L=(1-λ)L CE (y,P s )+λτ 2 KL(P T ||P S ), where: L CE Cross-entropy loss; KL is the Kullback-Leibler divergence; τ is the temperature parameter; λ is the distillation weight coefficient. Through multi-objective joint optimization, the pruned and low-bitscaled network relearns the high-precision feature distribution, ultimately forming a lightweight face feature extraction model. This lightweight face feature extraction model is used to extract features from the face image I to form a face feature vector F, F∈R. 128 .
[0053] The above algorithm was deployed on a mobile device for experimentation. The experimental conditions included:
[0054] Hardware platform: Snapdragon 865 (mobile), Raspberry Pi 4B (embedded).
[0055] Software environment: TensorFlow Lite, PyTorch Mobile, Android 11 operating system.
[0056] Dataset: LFW public dataset.
[0057] The experimental results are as follows:
[0058] Model type Number of parameters (MB) Inference delay (ms) Accuracy (LFW, %) Power consumption (mW) ResNet-50 25.3 215 99.2 890 Pruning + Quantification 7.8 46 98.6 320 distillation 6.3 39 98.1 280
[0059] The results above show that the lightweight model is less than 8MB in size, only about 1 / 4 the size of ResNet-50, with inference latency reduced by more than 70%, meeting the requirements of real-time applications. On the LFW dataset, the accuracy remains above 98%, only 1.1% lower than ResNet-50, and power consumption is reduced by about 60%, making it suitable for battery-powered devices. The experiments verify that the lightweight face feature extraction algorithm of this invention effectively reduces model size, inference latency, and energy consumption while maintaining high accuracy, significantly improving the deployability and practicality of the anti-counterfeiting code generation system on mobile and embedded devices.
[0060] A specific application example, as described in S30, embedding facial features into a vector for feature encryption and encoding includes error correction and fault-tolerant encoding. Specifically, the original feature vector F often contains noise components caused by non-identity factors (lighting, pose). To filter out this noise, a pre-trained correction mapping matrix C is introduced into the facial feature vector F. This correction mapping matrix is obtained by performing linear discriminant analysis (LDA) on a large-scale multi-lighting, multi-angle dataset. It projects the original features into a noise-suppressing subspace, maximizing the inter-class distance between different people and minimizing the intra-class variance of the same person in different environments. The formula for calculating the corrected feature vector F′ is: Where: b is the bias vector used to center the feature distribution, and the denominator represents L2 normalization to ensure that the feature vector lies on the unit hypersphere and eliminate the change in vector magnitude caused by differences in illumination intensity.
[0061] To address the instability caused by floating-point precision, the continuous feature vectors are converted into discrete binary feature codes. A thresholding function with a dead-zone is used for fault-tolerant coding. For the i-th element f in the correction vector F′... i Its encoding rules are as follows: Where: δ is the fault tolerance threshold, and X is marked as an unstable bit. During the final face comparison, the weighted Hamming distance is calculated. The system automatically ignores the unstable bits marked as X and only compares those feature bits with high confidence, i.e., the Code. i The feature bit = 1 directly masks the minute fluctuations in the feature value near zero caused by side lighting or angle, thus not affecting the consistency of the final feature code. The feature vector after the above processing is denoted as K.
[0062] An experiment was conducted to verify this, with the following conditions: 50 users, with 20 facial images collected from each user (under different lighting, angles, and expressions).
[0063] The experimental results are as follows:
[0064] method Consistency rate (%) False rejection rate (FRR, %) Delay (ms) Error correction not used 92.3 7.8 43 After the invention was corrected 99.1 1.2 48
[0065] Experimental data verified the effectiveness of the fuzzy extraction and error correction mechanism. This invention significantly improves the consistency and robustness of anti-counterfeiting code generation through this mechanism, effectively reducing the false rejection rate while maintaining the system's real-time performance and security, thereby further enhancing the reliability and practicality of the anti-counterfeiting system.
[0066] In a specific application example, the fusion of context parameters acquired by the sensor in S30 includes: dynamic parameters related to the usage scenario that are synchronously collected by the system, including: light sensing data L, timestamp T, device unique identifier D (device unique serial number or hardware fingerprint) and geographical location P (latitude and longitude obtained through GPS or base station positioning), and constructing a context vector: C = [L, T, D, P].
[0067] Furthermore, feature fusion and encryption in S30 include:
[0068] The facial feature vector K is fused with the context parameter C using a weighted concatenation method: Where α and β are the weights automatically learned by the lightweight attention module;
[0069] The fused feature vector V is input into the SM3 encryption algorithm for SM3 encryption: Code = SM3(V);
[0070] A collision-resistant and irreversible security code is formed with a fixed length of 256 bits.
[0071] Experimental verification was conducted under the following conditions: facial images of 100 different users were collected at different times (day / night) and different locations (indoor / outdoor).
[0072] The experimental results are as follows:
[0073] method Conflict rate (%) Consistency rate (%) Replay attack success rate (%) Facial features only 0.87 95.1 100 (within a fixed time period) Facial features + context fusion 0.02 99.4 0
[0074] Experimental data demonstrates that, through context fusion, the anti-counterfeiting code is virtually conflict-free, and each generated result is unique globally. Combined with timestamps and device IDs, the anti-counterfeiting code has dynamic update capabilities, effectively preventing intercepted replay attacks. It can meet the requirements of low conflict rate, high reliability, and strong security in practical application scenarios.
[0075] The final encrypted security code is mapped to various carrier formats, such as QR codes, barcodes, NFC signals, or RFID tags. The output anti-counterfeiting code is unique, one-time use, and difficult to forge, and can be used for product traceability, anti-counterfeiting verification, and other applications.
[0076] To verify the validity of the anti-counterfeiting code, a separate verification terminal can be provided. The system re-captures the user's facial image, repeats the lightweight feature extraction, obtains context parameters from the registered information, performs feature fusion and encryption, and generates and outputs the anti-counterfeiting code to generate a verification token. The system compares the verification token with the anti-counterfeiting code in the database; if they match, the verification passes; otherwise, it is rejected.
[0077] The anti-counterfeiting code generation method based on facial feature extraction described above utilizes a lightweight facial feature extraction model and dynamically generates anti-counterfeiting codes by combining contextual information. This method achieves high security, low computational overhead, and edge deployment capability. It can run efficiently on resource-constrained devices, reducing computational costs, preventing forgery and replay attacks, and significantly improving the uniqueness and security of anti-counterfeiting codes.
[0078] It should be understood that the exemplary embodiments described herein are illustrative and not restrictive. Although one or more embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art will understand that various changes in form and detail may be made without departing from the spirit and scope of the invention as defined by the appended claims.
Claims
1. A method for generating anti-counterfeit codes based on facial feature extraction, characterized in that, Includes the following steps: S10, real-time acquisition of user information and user facial images; S20: Lightweight feature extraction is performed on the user's face image, and the face feature embedding vector is output after extraction through a lightweight neural network model. S30 embeds facial features into vectors for feature encryption and encoding, and outputs a security code after fusing with context parameters obtained from the sensor and performing irreversible encryption operations. S40 maps the security code into multiple carrier formats, outputting at least one of QR codes, barcodes, NFC signals, and RFID tags.
2. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 1, characterized in that, The context parameters include light-sensing data, timestamps, device identifiers, or geographic location data.
3. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 1, characterized in that, In S10, an RGB three-channel face image with a height of 128 pixels and a width of 128 pixels is captured by combining a mobile device camera, PC camera, or embedded camera with an Ultra miniature model.
4. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 1, characterized in that, In S20, the lightweight neural network model extraction includes performing pruning on the ResNet-50 model W, including pruning based on the importance score of multi-index fusion of convolutional kernels, quantization based on importance-guided adaptive bit allocation, and knowledge distillation, to form a lightweight face feature extraction model.
5. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 4, characterized in that, Pruning based on multi-metric fusion importance scoring using convolutional kernels includes: Let the l-th convolutional layer have N l One convolutional kernel: For the i-th convolutional kernel in the l-th layer w l,i We define three importance measures based on weight strength, BN scaling magnitude, and feature response energy: Where ||·||1 represents the L1 norm of the vector; γ l,i f is the scaling factor for the batch normalization layer; l,i (x) represents the feature response of the convolutional kernel to the input sample x; E x∈D [·] represents the mathematical expectation of a sample x in the training set D; The overall importance score is a weighted fusion form: Where α, β, and δ are adjustable coefficients and α + β + δ = 1, the scoring is normalized because the number and scale of convolutional kernels differ in different layers: Next, the scores are globally sorted, and the convolutional kernels and corresponding BN channels with the lowest scores in the bottom 30% are deleted, and the model is reconstructed. The score is updated periodically during the training phase and recalculated every K epoch. Where λ∈[0,1] represents the update coefficient. This represents the new score value obtained from the recalculation. Using this dynamic update mechanism, the model can adaptively learn changes in importance during pruning. By reducing redundant convolutional kernels layer by layer through the above pruning method, a sparse network W′ is obtained.
6. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 5, characterized in that, Quantization for importance-guided adaptive bit allocation includes: The pruned model is further sparsed into a network W′ using adaptive bit allocation quantization, which increases the importance score S of the convolutional kernel. i Binding to quantization bit width: Where τ h ,τ l These are the high importance threshold and the low importance threshold, respectively, b i Each convolutional kernel is quantized independently with a wider bit width, and more bits are allocated to high-importance channels. This minimizes accuracy loss while compressing the model as much as possible. The weight quantization process is as follows: in 7. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 6, characterized in that, Knowledge distillation includes: Let the ResNet-50 model be used as the teacher network f T (x), the pruned and quantized model is the student network f. S (x), joint training, the soft label output by the teacher network is: P T =softmax(z T / τ), the output of the student network is: P S =softmax(z S / τ); Distillation loss function: L=(1-λ)L CE (y,P s )+λτ 2 KL(P T ||P S ), where: L CE τ is the cross-entropy loss; KL is the Kullback-Leibler divergence; τ is the temperature parameter; λ is the distillation weight coefficient. Through multi-objective joint optimization, the pruned and low-bit network relearns the high-precision feature distribution, and finally forms a lightweight face feature extraction model. The lightweight face feature extraction model is used to extract features from the face image I to form the face feature vector F.
8. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 7, characterized in that, The embedding of facial features into a vector for feature encryption and encoding as described in S30 includes error correction and fault-tolerant encoding. Specifically, the facial feature vector F is introduced into a pre-trained correction mapping matrix C. This correction mapping matrix is obtained by performing linear discriminant analysis (LDA) on a large-scale multi-light, multi-angle dataset. The original features are projected into a noise-suppressing subspace to maximize the inter-class distance between different people and minimize the intra-class variance of the same person in different environments. The formula for calculating the corrected feature vector F′ is as follows: Where: b is the bias vector, used to center the feature distribution, and the denominator represents L2 normalization to ensure that the feature vector lies on the unit hypersphere and to eliminate the change in vector magnitude caused by differences in illumination intensity. The continuous feature vector is then converted into discrete binary feature codes, and fault-tolerant coding is performed using a threshold quantization function with dead zone. For the i-th element f in the correction vector F′... i Its encoding rules are as follows: Where: δ is the fault tolerance threshold, and X is marked as an unstable bit. During the final face comparison, the weighted Hamming distance is calculated, and the system automatically ignores the unstable bits marked as X, only comparing those feature bits with high confidence, i.e., Code. i The eigenvector after the above processing is denoted as K, where the eigenbit is 1.
9. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 8, characterized in that, The context parameter fusion in S30 with sensor acquisition includes: dynamic parameters related to the usage scenario that the system synchronously collects, including: light sensing data L, timestamp T, device unique identifier D (device unique serial number or hardware fingerprint) obtained through light sensor, and geographical location P (latitude and longitude obtained through GPS or base station positioning), constructing a context vector: C = [L, T, D, P].
10. The anti-counterfeiting code generation method based on facial feature extraction as described in claim 9, characterized in that, Feature fusion and encryption in S30 include: The facial feature vector K is fused with the context parameter C using a weighted concatenation method: Where α and β are the weights automatically learned by the lightweight attention module; The fused feature vector V is input into the SM3 encryption algorithm for SM3 encryption: Code = SM3(V); A collision-resistant and irreversible security code is formed with a fixed length of 256 bits.