Visitor identity authentication method and system based on color code technology

Through a dual-factor authentication method combining color code technology and deep learning facial recognition, the visual Transformer model is used to extract facial features and encode them into color QR codes, which solves the problem of recognition robustness of traditional identity authentication systems in complex environments, and achieves high-precision and secure identity authentication.

CN120564299APending Publication Date: 2025-08-29Chinese People's Liberation Army Cyberspace Force Information Engineering University
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510849982.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-08-29

AI Technical Summary

Technical Problem

Traditional identity authentication systems have insufficient recognition robustness in complex lighting and posture changes, are vulnerable to attacks, and are difficult to meet high security needs.

Method used

The dual-factor authentication method based on color code technology and deep learning facial recognition is adopted, and facial features are extracted and encoded into color QR codes using the visual Transformer model, combining the self-attention mechanism and multi-head attention to capture the global facial features for authentication.

Benefits of technology

Improve the accuracy and tamper resistance of identity authentication, ensure the security and anti-counterfeiting of identity authentication through a two-factor authentication barrier, and enhance the recognition robustness in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120564299A_ABST
    Figure CN120564299A_ABST
Patent Text Reader

Abstract

The invention provides a visitor identity authentication method and system based on a color code technology. The method comprises the following steps: a user registration stage: performing verification according to a head portrait and a user name uploaded by a user, and if the verification is passed, generating a color two-dimensional code for the user; the color two-dimensional code, the generation time of the color two-dimensional code and personal information of the user are associated and stored in a database; the user authentication stage comprises the following steps: acquiring a color two-dimensional code shown by a user and collecting a real-time head portrait of the user; decoding the color two-dimensional code to obtain a registered facial feature; processing the real-time head portrait of the user by using a face recognition model based on a visual Transform so as to extract a current facial feature; and judging whether the registered facial feature is matched with the current facial feature or not, if so, passing the identity verification, and otherwise, refusing the identity verification. According to the invention, face recognition and two-dimensional code scanning are combined through a dual authentication mechanism, so that higher-level safety guarantee is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of access control, and in particular to a visitor identity authentication method and system based on color code technology. Background Art

[0002] In the context of deep learning-enabled technologies, identity authentication, as the first line of defense for information security, is becoming increasingly important. Traditional authentication methods such as passwords and ID cards are vulnerable to attacks such as cracking, copying, and forgery, and are no longer able to meet today's high security standards. This is especially true in critical areas with extremely sensitive data, such as financial transactions, government administration, and enterprise operations. The fragility of identity authentication mechanisms has become the weakest link in the entire system security chain. Therefore, building a reliable, intelligent, and attack-resistant identity recognition system to effectively mitigate the risks of identity fraud and forgery has become a core area of ​​ongoing research.

[0003] Facial recognition has been widely used in information security and identity verification in recent years due to its non-contact nature, ease of use, and high accuracy. Compared to traditional authentication mechanisms that rely on physical media, such as password entry or ID card verification, facial recognition accurately captures and analyzes the structural information of key facial areas, and can complete identity comparison without user interaction, providing a more secure authentication method. Especially with the continuous optimization of current deep learning algorithms, facial recognition systems have achieved leapfrog development in recognition accuracy, response speed, and environmental adaptability, and have strong robustness. However, such methods still face many challenges in their deployment in real-world scenarios. For example, complex lighting conditions, changes in shooting angles, differences in facial expressions, and partial facial occlusion can all lead to a decrease in the system's recognition rate or even misjudgment. Summary of the Invention

[0004] In order to solve the deficiencies of traditional identity authentication systems in terms of security and anti-counterfeiting, the present invention proposes a visitor identity authentication method and system based on color code technology.

[0005] In a first aspect, the present invention provides a visitor identity authentication method based on color code technology, comprising:

[0006] The user registration phase includes: verifying the user's uploaded profile picture and username. If the verification is successful, a color QR code is generated for the user; and the color QR code and its generation time are associated with the user's personal information and stored in the database;

[0007] The user authentication stage includes: obtaining the color QR code presented by the user and collecting the user's real-time profile picture; decoding the color QR code to obtain the registered facial features; using the visual Transformer-based face recognition model to process the user's real-time profile picture to extract the current facial features; judging whether the registered facial features match the current facial features. If so, the identity authentication is passed; otherwise, the identity authentication is rejected.

[0008] Further, determining whether the registered facial features match the current facial features specifically includes:

[0009] The cosine similarity between the registered facial features and the current facial features is calculated. If the cosine similarity is greater than a set threshold, the two are considered to match, otherwise they are not matched.

[0010] Furthermore, the process of generating a color QR code for the user specifically includes:

[0011] A visual Transformer-based face recognition model is used to process user-uploaded avatars to obtain registered facial features. A standard QR code encoding mechanism is used to convert the user's registered facial features and username into a two-dimensional code matrix consisting of black and white modules. For the two-dimensional code matrix, each adjacent m×m module is used as a block to divide the two-dimensional code matrix into several blocks, and each block is assigned a color to obtain an initial color QR code. The contrast and sharpness of the initial color QR code are enhanced to obtain a final color QR code, where m is a positive integer.

[0012] Furthermore, before decoding the color QR code to obtain the registered facial features, the method further includes: determining whether the color QR code is valid, specifically including: checking whether the color QR code is damaged and / or expired and / or matches the associated user personal information; if the color QR code is not damaged, has not expired and matches the associated user personal information, then the color QR code is valid;

[0013] Correspondingly, if the color QR code is valid, the color QR code is decoded to obtain the registered facial features; if it is invalid, the authentication process is terminated.

[0014] Furthermore, decoding the color QR code to obtain the registered facial features specifically includes:

[0015] If the color QR code is directly recognized using the preset decoding library and fails, multiple rounds of image enhancement process are entered to obtain an enhanced color QR code, and then the enhanced color QR code is recognized using the preset decoding library to obtain registered facial features; the image enhancement process includes: a grayscale processing stage, a threshold processing stage, an edge detection stage and a binarization processing stage;

[0016] Among them, the grayscale processing stage includes converting the color QR code into a grayscale image; the threshold processing stage includes using the adaptive threshold method to calculate the threshold when the lighting is uneven; when the brightness distribution is uniform, the threshold is calculated using the Otsu threshold method; the edge detection stage includes using the Canny edge detection algorithm to extract the contour information in the image and strengthening the edge through the expansion operation; the binarization processing stage includes extracting the R, G, and B color channel images of the image, and using the calculated threshold to binarize the three color channel images separately.

[0017] In a second aspect, the present invention provides a visitor identity authentication system based on color code technology, comprising:

[0018] The user function module is used to verify the user's uploaded avatar and username during the user registration phase. If the verification is successful, a color QR code is generated for the user; the color QR code and its generation time are associated with the user's personal information and stored in the database;

[0019] The dual identity authentication module is used to obtain the color QR code presented by the user and collect the user's real-time head portrait during the user authentication stage; decode the color QR code to obtain the registered facial features; use the visual Transformer-based face recognition model to process the user's real-time head portrait to extract the current facial features; determine whether the registered facial features match the current facial features. If so, the identity authentication is passed; otherwise, the identity authentication is rejected.

[0020] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.

[0021] In a fourth aspect, the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method described in the first aspect when executed by a processor.

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

[0023] This visitor identity authentication method and system, based on color coding technology, utilizes a visual Transformer model to replace traditional CNNs. Using a self-attention mechanism, it captures global facial features, addressing robustness issues in complex lighting and posture variations. It effectively captures facial details and provides highly accurate face recognition results, ensuring accurate identity verification. Facial features extracted by ViT and user information are encoded into a color QR code. This QR code not only carries the user's identity information but also enhances its anti-counterfeiting capabilities by encoding the color space, increasing the tamper-resistance and anti-forgery capabilities of traditional QR codes. During authentication, the QR code data is simultaneously parsed and matched with stored facial features, forming a dual verification barrier of "biometrics + encryption carrier." BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 The overall architecture of the existing ViT;

[0025] Figure 2 A schematic diagram of a process for visitor identity authentication based on color code technology provided by an embodiment of the present invention;

[0026] Figure 3 A schematic diagram of the architecture of a visitor identity authentication system based on color code technology provided by an embodiment of the present invention;

[0027] Figure 4 A user registration interface provided by an embodiment of the present invention;

[0028] Figure 5 Color QR codes for different users provided by the embodiment of the present invention;

[0029] Figure 6 The color code authentication success interface provided by the embodiment of the present invention;

[0030] Figure 7 The color code authentication failure interface provided by the embodiment of the present invention;

[0031] Figure 8 The face authentication success interface provided by the embodiment of the present invention;

[0032] Figure 9 A user personal information interface provided by an embodiment of the present invention;

[0033] Figure 10 An administrator interface provided for an embodiment of the present invention;

[0034] Figure 11 A user management interface provided by an embodiment of the present invention;

[0035] Figure 12 The test record management interface provided by the embodiment of the present invention;

[0036] Figure 13 This is a structural block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0037] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0038] In order to address the shortcomings of traditional identity authentication systems in terms of security and anti-counterfeiting, the present invention proposes a dual authentication method and system that integrates color code technology and deep learning face recognition. The purpose is to achieve an efficient and secure identity authentication method and system by integrating QR code color code technology and deep learning-based face recognition algorithm.

[0039] Before introducing the technical solution of the present invention, the key technologies used in the present invention are briefly introduced below.

[0040] The face recognition algorithm used in this invention is a face recognition model based on the Vision Transformer (ViT). The overall framework of ViT is as follows: Figure 1 As shown in the figure, the overall structure of the Vision Transformer mainly consists of three modules: (1) Linear Projection Module: including the Patch and Position embedding layers, which is used to cut the input image into small patches (patches) and add position information to each patch; (2) Transformer-based Encoder: Image data enters the Transformer encoder, and the input features are processed and extracted through the self-attention mechanism; (3) MLP Head: After being processed by the Transformer encoder, the features are passed to the MLP head, which is responsible for mapping the extracted features to the classification layer to obtain the final classification results.

[0041] The Transformer Encoder processes images that have been partitioned into small patches. This approach is based on treating each patch in the image as a token (similar to a word or character in NLP), and calculating the correlation between each token in the Transformer. In ViT, the Transformer Encoder requires a vector of shape num_token, token_dim. For image data, inputs of shape H, W, C do not meet these requirements, so they must be converted into tokens through the Embedding layer. Taking ViT-B / 16 as an example, assuming the input image size is 224×224×3 and the original image size of each token is 16×16×3, the image can be split into 196 patches. ViT then converts each patch into a one-dimensional vector of length 16×16×3 = 768 through a linear projection. Therefore, when the 196 tokens are stacked together, the final dimension is 196,768.

[0042] It's also important to note that tokens can be encoded with positions. Due to the nature of the self-attention mechanism, without position information, the calculation results for "I love you" and "You love me" are the same. Therefore, after adding position encoding, the model can more accurately understand the relative position of each element in the sequence, thereby improving classification accuracy. In the Embedding layer of ViT, the position information is fused with the input tensor through addition, expressed as:

[0043] Input=Token+Position_Embedding

[0044] Among them, Position_Embedding is a predefined position information vector, and Token is the feature representation of the image block obtained by patch splitting and linear mapping.

[0045] Another key point is that a class token (classification layer) is also required in the input tensor. This class token has the same shape as other tokens, with a length of 768, and is fused differently with the positional encoding. Concatenation is used here, rather than addition. This is because the classification information needs to be extracted and predicted separately in subsequent stages, so it cannot be fused additively. The formula is:

[0046] Input_with_class=[Class_Token; Token1; Token2; ....; Token 196 ]

[0047] Through the concatenation operation, the final input dimension changes from 196,768 196,768 to 197,768 197,768, where 197 represents the number of tokens including the class token.

[0048] Transformer Encoder usually consists of the following key components: Layer Normalization, Multi-Head Attention, DropOut / DropPath, and MLP Block. Layer Normalization processes a single sample, calculates the mean and variance of all feature maps of the sample, and normalizes them:

[0049]

[0050] Here μ L and It is the mean and variance for a single sample. Layer normalization avoids the problems caused by changes in the distribution of mini-batch data in batch normalization, and only one sample is required for normalization, which reduces the need for storage and is therefore more efficient in some cases. Multi-Head Attention is the core mechanism in the Transformer architecture, which can capture the dependencies between positions in the input sequence. In ViT, the role of Multi-Head Attention is to model the global features of the input image blocks. By calculating different self-attentions in parallel through multiple "heads", Multi-Head Attention enables the model to pay attention to different feature dimensions at the same time. Its calculation formula is as follows:

[0051]

[0052] Where Q is the query matrix, K is the key matrix, V is the value matrix, and d k is the key dimension, and the softmax operation ensures the weight of attention distribution. Multi-head attention captures dependency information at different levels of the image by computing multiple attention heads in parallel and concatenating the results. DropOut / DropPath are techniques for preventing overfitting and improving model robustness. They both have similar functions, preventing network overfitting by randomly discarding some neurons. Specifically in ViT, DropPath acts on the network structure of each layer's output, while DropOut randomly discards some network-connected nodes. Both strategies have little impact on the final result, so different strategies can be selected as needed in actual implementation.

[0053] The MLP Head Block is another important component of the Transformer Encoder. It consists of a fully connected layer, an activation function, and a DropOut layer. Its structure can be considered a bottleneck: the input features are first expanded to four times the original number of channels through a fully connected layer, and then restored to their original dimensions through another fully connected layer. This process can be expressed as follows:

[0054] MLP(x)=DropOut(GELU(W1x+b1))W2+b2

[0055] Here, W1 and W2 are the weight matrices of the fully connected layer, b1 and b2 are bias terms, and GELU is the activation function. This inverted bottleneck structure allows the model to achieve greater expressive power while maintaining computational efficiency. Notably, the shape of the tensor processed by the MLP block remains unchanged, with dimensions remaining at [196, 768]. This ensures consistent input and output dimensions, ensuring continuous information flow.

[0056] By stacking these modules, the Transformer Encoder constructs a powerful image feature extraction and representation mechanism that can simultaneously capture local details and global semantic information. The multi-head self-attention mechanism enables the model to learn long-range dependencies between pixels without being restricted by the receptive field constraints of traditional convolutional neural networks, effectively solving the problem of long-range context modeling in visual tasks. At the same time, the introduction of positional encoding and residual connections ensures the preservation of spatial information and the stable transfer of gradients, enabling the model to handle the complex structure of two-dimensional image data. By alternating between self-attention layers and feedforward neural networks, each stacked module can gradually refine and abstract the image representation, forming a hierarchical feature learning process.

[0057] like Figure 2 As shown, an embodiment of the present invention provides a visitor identity authentication method based on color code technology, comprising the following steps:

[0058] The user registration phase includes: verifying the user's uploaded profile picture and username. If the verification is successful, a color QR code is generated for the user; and the color QR code and its generation time are associated with the user's personal information and stored in the database;

[0059] The user authentication stage includes: obtaining the color QR code presented by the user and collecting the user's real-time profile picture; decoding the color QR code to obtain the registered facial features; using the visual Transformer-based face recognition model to process the user's real-time profile picture to extract the current facial features; judging whether the registered facial features match the current facial features. If so, the identity authentication is passed; otherwise, the identity authentication is rejected.

[0060] Specifically, the visual Transformer-based face recognition model first divides the input face image into non-overlapping image patches of fixed size. Each patch is converted into an embedding vector through linear projection, and a learnable positional encoding is added to preserve spatial information. These embedding vectors are then input into a multi-layer Transformer encoder, each layer of which contains multi-head self-attention (MSA) and a feedforward network (FFN). The self-attention mechanism dynamically aggregates global information by calculating the similarity of the query (Q), key (K), and value (V). Multi-head attention splits the input into h groups of parallel calculations, and finally concatenates the results and fuses them through a linear layer. In the output of the Transformer encoder, the vector corresponding to the [class] tag is usually used as the global face feature representation.

[0061] To optimize feature discriminability, the face recognition model based on the visual Transformer in this embodiment is pre-trained using a large-scale face dataset (such as MS-Celeb-1M or Glint360K) and a loss function (such as ArcFace). ArcFace enhances intra-class compactness and inter-class separability through an angular margin penalty, and its formula is:

[0062]

[0063] where θ y The angle between the feature and target class weight vectors, m is the spacing hyperparameter, and s is the scaling factor. Furthermore, data augmentation and model optimization techniques can be introduced during training to improve generalization. During inference, the system performs face verification or recognition by comparing feature vector similarity thresholds. This computational efficiency is achieved thanks to the parallel processing capabilities of the Transformer, eliminating the need for the local receptive field-based progressive feature fusion of traditional CNNs.

[0064] As an implementable method, determining whether the registered facial features match the current facial features specifically includes: calculating the cosine similarity between the registered facial features and the current facial features, and when it is greater than a set threshold, the two are considered to match, otherwise they are not matched.

[0065] The visitor identity authentication method based on color coding technology provided in an embodiment of the present invention utilizes a visual Transformer model to replace the traditional CNN. It captures global facial features through a self-attention mechanism, addressing recognition robustness issues in scenarios with complex lighting and posture changes. It effectively captures facial details and provides highly accurate face recognition results, ensuring the accuracy of identity verification. Facial features extracted by ViT and user information are encoded into a color QR code. This QR code not only carries the user's identity information but also enhances the QR code's anti-counterfeiting capabilities by encoding the color space, increasing the tamper-resistance and anti-forgery capabilities of traditional QR codes. During authentication, the QR code data is simultaneously parsed and matched with stored facial features, forming a dual verification barrier of "biometric features + encryption carrier."

[0066] In one embodiment, before decoding the color QR code to obtain the registered facial features, it also includes: judging whether the color QR code is valid, specifically including: checking whether the color QR code is damaged and / or whether it has exceeded the validity period and / or matches the associated user personal information. If it is not damaged, has not exceeded the validity period and matches the associated user personal information, it means that the color QR code is valid; correspondingly, if the color QR code is valid, the color QR code is decoded to obtain the registered facial features. If it is invalid, the authentication process is terminated.

[0067] Specifically, by adding a validity detection process for the color QR code, the security of identity authentication is further enhanced.

[0068] In one embodiment, the embodiment of the present invention implements generation and decoding of color two-dimensional codes based on a standard QR code encoding and decoding method using image processing technology.

[0069] (1) Coding stage

[0070] S201: Construction of a QR code matrix. The user input data (including the characteristic information of the user name and user avatar) is converted into a QR code matrix composed of black and white modules using a standard QR code encoding mechanism. The process formula can be expressed as follows (1). Among them, the characteristic information of the user avatar is the global facial features obtained by processing the user's uploaded avatar using a face recognition model based on visual Transformer. In order to conveniently distinguish the global facial features in the registration stage and the identity authentication stage, the facial features in the two stages are respectively referred to as registration facial features and current facial features.

[0071] QRCodeMatrix(i,j)={0,1}(1)

[0072] Where (i, j) represents the position in the matrix, a value of 0 represents white, and a value of 1 represents black.

[0073] Specifically, the QR code matrix is ​​constructed according to the QR code specification, which includes a positioning pattern, a timing pattern, format information, a data area, and error correction codewords. These structures generate redundant information through Reed-Solomon coding, so that even if part of the area is damaged, the original data can be restored through error correction capabilities.

[0074] S202: Matrix coloring. Perform color mapping on the black and white QR code obtained in the previous step;

[0075] Specifically, unlike traditional monochrome QR codes, this embodiment adopts a "block consistency" strategy to perform color mapping on the matrix, specifically: the entire QR code matrix is ​​divided into several 4×4 small square areas (i.e., "blocks"), and all black modules in each block are assigned the same color (the formulas corresponding to color allocation are as follows (2) and (3)) to maintain local color consistency and avoid scanner misjudgment due to color mutation. This design not only improves visual beauty but also takes into account recognition stability. In terms of color selection, the original encoding method supports two modes: (1) high contrast mode: using dark tones such as dark red, dark green, dark blue, etc. to ensure good readability in different backgrounds; (2) vivid mode: using bright colors such as pure red, pure green, pure blue, etc., suitable for display purposes. This embodiment mainly adopts high contrast mode.

[0076]

[0077] Where ColorMap(i,j) represents the color at position (i,j) in the QR code. random_color(C) represents the color from the color list C = {c1,...,c n}. finder_pattern is a fixed positioning pattern area in the QR code (such as three large squares).

[0078] S203: Enhance contrast and sharpen. In order to improve the clarity and scanning success rate of the QR code, this embodiment also performs contrast enhancement and sharpening processing on the initial color QR code generated in the previous step. This is to perform linear or nonlinear transformation on the image pixel values, enhance edge details, make the QR code boundary clearer, and improve the recognition rate. When the image is finally output, the color QR code is saved in RGB format, retaining the complete color information without destroying the original QR code structure layout. Among them, the image contrast enhancement formula is as follows (4), and the image sharpening process is performed by applying a convolution kernel, as shown in (5).

[0079] I enhanced =I original ×contrast factor(4)

[0080] I shared =I original ×K sharpen (5)

[0081] Among them, I original is the original image, the contrast factor is usually in the range of [1,3], K sharpen It is a sharpening convolution kernel used to enhance the details of the image.

[0082] (2) Decoding stage

[0083] The goal of the decoding phase is to extract the QR code content from an image that may contain color interference, uneven lighting, blur, and other issues, and restore the original data. The mathematical principle of decoding color QR codes is essentially the process of restoring the visual information in the image to the original encoded data.

[0084] In this embodiment, the decoding of the color QR code to obtain the registered facial features specifically includes: using a preset decoding library to directly identify the color QR code, and if it fails, entering multiple rounds of image enhancement process to obtain an enhanced color QR code, and then using the preset decoding library to identify the enhanced color two-dimensional to obtain the registered facial features; the image enhancement process includes: a grayscale processing stage, a threshold processing stage, an edge detection stage and a binarization processing stage; wherein, the grayscale processing stage includes converting the color QR code into a grayscale image, which is obtained by weighted averaging the pixel values ​​of the three channels R, G, and B; the threshold processing stage includes using an adaptive threshold method to calculate the threshold when the illumination is uneven; and using the Otsu threshold method to calculate the threshold when the brightness distribution is uniform; the edge detection stage includes using the Canny edge detection algorithm to extract contour information in the image, and strengthening the edge through an expansion operation; the binarization processing stage includes extracting the R, G, and B color channel images of the image, and using the calculated threshold to binarize the three color channel images separately.

[0085] Specifically, since color QR codes are much more complex than traditional black and white QR codes in terms of color distribution and brightness variations, when direct recognition fails, a series of image preprocessing steps are required to enhance image features to make them easier to recognize.

[0086] Based on the same inventive concept, an embodiment of the present invention further provides a visitor identity authentication system based on color code technology, including a user function module and a dual identity authentication module.

[0087] Among them, the user function module is used to verify the user's uploaded avatar and username during the user registration stage. If the verification is passed, a color QR code is generated for the user; and the color QR code and its generation time are associated with the user's personal information and stored in the database; the dual identity authentication module is used to obtain the color QR code presented by the user and collect the user's real-time avatar during the user authentication stage; decode the color QR code to obtain the registered facial features; use the visual Transformer-based face recognition model to process the user's real-time avatar to extract the current facial features; determine whether the registered facial features match the current facial features. If so, the identity authentication is passed, otherwise, the identity authentication is rejected.

[0088] The visitor identity authentication system based on color code technology provided by an embodiment of the present invention uses a visual transformer (ViT) model to extract and match facial features. The system can accurately identify the user's identity and generate a color QR code with color coding information. This QR code not only carries the user's identity information, but also enhances the QR code's anti-counterfeiting properties by encoding the color space, improving the system's anti-tampering and anti-counterfeiting capabilities. During the identity authentication stage, the system combines facial recognition and QR code scanning through a dual authentication mechanism to achieve a higher level of security.

[0089] In one embodiment, the visitor identity authentication system utilizes a three-tier architecture, comprising a front-end interaction layer, a back-end processing layer, and a database storage layer. This system utilizes a two-factor authentication mechanism that combines color QR codes with facial recognition, enabling efficient and secure identity verification. The system primarily includes core functional modules such as user registration and authentication, color code generation and management, and facial feature comparison. A MySQL database is used for data storage and management.

[0090] The overall system design diagram shows the architecture of the entire system, such as Figure 3 As shown in the figure, the system primarily consists of a front-end layer, a back-end layer, a database layer, and external services. The various components in the system architecture exchange and manage data through APIs and databases, ensuring efficient system operation. The front-end, back-end, and database layers work together to form a complete system architecture.

[0091] The front-end layer is responsible for interacting with users, displaying system data and operating interfaces, and providing functions such as user login, registration, uploading QR codes and avatar images, and viewing test results. The front-end layer is implemented using a technology stack such as HTML, CSS, and JavaScript. The front-end layer communicates with the back-end API, and front-end operations trigger back-end logic processing. Specific functions include:

[0092] 1. User Login and Registration: Users can create accounts and log in to the system, and administrators can also manage accounts. 2. Image Upload and Display: Users can upload QR codes and portrait images, which the system will store and process. 3. Test Result Display: Displays test results, such as pass / fail status, after users upload QR codes and portrait images. 4. Administrator Control Panel: Administrators can manage users, view user-generated QR codes, and perform other operations.

[0093] The back-end layer is based on the Django framework, which processes front-end requests and implements business logic, providing a RESTful interface for data exchange with the front-end. Back-end services include user authentication, QR code generation services, detection services, and permission management to ensure the security and effectiveness of the system. Specific functions include: 1. User management: Administrators can manage users through the back-end management interface, including user registration, information modification, and other operations. 2. QR code generation and management: After the user uploads information, the system can generate a unique QR code and associate it with the user. The QR code generation record includes the generation time and administrator information. 3. Detection record management: When the user uploads a QR code and avatar picture, the back-end receives and saves this data and performs detection processing. The detection results will be stored and associated with the user for subsequent query and analysis. 4. Data processing and analysis: The back-end will also process detection data, including storage, query, and analysis of detection results.

[0094] In this system, three main entities are designed: Admin, User, and DetectionRecord. Each entity has different attributes, which determine the structure of each table in the database. The database layer uses MySQL to store persistent data, including administrator information, user information, and detection records. Each data table is responsible for storing a specific type of information. For example, the administrator table stores administrator account information, the user table stores user information, including avatars, QR codes, and QR code generation time, and the detection record table records the QR codes, avatar images, and detection results uploaded by users. External services include image storage services for storing uploaded avatars and QR code images, and file processing services for processing user-uploaded files and performing image preprocessing and detection.

[0095] The administrator table is designed as shown in Table 1. It is used to store administrator information. It includes id (unique identifier, primary key), username (administrator's username), and password (administrator's password). The administrator's username is unique and is used to distinguish different administrators.

[0096] Table 1 Administrator table design

[0097] Field Name Data Type illustrate id BIGINT(PK) Primary Key username VARCHAR(32) Administrator Username password VARCHAR(64) Administrator password

[0098] The user table is designed as shown in Table 2. It stores user information, including id (unique identifier, primary key), username (user's unique username), password (user's password), avatar (path to the user's avatar), qr_code (user's QR code path, which can be null), and qr_code_generated_at (the time the QR code was generated, which can be null). The relationship between users and administrators is indirectly established through QR code generation. If QR code generation is enabled, administrators generate QR codes for users. One administrator can generate QR codes for multiple users, but there is no explicit foreign key association.

[0099] Table 2 User table

[0100] Field Name Data Type illustrate id BIGINT(PK) Primary Key username VARCHAR(32) username password VARCHAR(64) password avatar VARCHAR(255) Avatar image path qr_code VARCHAR(255) Unique QR code image path qr_code_generated_at DATETIME QR code generation time

[0101] The detection record table, as shown in Table 3, is used to store user detection records. It includes id (a unique identifier, the primary key), user_id (a foreign key pointing to the id field in the User table, indicating which user the record belongs to), uploaded_type (detection record), detection_time (detection time), result (test result, storing pass or fail results), and remark (remark information, which can be empty). The relationship between DetectionRecord and User is a one-to-many relationship; a user can have multiple detection records, but each record belongs to only one user.

[0102] Table 3 Test record

[0103] Field Name Data Type illustrate id BIGINT(PK) Primary Key user_id BIGINT(FK) Foreign key, associated with User table uploaded_type VARCHAR(255) Detection Type detection_time DATETIME Detection time result VARCHAR(20) Test result ("pass" or "fail") remark TEXT Remarks

[0104] In one embodiment, the system also includes a system management module. The administrator model (Admin) is used to store administrator information in the system. The administrator has a username and password to log in to the system to perform management operations. Administrator functions include: (1) Managing users: The administrator can view the information of all users, delete users and reset passwords, and manage their QR code generation records. (2) Audit management: The administrator can view the login records of all users, including the user's username, login time, and whether the login is successful.

[0105] In order to verify the effectiveness of the solution of the present invention, the present invention also provides the following experimental data.

[0106] (1) Development and test operating environment

[0107] The local development and testing environment of this system is based on the Windows 10 operating system. The system development adopts the Visual Studio Code on Windows integrated development environment. The real-time face detection input source is the local camera input of the office computer (ThinkPadX1), the format is 720p 16:9 30fps, and the processor is Intel(R) 12th Gen Core(TM) i5-1240P.

[0108] Table 4 Development and test operating environment

[0109] name illustrate Local development operating system Windows 10 Development Tools Visual Studio Code Video Input 720p 16:9 30fps processor Intel(R)12th Gen Core(TM)i5-1240P

[0110] This system is primarily implemented using the Django framework and a MySQL database. Django is a Python-based, advanced web development framework that follows the MTV (Model-Template-View) architectural pattern. It provides a wealth of built-in features, such as ORM (Object-Relational Mapping), authentication systems, and an administrative backend, enabling the rapid construction of secure and reliable web services.

[0111] For data storage, the system uses MySQL as its core database management system. MySQL is a widely used open-source relational database with high performance, excellent concurrency, and mature transaction support, making it suitable for medium- to large-scale data storage and query needs. Through the database abstraction layer provided by Django, developers can define data models using Python code instead of directly writing SQL statements, thereby improving development efficiency and reducing maintenance costs.

[0112] (2) Dataset preparation

[0113] To better perform face recognition, the present invention first uses a public dataset related to Hollywood celebrity faces to fine-tune the existing ViT model, and trains it on large-scale and diverse facial data of Hollywood celebrity faces, enabling the model to more accurately learn the detailed features in facial images. Then, photos of three classmates are uploaded to the real dataset for face recognition in complex real-life scenes, improving its recognition accuracy and generalization ability in actual application scenarios, better adapting to different lighting, posture and expression changes, and thus enhancing its robustness in complex environments.

[0114] (3) ViT pre-training model

[0115] This system uses the pre-trained ViT model Ganesh-KSV / face-recognition-version1 provided by Hugging Face. This model has been widely used in face recognition and identification. The specific process includes image preprocessing, model inference, and result mapping. Trained on a large-scale facial dataset, it can recognize the faces of many famous actors and public figures. This pre-trained model allows users to directly apply it to various face recognition tasks without having to train it from scratch, significantly saving training time and resources. For each input image, the model outputs a category label representing the recognized person. These labels are mapped to famous names such as "Angelina Jolie," "Brad Pitt," and "Leonardo DiCaprio," enabling the model to provide intuitive results in real-world applications. Using this pre-trained model not only avoids the tedious training process but also leverages the efficiency and accuracy offered by large-scale data training, providing users with reliable face recognition services in a variety of real-world scenarios. This model has broad applicability in various face recognition applications, particularly in industries such as entertainment and security.

[0116] To associate predictions with celebrity names, we defined a label mapping dictionary that maps the category numbers output by the model to the corresponding celebrity names. This dictionary includes the names of several famous celebrities. During inference, the model returns the corresponding category numbers, which are then converted to specific celebrity names using this dictionary.

[0117] After image preprocessing is complete, the processed image is input into the ViT model for inference. The output returned by the model contains the raw prediction score (logits) for each category. Next, the torch.argmax function is used to obtain the category index with the highest score, and the index is converted into the corresponding celebrity name through the label mapping dictionary. Finally, the entire process is encapsulated into a function predict, which accepts the image path as input and returns the predicted category number and celebrity name. In this way, face recognition can be performed based on uploaded images. Simply upload the image, and the system will analyze the image based on the pre-trained ViT model and return the name of the person in the image. This method can provide users with efficient and accurate face recognition services in multiple application scenarios.

[0118] (4) Dual Authentication System Testing

[0119] (1) User registration

[0120] The user submits the user name and password through the registration interface and uploads a face photo. Figure 4As shown in the figure, the backend uses OpenCV to perform face detection on the uploaded image, extracts the face feature vector through the ViT model, and stores it in the MySQL user table together with the user information (user name, password).

[0121] (2) Color code generation

[0122] The system calls the color QR code generation module to encode the user ID and facial feature hash value into an anti-counterfeiting color QR code, such as Figure 5 The encoding process adheres to QR code standards, employing the Reed-Solomon error correction algorithm to ensure data integrity. A "block consistency" strategy is used to uniformly colorize the 4×4 module area for enhanced visual stability. Color modes support high contrast (dark red, dark green, dark blue) and vivid (solid color), with the former being selected for improved scanning robustness. The generated QR code undergoes contrast enhancement and sharpening, is saved in RGB format, and is associated with the user account.

[0123] (3) Color code authentication

[0124] When logging in, users need to enter their username, password, and user type to trigger a two-factor authentication process. The system first requires uploading a unique color code. We try to use the pyzbar decoding library to directly identify the image. If this fails, we enter a multi-round image enhancement process to parse the color QR code content through multiple rounds of image preprocessing (grayscale, adaptive threshold, Otsu binarization, edge enhancement, and color channel separation). After successful decoding, we extract the embedded user ID and facial feature hash value to verify its match with the database record. If the match is successful, Figure 6 Then enter the face recognition authentication. If the color code authentication fails, Figure 7 You will not be able to proceed to the next step of face recognition authentication.

[0125] (4) Face recognition authentication

[0126] After the color code authentication is passed, the system starts the face recognition authentication. The user needs to take a real-time face photo, and the back-end extracts the feature vector through the ViT model and calculates the similarity with the original feature stored in the color code. If the similarity exceeds the preset threshold, it is determined that the same identity authentication is successful. Figure 8 Otherwise, authentication fails. This step can resist photo and video forgery attacks and ensure the validity of the biometric feature.

[0127] (5) Double authentication successful

[0128] After both authentications are passed, the system determines that the user's identity is legitimate, grants access rights, and enters the user's personal information interface. Figure 9 , and record the authentication log including time, device information and authentication results.

[0129] If any authentication fails, the user will not be authenticated, will not be able to access the user personal information interface, and the authentication failure will be recorded in the audit.

[0130] (6) User management and audit

[0131] Administrators can use the backend interface to Figure 10 , manage user accounts, including querying and deleting abnormal accounts. The system automatically records all key operations (color code generation, authentication attempts) to the detection record table such as Figure 11 You can also view the user name, user registered password, user id, user name, user password, user avatar path, user color code path and color code generation time in the database. Figure 12 .

[0132] Figure 13 An example of a physical structure diagram of an electronic device is shown below. Figure 13 As shown, the electronic device may include: a processor 1301, a communication interface 1302, a memory 1303, and a communication bus 1304, wherein the processor 1301, the communication interface 1302, and the memory 1303 communicate with each other via the communication bus 1304. The processor 1301 may call the logic instructions in the memory 1303 to execute a visitor identity authentication method based on color code technology, the method comprising: a user registration phase, comprising: verifying based on the user's uploaded head portrait and user name, if the verification is successful, generating a color QR code for the user; and associating the color QR code and its generation time with the user's personal information and storing it in a database; a user authentication phase, comprising: obtaining the color QR code presented by the user and collecting the user's real-time head portrait; decoding the color QR code to obtain registered facial features; processing the user's real-time head portrait using a visual Transformer-based face recognition model to extract current facial features; and determining whether the registered facial features match the current facial features. If so, the identity authentication is passed; otherwise, the identity authentication is rejected.

[0133] In addition, when the logic instructions in the above-mentioned memory 1303 are implemented in the form of a software functional unit and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0134] An embodiment of the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the visitor identity authentication method based on color code technology provided by the above-mentioned method embodiments.

[0135] An embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the visitor identity authentication method based on color code technology provided by the above-mentioned method embodiments is implemented.

[0136] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A visitor identity authentication method based on color code technology, characterized in that: include: The user registration phase includes: verifying the user's uploaded profile picture and username. If the verification is successful, a color QR code is generated for the user; and the color QR code and its generation time are associated with the user's personal information and stored in the database; The user authentication stage includes: obtaining the color QR code presented by the user and collecting the user's real-time profile picture; decoding the color QR code to obtain the registered facial features; using the visual Transformer-based face recognition model to process the user's real-time profile picture to extract the current facial features; judging whether the registered facial features match the current facial features. If so, the identity authentication is passed; otherwise, the identity authentication is rejected.

2. The visitor identity authentication method based on color code technology according to claim 1 is characterized in that: Determining whether the registered facial features match the current facial features specifically includes: The cosine similarity between the registered facial features and the current facial features is calculated. If the cosine similarity is greater than a set threshold, the two are considered to match, otherwise they are not matched.

3. The visitor identity authentication method based on color code technology according to claim 1 is characterized in that: The method of generating a color QR code for the user specifically includes: A visual Transformer-based face recognition model is used to process user-uploaded avatars to obtain registered facial features. A standard QR code encoding mechanism is used to convert the user's registered facial features and username into a two-dimensional code matrix consisting of black and white modules. For the two-dimensional code matrix, each adjacent m×m module is used as a block to divide the two-dimensional code matrix into several blocks, and each block is assigned a color to obtain an initial color QR code. The contrast and sharpness of the initial color QR code are enhanced to obtain a final color QR code, where m is a positive integer.

4. The visitor identity authentication method based on color code technology according to claim 1 is characterized in that: Before decoding the color QR code to obtain the registered facial features, the method further includes: determining whether the color QR code is valid, specifically including: checking whether the color QR code is damaged and / or expired and / or matches the associated user personal information; if the color QR code is not damaged, has not expired and matches the associated user personal information, then the color QR code is valid; Correspondingly, if the color QR code is valid, the color QR code is decoded to obtain the registered facial features; if it is invalid, the authentication process is terminated.

5. The visitor identity authentication method based on color code technology according to claim 1 is characterized in that: The decoding of the color QR code to obtain the registered facial features specifically includes: If the color QR code is directly recognized using the preset decoding library and fails, multiple rounds of image enhancement process are entered to obtain an enhanced color QR code, and then the enhanced color QR code is recognized using the preset decoding library to obtain registered facial features; the image enhancement process includes: a grayscale processing stage, a threshold processing stage, an edge detection stage and a binarization processing stage; Among them, the grayscale processing stage includes converting the color QR code into a grayscale image; the threshold processing stage includes using the adaptive threshold method to calculate the threshold when the lighting is uneven; when the brightness distribution is uniform, the threshold is calculated using the Otsu threshold method; the edge detection stage includes using the Canny edge detection algorithm to extract the contour information in the image and strengthening the edge through the expansion operation; the binarization processing stage includes extracting the R, G, and B color channel images of the image, and using the calculated threshold to binarize the three color channel images separately.

6. The visitor identity authentication system based on color code technology is characterized by: include: The user function module is used to verify the user's uploaded avatar and username during the user registration phase. If the verification is successful, a color QR code is generated for the user; the color QR code and its generation time are associated with the user's personal information and stored in the database; The dual identity authentication module is used to obtain the color QR code presented by the user and collect the user's real-time head portrait during the user authentication stage; decode the color QR code to obtain the registered facial features; use the visual Transformer-based face recognition model to process the user's real-time head portrait to extract the current facial features; determine whether the registered facial features match the current facial features. If so, the identity authentication is passed; otherwise, the identity authentication is rejected.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.