A distortion-corrected face recognition algorithm for large-angle recognition
Through multi-level distortion correction and deep learning feature extraction, combined with adaptive image enhancement, it solves the problems of face recognition technology in distortion correction at large angles and poor adaptability to complex environments, and improves recognition accuracy and adaptability.
Patent Information
- Application Number
- CN202410997050.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-07-24
AI Technical Summary
Existing face recognition technology has static parameter settings when correcting distortion at large angles, and cannot flexibly cope with distortion at different angles. Deep learning feature extraction is insufficient, resulting in low recognition accuracy and poor adaptability to complex environments.
It adopts multi-level distortion correction technology, combines CNN convolutional neural network and adaptive image enhancement, optimizes distortion correction parameters through gradient descent, uses deep learning models to extract facial features, and improves the versatility and applicability of the algorithm through model transfer learning.
It significantly improves the accuracy of large-angle face recognition and adaptability to complex environments, enhances the ability to handle distortion at different angles, and reduces the misrecognition rate.
Smart Images

Figure CN118522062B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and more specifically to a large-angle recognition algorithm for distortion-corrected face recognition. Background Art
[0002] In face recognition technology, when there is a large angular deviation between the camera and the face, the acquired image often has serious distortion, which greatly reduces the accuracy of face recognition. At present, some technologies have attempted to solve this problem, such as methods based on spherical transformation, but these methods have some technical problems. These problems mainly include: the parameter settings are too static during distortion correction and cannot flexibly cope with distortion at different angles; in terms of deep learning feature extraction, some methods fail to fully utilize the learning ability of deep learning models on large-scale data, resulting in insufficient feature extraction at specific angles and inability to fully utilize high-dimensional information, including expression differences and light and shadow changes, resulting in limited recognition performance. At the same time, existing face recognition algorithms have certain limitations on passive or active deformations caused by the non-fixed angle, standing position, height and detection distance between the person to be identified and the camera, resulting in a low chance of successful face recognition. Summary of the invention
[0003] In view of the deficiencies of the above-mentioned technologies, the present invention discloses a distortion-corrected face recognition large-angle recognition algorithm, which can correct the distortion in face images and complete large-angle face recognition.
[0004] In order to achieve the above technical effects, the present invention adopts the following technical solutions:
[0005] A distortion-corrected face recognition large-angle recognition algorithm includes the following steps:
[0006] Step 1: Image acquisition, receiving an image containing a face;
[0007] Step 2: Face detection and positioning: Use the Haar cascade classification algorithm to locate the face in the image and select the face area;
[0008] Step 3: dynamically adjust the distortion correction parameters according to the angle and position of the face image to perform multi-level distortion correction;
[0009] Calculate the face angle, initialize the distortion correction parameters according to the face angle, and perform multi-level distortion correction, including the first layer of coarse correction based on angle, the second layer of fine correction based on local features, and the third layer of correction optimization based on deep learning. In the multi-level distortion correction process, the distortion correction parameters are dynamically adjusted through gradient descent to achieve iterative optimization of the correction effect.
[0010] Step 4: Extract facial features;
[0011] The facial features of the corrected image are extracted by a CNN convolutional neural network model, wherein the CNN convolutional neural network model includes an information input module, a CNN algorithm model, a multi-scale feature fusion module, an attention mechanism module and an output module, wherein the CNN algorithm model includes a convolution layer, an activation layer, a pooling layer, and a fully connected layer, wherein the output end of the information input module is connected to the input end of the CNN algorithm model, the output end of the attention mechanism module is connected to the input end of the CNN algorithm model, the output end of the CNN algorithm model is connected to the input end of the multi-scale feature fusion module, and the output end of the multi-scale feature fusion module is connected to the input end of the output module;
[0012] Step 5: Adaptive image enhancement;
[0013] The image brightness and contrast parameters are dynamically adjusted according to the image quality and environmental conditions through the adaptive histogram equalization method to improve the image clarity;
[0014] Step 6: Perform face recognition;
[0015] Compare the enhanced portrait features with the pre-stored face feature library to determine the identity of the face;
[0016] Step 7: Model transfer learning;
[0017] By training the model on a large-scale dataset and migrating it to the target task, the algorithm has better versatility and applicability in feature extraction of wide-angle face images.
[0018] As a further embodiment of the present invention, the first layer of angle-based rough correction makes the face image close to the frontal perspective according to the calculated face angle through affine transformation and perspective transformation, the second layer of local feature-based fine correction further corrects the position and shape of the face through thin plate spline interpolation, and the third layer of deep learning-based correction optimization fits the image distortion through an image distortion correction model based on radial basis function;
[0019] The affine transformation expression is:
[0020] (1)
[0021] In formula (1), represents the transformed coordinates, represents the coordinates before transformation, is the weighting factor, represents the degree of freedom coefficient in the affine transformation;
[0022] The expression of the perspective transformation is:
[0023] (2)
[0024] In formula (2), (x, y, z) represents the coordinates before transformation, and (X, Y, Z) represents the coordinates after transformation. Indicates that the image changes linearly. Used to generate image perspective transformation, Indicates image translation;
[0025] The output expression of the image distortion correction model based on radial basis function is:
[0026] (3)
[0027] In formula (3), Indicates the output result, represents the width of the center point of the function, h represents the number of neurons in the hidden layer, represents the weight from the hidden layer to the output layer, a represents the regularization parameter, represents the i-th center point, represents the selection coefficient, Represents the learning rate.
[0028] As a further embodiment of the present invention, the face angle calculation method is:
[0029] 1) Key point detection: Use Dlib's 68-point face key point detection method to determine the key points of the face, including the corners of the eyes, the end of the eyes, the tip of the nose, and the corners of the mouth;
[0030] 2) Establish a model for calculating face angles. Based on the classification model, the input is a face image or key point position features, and the output is a face angle. The model learns the mapping relationship from input features to output angles;
[0031] 3) Perform angle calculations and use geometric relationships to calculate the yaw, pitch, and roll angles;
[0032] 4) Optimization and adjustment: adjusting the calculated face angle through nonlinear optimization algorithm;
[0033] 5) Verification and evaluation: A face image dataset containing different angles and expressions is used to verify and evaluate the face angle model.
[0034] As a further embodiment of the present invention, the yaw angle is the angle between the vector between the two eye key points and the horizontal line, the pitch angle is the angle between the vector between the nose tip to the chin key points and the vertical line, and the roll angle is the angle between the normal of the plane formed by the two eye key points and the nose tip key point and the vertical line.
[0035] As a further embodiment of the present invention, the information input module in the CNN convolutional neural network model receives the distortion-corrected image through a communication interface and a communication protocol, the convolution layer performs a convolution operation on the input image through a convolution kernel to extract features of the input image, the CNN convolutional neural network model uses a ReLu function to perform nonlinear changes to increase the nonlinear expression ability of the model, the pooling layer reduces the dimension and complexity of the feature map through maximum pooling and average pooling, and the pooling operation is invariant to the illumination changes in the input image, the fully connected layer maps the features extracted by the convolution layer and the pooling layer to the sample labeling space, and outputs facial features, the multi-scale feature fusion module captures expressions and light and shadow changes of different scales through spatial pyramid pooling technology, and fuses features of different scales through a multi-scale feature fusion method, the attention mechanism module is used to enhance the ability to focus on important areas in the input data, including eyes, nose, and mouth, and the output module is used to output the extracted portrait features.
[0036] As a further embodiment of the present invention, the convolution mathematical expression is:
[0037] (4)
[0038] In formula (4), represents the width factor, represents the resolution factor, Represents the output of the convolutional layer of the CNN convolutional model, Represents CNN convolution Layer output, represents the convolution kernel, represents the convolution operation, represents the output feature map channel, represents the input mapping depth, represents the sliding step of the feature map, Represents the bias of the convolutional layer of the CNN convolution model, represents the weight parameter;
[0039] The convolution activation function is:
[0040] (5)
[0041] In formula (5), represents the batch normalization processing of user image information, represents the activation function of the CNN convolutional model, Represents the convolutional module of the recognition model;
[0042] The pooling mathematical expression is:
[0043] (6)
[0044] In formula (6), Indicates sampling operation. Represents the output of the pooling module in the CNN convolutional model, Represents the bias of the pooling module in the CNN volume integration model, represents the output feature map channel, represents the input mapping depth, represents the sliding step of the feature map, represents the bias factor, Indicates the input information. Represents the weight parameter.
[0045] As a further embodiment of the present invention, the method for implementing the adaptive histogram equalization is:
[0046] 1) Image segmentation: divide the input image into non-overlapping sub-regions;
[0047] 2) Calculate the histogram of the sub-region, and calculate the grayscale histogram for each sub-region;
[0048] 3) Apply histogram equalization to the sub-regions, and equalize the histogram of each sub-region by mapping the input pixel value to the output pixel value;
[0049] 4) Dealing with boundary effects, using interpolation to balance sub-region boundaries;
[0050] 5) Synthesize the output image, and stitch the pixel values of all equalized sub-regions according to the corresponding positions of the original image to form the final output image;
[0051] 6) Dynamic adjustment, using image quality assessment algorithms to determine whether contrast needs to be adjusted and brightness parameters to adjust according to changes in ambient light.
[0052] Positive beneficial effects:
[0053] Based on a deep understanding of the defects of the prior art, the present invention provides a new distortion-corrected face recognition algorithm for wide-angle recognition, which solves the problems of information loss, insufficient feature extraction, poor adaptability to complex environments, and high misrecognition rate caused by image distortion in the prior art. First, the multi-level distortion correction technology makes the present invention more flexible and adaptable when processing wide-angle face images, and can effectively deal with image distortion at different angles and improve the correction effect. Secondly, deep learning face feature extraction enables the algorithm to capture the key features in wide-angle face images more comprehensively and accurately, significantly improving the recognition accuracy. Adaptive image enhancement technology improves the adaptability of the algorithm to complex environments, enabling it to perform well under various lighting conditions and background conditions. Finally, the introduction of model transfer learning enables the algorithm to have better generalization capabilities. By training the model on a large-scale data set, it can better adapt to new wide-angle face recognition tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0055] Figure 1 This is a schematic diagram of a large-angle recognition algorithm flow for distortion correction face recognition of the present invention;
[0056] Figure 2 A perspective transformation diagram of a distortion-corrected face recognition large-angle recognition algorithm in the present invention;
[0057] Figure 3 A schematic diagram of the structure of a CNN convolutional neural network model for a distortion-corrected face recognition large-angle recognition algorithm in the present invention;
[0058] Figure 4 This is a face angle calculation flow chart of a distortion-corrected face recognition large-angle recognition algorithm in the present invention. DETAILED DESCRIPTION
[0059] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0060] like Figure 1-Figure 4 As shown, a distortion correction face recognition large angle recognition algorithm includes the following steps:
[0061] Step 1: Image acquisition, receiving an image containing a face;
[0062] Step 2: Face detection and positioning: Use the Haar cascade classification algorithm to locate the face in the image and select the face area;
[0063] Step 3: dynamically adjust the distortion correction parameters according to the angle and position of the face image to perform multi-level distortion correction;
[0064] Calculate the face angle, initialize the distortion correction parameters according to the face angle, and perform multi-level distortion correction, including the first layer of coarse correction based on angle, the second layer of fine correction based on local features, and the third layer of correction optimization based on deep learning. In the multi-level distortion correction process, the distortion correction parameters are dynamically adjusted through gradient descent to achieve iterative optimization of the correction effect.
[0065] Step 4: Extract facial features;
[0066] The facial features of the corrected image are extracted by a CNN convolutional neural network model, wherein the CNN convolutional neural network model includes an information input module, a CNN algorithm model, a multi-scale feature fusion module, an attention mechanism module and an output module, wherein the CNN algorithm model includes a convolution layer, an activation layer, a pooling layer, and a fully connected layer, wherein the output end of the information input module is connected to the input end of the CNN algorithm model, the output end of the attention mechanism module is connected to the input end of the CNN algorithm model, the output end of the CNN algorithm model is connected to the input end of the multi-scale feature fusion module, and the output end of the multi-scale feature fusion module is connected to the input end of the output module;
[0067] Step 5: Adaptive image enhancement;
[0068] The image brightness and contrast parameters are dynamically adjusted according to the image quality and environmental conditions through the adaptive histogram equalization method to improve the image clarity;
[0069] Step 6: Perform face recognition;
[0070] Compare the enhanced portrait features with the pre-stored face feature library to determine the identity of the face;
[0071] Step 7: Model transfer learning;
[0072] By training the model on a large-scale dataset and migrating it to the target task, the algorithm has better versatility and applicability in feature extraction of wide-angle face images.
[0073] In a specific embodiment, the Haar cascade classification algorithm first loads a pre-trained Haar cascade classification model, reads the image to be detected and converts it into a grayscale image, uses the loaded model to perform sliding window detection on the grayscale image, calculates the Haar features at each window position and applies the cascade classifier to determine whether the window contains a face, and marks the detected face position with a rectangular frame.
[0074] In the present invention, the first layer of coarse correction based on angle makes the face image close to the frontal perspective through affine transformation and perspective transformation according to the calculated face angle, the second layer of fine correction based on local features further corrects the position and shape of the face through thin plate spline interpolation, and the third layer of correction optimization based on deep learning fits the image distortion through an image distortion correction model based on radial basis function.
[0075] In a specific embodiment, the first layer of coarse correction based on angle applies affine transformation to make the face image close to the frontal perspective according to the calculated face angle, keeps the straight lines and parallel lines in the original image straight and parallel in the output image, and uses perspective transformation to simulate the effect of near objects being larger and far objects being smaller when the human eye observes objects to adjust the face angle. The second layer of fine correction based on local features extracts local features of the face image, such as the position information of key points of the eyes, nose, and mouth, based on the first layer of correction, and uses the extracted local feature point information to interpolate the face image through thin plate spline interpolation. Further position and shape correction, the third layer is based on radial basis function image distortion correction. The value of the radial basis function depends on the distance between the input vector and the center. It is used to fit the nonlinear distortion in the image. The parameters in the model are optimized through back propagation algorithm and gradient descent to minimize the difference between the predicted distortion and the minimum distortion. Iterative training is used to accurately fit the distortion in the image and output the corrected face image. When the yaw angle, pitch angle and roll angle of the face are all less than 20°, the face image can be directly extracted for feature extraction after the first layer of distortion correction to reduce the time for large-angle face recognition.
[0076] The affine transformation expression is:
[0077] (1)
[0078] In formula (1), represents the transformed coordinates, represents the coordinates before transformation, is the weighting factor, represents the degree of freedom coefficient in the affine transformation;
[0079] In actual programming, various programming languages can be used to implement affine transformation. The following is a sample code that uses Python and OpenCV library to implement affine transformation:
[0080] Copy code import cv2
[0081] import numpy as np
[0082] # Set the original point coordinates and translation vector
[0083] # Note: The point coordinates set here should be the points in the original image
[0084] pts1 = np.float32([[0,0], [0,1], [1,1]])
[0085] # The translation vector can be set to (0,0) to keep the original position unchanged, or set to other values for translation
[0086] pts2 = np.float32([[50,50], [50,150], [200,150]])
[0087] # Calculate the affine transformation matrix
[0088] M = cv2.getAffineTransform(pts1, pts2)
[0089] # Read the image
[0090] image = cv2.imread('input.jpg')
[0091] # Apply affine transformation
[0092] transformed = cv2.warpAffine(image, M, (image.shape[1], image.shape[0]))
[0093] # Display the image
[0094] cv2.imshow('Original', image)
[0095] cv2.imshow('Transformed', transformed)
[0096] cv2.waitKey(0)
[0097] cv2.destroyAllWindows()
[0098] This code first sets the original point coordinates and translation vector, then calculates the affine transformation matrix using the cv2.getAffineTransform function. After that, it reads an image file and applies the affine transformation using the cv2.warpAffine function. Finally, the code displays the original image and the transformed image. Replace 'input.jpg' in the example with the image file name according to the actual situation, and adjust the original point coordinates and translation vector as needed.
[0099] In a specific embodiment, the affine transformation has 6 degrees of freedom, which is represented by a 2×3 transformation matrix, wherein the 2×2 submatrix controls scaling, rotation, and shearing, and the third column controls translation, wherein the rotation calculates the required rotation angle by obtaining the face angle and converts it into a rotation matrix, and the adjusted affine transformation matrix is used to transform the original image to correct the face angle, and the expression of the rotation matrix is:
[0100] (2)
[0101] In formula (2), Table roll angle rotates around the x-axis, Indicates that the pitch angle rotates around the Y axis. Indicates the yaw angle rotation around the z-axis.
[0102] The expression of the perspective transformation is:
[0103] (3)
[0104] In formula (3), (x, y, z) represents the coordinates before transformation, and (X, Y, Z) represents the coordinates after transformation. Indicates that the image changes linearly. Used to generate image perspective transformation, Indicates image translation;
[0105] In a specific embodiment, the perspective transformation principle is as follows: Figure 2 As shown, the perspective transformation projects the original image to a new viewing plane, that is, by applying the perspective transformation matrix to the entire original image, each pixel in the original image is mapped to a new position through the perspective transformation matrix, thereby obtaining a large-angle recognition corrected image projected on the new viewing plane.
[0106] The output expression of the image distortion correction model based on radial basis function is:
[0107] (4)
[0108] In formula (4), Indicates the output result, represents the width of the center point of the function, h represents the number of neurons in the hidden layer, represents the weight from the hidden layer to the output layer, a represents the regularization parameter, represents the i-th center point, represents the selection coefficient, Represents the learning rate.
[0109] In a specific embodiment, the original mathematical expression of the radial basis function is:
[0110] (5)
[0111] By introducing the selection coefficient Control the contribution of each radial basis value to the fitting result and introduce the learning rate The response range of the radial basis function is limited to reduce the amount of calculation and improve the calculation efficiency. The regularization strength is controlled by introducing the regularization parameter a. The logarithmic function is used to optimize the value of the regularization parameter a according to the actual situation of the model to affect the smoothness and generalization ability of the final solution, while preventing overfitting.
[0112] The activation function in the radial basis function network (RBFN) has the general form:
[0113] \[ f(x) = e^{-\frac{||x - c||^2}{2\sigma^2}} \]
[0114] Where \( x \) is the input vector, \( c \) is the center vector, and \( \sigma \) is the shape parameter, also known as the learning rate, which determines the width of the function.
[0115] In actual programming, the implementation of radial basis function networks may use various libraries, such as Python's TensorFlow or PyTorch. The following is a simple example showing how to implement an RBFN using TensorFlow in Python:
[0116] ```Python
[0117] import tensorflow as tf
[0118] from tensorflow import keras
[0119] from tensorflow.keras import layers
[0120] # Assume that the present invention has an input data set X and a corresponding output data set y
[0121] # X = ... (input data)
[0122] # y = ... (output data)
[0123] # Create a sequence model
[0124] model = keras.Sequential([
[0125] # Add a radial basis function layer where centers is a list of center vectors and stddev is the learning rate for the shape parameter
[0126] keras.layers.RadialBasisFunction(centers=np.random.rand(10, input_dim), stddev=0.1),
[0127] # Add a fully connected layer for classification or regression
[0128] keras.layers.Dense(units=output_dim, activation='sigmoid') # For binary classification problems
[0129] # keras.layers.Dense(units=output_dim) # For multi-classification or regression problems ])
[0131] # Compile the model
[0132] model.compile(optimizer='adam', loss='binary_crossentropy') # For binary classification problems
[0133] # model.compile(optimizer='adam', loss='categorical_crossentropy') #For multi-classification problems
[0134] # model.compile(optimizer='adam', loss='mean_squared_error') # For regression problems
[0135] # Train the model
[0136] model.fit(X, y, epochs=100, batch_size=32, validation_split=0.2)
[0137] # Evaluate the model
[0138] model.evaluate(X, y)
[0139] ```
[0140] In this example, I first imported the TensorFlow and keras libraries, and then created a sequence model. In the model, I added a `RadialBasisFunction` layer, which accepts a learning rate for the center vector and shape parameters. Then, I added a fully connected layer with a number of neurons that matches the output dimension and uses a sigmoid activation function for binary classification. For multi-classification or regression problems, I can change the activation function and loss function. Finally, I compiled and trained the model and evaluated its performance. This is just a simple example.
[0141] In a specific embodiment, the multi-level distortion correction dynamically adjusts the distortion correction parameters according to the angle and position of the face image to correct the distorted face. The effect of the multi-level distortion correction is determined by comparing the accuracy of the multi-level distortion correction with the accuracy of the single-level distortion correction. The correction comparison results are shown in Table 1:
[0142] Table 1: Comparison of correction effects
[0143]
[0144] In Table 1, the yaw angle is represented by Y, the pitch angle is represented by P, and the roll angle is represented by R. It can be seen from the results in Table 1 that when the yaw angle, roll angle and pitch angle of the face angle are not greater than 20 degrees, the accuracy of the multi-level correction is consistent with the accuracy of the single-level correction, and both can achieve 100% correction. When the yaw angle, roll angle and pitch angle of the face angle are greater than 20 degrees, the accuracy of the hierarchical distortion correction decreases with the increase of the angle, while in the multi-level correction, the three levels work together to keep the correction accuracy at 100%. At the same time, it can be seen that when the yaw angle, pitch angle and roll angle of the face are all less than 20°, the accuracy of the image can reach 100% after the first layer of correction.
[0145] In the present invention, the face angle calculation method is:
[0146] 1) Key point detection, using Dlib's 68-point face key point detection to determine the key points of the face, including the corners of the eyes, the end of the eyes, the tip of the nose, and the corners of the mouth;
[0147] 2) Establish a model for calculating face angles. Based on the classification model, the input is a face image or key point position features, and the output is a face angle. The model learns the mapping relationship from input features to output angles;
[0148] 3) Perform angle calculations and use geometric relationships to calculate the yaw, pitch, and roll angles;
[0149] 4) Optimization and adjustment: adjusting the calculated face angle through nonlinear optimization algorithm;
[0150] 5) Verification and evaluation: A face image dataset containing different angles and expressions is used to verify and evaluate the face angle model.
[0151] In the present invention, the yaw angle is the angle between the vector between the two eye key points and the horizontal line, the pitch angle is the angle between the vector from the nose tip to the chin key points and the vertical line, and the roll angle is the angle between the normal of the plane formed by the two eye key points and the nose tip key point and the vertical line.
[0152] In the present invention, the information input module in the CNN convolutional neural network model receives the distortion-corrected image through a communication interface and a communication protocol, the convolution layer performs a convolution operation on the input image through a convolution kernel to extract the features of the input image, the CNN convolutional neural network model uses a ReLu function to perform nonlinear changes to increase the nonlinear expression ability of the model, the pooling layer reduces the dimension and complexity of the feature map through maximum pooling and average pooling, the pooling operation is invariant to the illumination changes in the input image, the fully connected layer maps the features extracted by the convolution layer and the pooling layer to the sample labeling space, and outputs the facial features, the multi-scale feature fusion module captures expressions and light and shadow changes of different scales through spatial pyramid pooling technology, and fuses features of different scales through a multi-scale feature fusion method, the attention mechanism module is used to enhance the ability to focus on important areas in the input data, including eyes, nose, and mouth, and the output module is used to output the extracted portrait features.
[0153] In the present invention, the convolution mathematical expression is:
[0154] (6)
[0155] In formula (6), represents the width factor, represents the resolution factor, Represents the output of the convolutional layer of the CNN convolutional model, Represents CNN convolution Layer output, represents the convolution kernel, represents the convolution operation, represents the output feature map channel, represents the input mapping depth, represents the sliding step of the feature map, Represents the bias of the convolutional layer of the CNN convolution model, represents the weight parameter;
[0156] In Python, convolution operations can be easily implemented using TensorFlow or PyTorch libraries. Here is a sample code using TensorFlow:
[0157] Copy code import tensorflow as tf
[0158] # Assume the shape of input image X is (batch_size, height, width, channels)
[0159] X = tf.random.normal((1, 32, 32, 3)) # Example input
[0160] # Create a convolution kernel with a shape of (height, width, input_channels, output_channels)
[0161] # For example, a 3x3 convolution kernel is used to process 3 input channels and produce 6 output channels
[0162] conv_kernel = tf.random.normal((3, 3, 3, 6))
[0163] # Apply convolution operation, using 'VALID' border filling mode, without border extension
[0164] Y = tf.nn.conv2d(X, conv_kernel, strides=(1, 1, 1, 1), padding='VALID')
[0165] # Assume that ReLU activation function is used
[0166] Y = tf.nn.relu(Y)
[0167] # Print the shape of the output feature map
[0168] print(Y.shape)
[0169] The predecessor of the convolution mathematical formula is the convolution operation in mathematics. Convolution is the process of combining two functions. and Generate the third function A mathematical operator that characterizes the function and The area of the overlapping part after flipping and translation is used to describe the interaction between two functions or sequences. The convolution formula is:
[0170] (7)
[0171] In one embodiment, using the sample code of TensorFlow:
[0172] Copy code import tensorflow as tf
[0173] # Assume the shape of input image X is (batch_size, height, width, channels)
[0174] X = tf.random.normal((1, 32, 32, 3)) # Example input
[0175] # Create a convolution kernel with a shape of (height, width, input_channels, output_channels)
[0176] # For example, a 3x3 convolution kernel is used to process 3 input channels and produce 6 output channels
[0177] conv_kernel = tf.random.normal((3, 3, 3, 6))
[0178] # Apply convolution operation, using 'VALID' border filling mode, without border extension
[0179] Y = tf.nn.conv2d(X, conv_kernel, strides=(1, 1, 1, 1), padding='VALID')
[0180] # Assume that ReLU activation function is used
[0181] Y = tf.nn.relu(Y)
[0182] # Print the shape of the output feature map
[0183] print(Y.shape)
[0184] The convolution formula is expressed as a matrix:
[0185] (8)
[0186] Furthermore, the convolution formula can be expressed as
[0187] (9)
[0188] In formula (9), Indicates Layer Features, Indicates for All associated features of the layer and Layer Convolution kernel Do the convolution operation and sum it, Represents the bias parameter.
[0189] In a specific embodiment, a width factor is introduced to control the output width of the convolution layer to control the size of the output feature map, a resolution factor is introduced to control the output resolution of the convolution layer, a weight parameter is introduced to represent the weight of each convolution kernel, and the convolution kernel weight is operated with the local area of the input feature map during the convolution process to extract the features of the local area. The mapping channel, mapping sliding step, mapping depth and weight parameters are adjusted to adapt to facial images with different degrees of distortion.
[0190] In a specific embodiment, the calculation of the CNN convolution layer requires hardware support, and the hardware includes a high-performance computing unit GPU, a large-capacity memory VRAM, a storage device SSD, an Ethernet interface and a heat sink; the high-performance computing unit GPU is used to improve the data processing speed and perform high-speed convolution calculations and residual calculations, the large-capacity memory VRAM is used to store model parameters and intermediate calculation results, the storage device SSD is used to read and write data, the Ethernet interface is used for data transmission and communication, and the heat sink is used to process the large amount of heat generated by the high-performance computing unit GPU during operation to ensure the stability and reliability of the device.
[0191] The convolution activation function is:
[0192] (10)
[0193] In formula (10), represents the batch normalization processing of user image information, represents the activation function of the CNN convolutional model, Represents the convolutional module of the recognition model;
[0194] The pooling calculation formula is:
[0195] (11)
[0196] In formula (11), Indicates sampling operation. Represents the output of the pooling module in the CNN convolutional model, Represents the bias of the pooling module in the CNN volume integration model, represents the output feature map channel, represents the input mapping depth, represents the sliding step of the feature map, represents the bias factor, Indicates the input information. Represents the weight parameter. Example code for using TensorFlow to implement the ReLU activation function and the maximum pooling operation:
[0197] Copy code import tensorflow as tf
[0198] # Assume the shape of the input feature map X is (batch_size, height, width, channels)
[0199] X = tf.random.normal((1, 32, 32, 3)) # Example input
[0200] # Apply ReLU activation function
[0201] Y_relu = tf.nn.relu(X)
[0202] # Apply a max pooling operation, using a 2x2 pooling window, a stride of 2, and no border extension
[0203] Y_pool = tf.nn.max_pool(Y_relu, ksize=[1, 2, 2, 1], strides=[1, 2, 2,1], padding='VALID')
[0204] # Print the shape of the output feature map
[0205] print(Y_pool.shape)
[0206] In this example, the present invention first creates a random input feature map X. Then the present invention applies the ReLU activation function using the tf.nn.relu function and applies the maximum pooling operation using the tf.nn.max_pool function. Finally, the present invention prints out the shape of the output feature map Y_pool, which is an exemplary embodiment of the present invention.
[0207] In a specific embodiment, by comparing the traditional image processing method for extracting large-angle distorted portrait features with the CNN convolutional neural network model for extracting large-angle distorted portrait features, the effect of the CNN convolutional neural network model on extracting facial features from the corrected image is confirmed. The comparison results are shown in Table 2:
[0208] Table 2: Face feature extraction comparison results record table
[0209]
[0210] According to the data in Table 2, it can be concluded that the CNN convolutional neural network model can extract face images more effectively, with higher extraction speed and higher extraction accuracy.
[0211] In the present invention, the method for implementing the adaptive histogram equalization is:
[0212] 1) Image segmentation: divide the input image into non-overlapping sub-regions;
[0213] 2) Calculate the histogram of the sub-region, and calculate the grayscale histogram for each sub-region;
[0214] 3) Apply histogram equalization to the sub-regions, and equalize the histogram of each sub-region by mapping the input pixel value to the output pixel value;
[0215] 4) Dealing with boundary effects, using interpolation to balance sub-region boundaries;
[0216] 5) Synthesize the output image, and stitch the pixel values of all equalized sub-regions according to the corresponding positions of the original image to form the final output image;
[0217] 6) Dynamic adjustment, using image quality assessment algorithms to determine whether contrast needs to be adjusted and brightness parameters to adjust according to changes in ambient light.
[0218] In a specific embodiment, adaptive histogram equalization makes the histogram of the image uniform by redistributing the pixel values of the image, thereby enhancing the brightness difference between different areas in the image. This process adjusts the equalization effect according to the local characteristics of the image to achieve adaptivity. Adaptive histogram equalization grays the input image to convert the color image into a grayscale image, then calculates the histogram of the grayscale image, accumulates the frequency of each grayscale level to obtain a cumulative histogram to determine the proportion of each grayscale level in the equalized image, uses the cumulative histogram for each pixel to map the original grayscale level to the new grayscale level, and uses the mapped grayscale level to replace each pixel value in the original image, which will generate an equalized image, improve the brightness difference, and enhance the contrast.
[0219] In a specific embodiment, the enhanced portrait feature vector is compared with a pre-stored face feature library, which contains face feature vectors of multiple known identities. The cosine similarity measurement method is used to calculate the similarity between the enhanced portrait feature vector and the feature vector in the feature library, and the identity corresponding to the feature vector with the highest similarity is selected as the recognition result. If the similarity is higher than a preset threshold, the recognition is considered successful, otherwise the recognition is considered failed.
[0220] In a specific embodiment, model transfer learning includes source domain pre-training model, transfer learning preparation, magic transfer, model fine-tuning, model evaluation and optimization, and face recognition and application, wherein model fine-tuning uses the data set of the target domain to adapt model learning to the specific characteristics of the target domain, and model evaluation and optimization uses the verification set of the target domain to evaluate the fine-tuned model and calculate its performance indicators in the target domain.
[0221] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that these specific embodiments are only illustrative, and those skilled in the art may omit, replace, and change the details of the above methods and systems in various ways without departing from the principles and essence of the present invention. For example, merging the above method steps so as to perform substantially the same functions in substantially the same manner to achieve substantially the same results is within the scope of the present invention. Therefore, the scope of the present invention is limited only by the appended claims.
Claims
1. A distortion-corrected face recognition algorithm with large angles, characterized by: The following steps are involved: Step 1: Image acquisition, receiving an image containing a face; Step 2: Face detection and positioning: Use the Haar cascade classification algorithm to locate the face in the image and select the face area; Step 3: dynamically adjust the distortion correction parameters according to the angle and position of the face image to perform multi-level distortion correction; Calculate the face angle, initialize the distortion correction parameters according to the face angle, and perform multi-level distortion correction, including the first layer of coarse correction based on angle, the second layer of fine correction based on local features, and the third layer of correction optimization based on deep learning. In the multi-level distortion correction process, the distortion correction parameters are dynamically adjusted through gradient descent to achieve iterative optimization of the correction effect. Step 4: Extract facial features; The facial features of the corrected image are extracted by a CNN convolutional neural network model, wherein the CNN convolutional neural network model includes an information input module, a CNN algorithm model, a multi-scale feature fusion module, an attention mechanism module and an output module, wherein the CNN algorithm model includes a convolution layer, an activation layer, a pooling layer, and a fully connected layer, wherein the output end of the information input module is connected to the input end of the CNN algorithm model, the output end of the attention mechanism module is connected to the input end of the CNN algorithm model, the output end of the CNN algorithm model is connected to the input end of the multi-scale feature fusion module, and the output end of the multi-scale feature fusion module is connected to the input end of the output module; Step 5: Adaptive image enhancement; The image brightness and contrast parameters are dynamically adjusted according to the image quality and environmental conditions through the adaptive histogram equalization method to improve the image clarity; Step 6: Perform face recognition; Compare the enhanced portrait features with the pre-stored face feature library to determine the identity of the face; Step 7: Model transfer learning; By training the model on a large-scale dataset and migrating it to the target task, the algorithm has better versatility and applicability in feature extraction of wide-angle face images.
2. The distortion-corrected face recognition algorithm for large-angle recognition according to claim 1, characterized in that: The first layer of angle-based rough correction makes the face image close to the frontal perspective according to the calculated face angle through affine transformation and perspective transformation, the second layer of local feature-based fine correction further corrects the position and shape of the face through thin plate spline interpolation, and the third layer of deep learning-based correction optimization fits the image distortion through an image distortion correction model based on radial basis function; The affine transformation expression is: (1) In formula (1), represents the transformed coordinates, represents the coordinates before transformation, is the weighting factor, represents the degree of freedom coefficient in the affine transformation; The expression of the perspective transformation is: (2) In formula (2), (x, y, z) represents the coordinates before transformation, and (X, Y, Z) represents the coordinates after transformation. Indicates that the image changes linearly. Used to generate image perspective transformation, Indicates image translation; The output expression of the image distortion correction module based on radial basis function is: (3) In formula (3), Indicates the output result, represents the width of the center point of the function, h represents the number of neurons in the hidden layer, represents the weight from the hidden layer to the output layer, a represents the regularization parameter, represents the i-th center point, represents the selection coefficient, Represents the learning rate.
3. The distortion-corrected face recognition algorithm for large-angle recognition according to claim 1, characterized in that: The face angle calculation method is: 1) Key point detection: Use Dlib's 68-point face key point detection method to determine the key points of the face, including the corners of the eyes, the end of the eyes, the tip of the nose, and the corners of the mouth; 2) Establish a model for calculating face angles. Based on the classification model, the input is a face image or key point position features, and the output is a face angle. The model learns the mapping relationship from input features to output angles; 3) Perform angle calculations and use geometric relationships to calculate the yaw, pitch, and roll angles; 4) Optimization and adjustment: adjusting the calculated face angle through nonlinear optimization algorithm; 5) Verification and evaluation: A face image dataset containing different angles and expressions is used to verify and evaluate the face angle model.
4. The distortion-corrected face recognition large-angle recognition algorithm according to claim 3, characterized in that: The yaw angle is the angle between the vector between the two eye key points and the horizontal line, the pitch angle is the angle between the vector from the nose tip to the chin key points and the vertical line, and the roll angle is the angle between the normal of the plane formed by the two eye key points and the nose tip key point and the vertical line.
5. The distortion-corrected face recognition algorithm for large-angle recognition according to claim 1, characterized in that: The information input module in the CNN convolutional neural network model receives the distortion-corrected image through the communication interface and the communication protocol. The convolution layer performs a convolution operation on the input image through the convolution kernel to extract the features of the input image. The CNN convolutional neural network model uses the ReLu function to perform nonlinear changes to increase the nonlinear expression ability of the model. The pooling layer reduces the dimension and complexity of the feature map through maximum pooling and average pooling. The pooling operation is invariant to the illumination changes in the input image. The fully connected layer maps the features extracted by the convolution layer and the pooling layer to the sample label space and outputs the facial features. The multi-scale feature fusion module captures expressions and light and shadow changes of different scales through the spatial pyramid pooling technology, and fuses features of different scales through the multi-scale feature fusion method. The attention mechanism module is used to enhance the ability to focus on important areas in the input data, including eyes, nose, and mouth. The output module is used to output the extracted portrait features.
6. The distortion-corrected face recognition algorithm for large-angle recognition according to claim 1, characterized in that: The convolution mathematical expression is: (4) In formula (4), represents the width factor, represents the resolution factor, Represents the output of the convolutional layer of the CNN convolutional model, Represents CNN convolution Layer output, represents the convolution kernel, represents the convolution operation, represents the output feature map channel, represents the input mapping depth, represents the sliding step of the feature map, Represents the bias of the convolutional layer of the CNN convolution model, represents the weight parameter; The convolution activation function is: (5) In formula (5), represents the batch normalization processing of user image information, represents the activation function of the CNN convolutional model, Represents the convolutional module of the recognition model; The pooling mathematical expression is: (6) In formula (6), Indicates sampling operation. Represents the output of the pooling module in the CNN convolutional model, Represents the bias of the pooling module in the CNN volume integration model, represents the output feature map channel, represents the input mapping depth, represents the sliding step of the feature map, represents the bias factor, Indicates the input information. Represents the weight parameter.
7. The distortion-corrected face recognition algorithm for large-angle recognition according to claim 1, characterized in that: The implementation method of the adaptive histogram equalization is: 1) Image segmentation: divide the input image into non-overlapping sub-regions; 2) Calculate the histogram of the sub-region, and calculate the grayscale histogram for each sub-region; 3) Apply histogram equalization to the sub-regions, and equalize the histogram of each sub-region by mapping the input pixel value to the output pixel value; 4) Dealing with boundary effects, using interpolation to balance sub-region boundaries; 5) Synthesize the output image, and stitch the pixel values of all equalized sub-regions according to the corresponding positions of the original image to form the final output image; 6) Dynamic adjustment, using image quality assessment algorithms to determine whether contrast needs to be adjusted and brightness parameters to adjust according to changes in ambient light.
