Face recognition method and device, computer equipment and storage medium
Through face alignment and histogram equalization processing, combined with PCA and SVM algorithms, texture feature vectors are extracted, which solves the problem of low recognition rate under the influence of environmental factors, and realizes high-precision face recognition of color images.
Patent Information
- Application Number
- CN202510375989.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, face recognition is affected by environmental factors such as lighting, position, and posture in actual applications, resulting in low recognition accuracy, especially in color image data sets.
After face alignment processing and histogram equalization processing, area division is performed, texture feature vectors are extracted, and dimensionality reduction and classification are combined with PCA and SVM algorithms to improve recognition accuracy.
While reducing the influence of environmental and posture factors, the face recognition accuracy of color images is improved and the application scope is expanded.
Smart Images

Figure CN120299075A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of face recognition technology, and in particular, to a face recognition method, device, computer device, and storage medium. Background Art
[0002] With the development of computer technology, face recognition technology has emerged. Face recognition is a typical model recognition technology and image analysis technology, and has important applications in many fields, such as intelligent monitoring, daily life, and the financial field, etc.
[0003] In related technologies, generally, a model of fully convolutional network and sparse representation classification is used to recognize faces. This model is generally trained on a standard grayscale face image dataset. However, in the actual application process, the face images to be recognized collected are inevitably affected by various environmental factors in the actual application scenario, such as illumination, position, posture, etc., resulting in a low accuracy rate of face recognition. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a face recognition method, device, computer device, and computer-readable storage medium that can improve the recognition accuracy of color images of faces.
[0005] In a first aspect, this application provides a face recognition method. The method includes:
[0006] Obtain a to-be-detected image, and perform preprocessing on the to-be-detected image to obtain a first image, where the preprocessing includes one or more of face alignment processing and histogram equalization processing;
[0007] Perform region division on the first image to obtain a plurality of detection regions, and process the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain a texture feature vector of the first image;
[0008] Query in a preset face database based on the texture feature vector of the first image to obtain a face recognition result corresponding to the to-be-detected image.
[0009] In one embodiment, the obtaining the to-be-detected image, and performing preprocessing on the to-be-detected image to obtain a first image includes:
[0010] Perform face alignment processing on the to-be-detected image through a preset face alignment strategy to obtain an initial image;
[0011] Perform equalization processing on the initial image through a preset histogram equalization strategy to obtain a first image.
[0012] In one embodiment, the face alignment process of the image to be detected by a preset face alignment strategy to obtain an initial image includes:
[0013] Determine the coordinates of multiple key points in the image to be detected, where the key points at least include key points of the first part and key points of the second part;
[0014] Based on the coordinates of the key points of the first part and the coordinates of the key points of the second part, calculate the rotation angle, and based on the rotation angle and the midpoint of the key points of the first part and the key points of the second part, perform a rotation process on each of the key points to obtain the adjusted key points;
[0015] Crop the image to be detected with a target size to obtain a cropped image to be detected; and perform coordinate transformation on each of the adjusted key points based on the cropped image to be detected to obtain an initial image.
[0016] In one embodiment, the equalization process of the initial image by a preset histogram equalization strategy to obtain a first image includes:
[0017] Perform statistical processing on the gray values of each pixel point on the initial image to obtain the number of pixel points of each gray value, the total number of pixel points, and calculate the probability of each gray value;
[0018] Based on the probability of each gray value, calculate the cumulative probability of the initial image;
[0019] Perform gray value mapping based on the cumulative probability to obtain the mapped gray value, and based on the mapped gray value, obtain the image equalization gray value;
[0020] Perform equalization adjustment on the initial image based on the image equalization gray value to obtain the first image corresponding to the image to be detected.
[0021] In one embodiment, the process of processing the pixel values of each pixel point in each detection area by a preset pixel value comparison strategy to obtain the texture feature vector of the first image includes:
[0022] For each detection area, based on a preset pixel value comparison strategy, process the pixel values of each pixel point in the detection area to obtain the pixel comparison values of each pixel point, arrange the pixel comparison values of each pixel point in the detection area in a preset order to obtain a target base value, and perform conversion on the target base value to obtain the texture classification feature value of the detection area;
[0023] Perform histogram calculation based on the texture classification feature value to obtain the histogram of the detection area;
[0024] Perform a connection process on the histograms of the respective detection regions to obtain the texture feature vector of the first image.
[0025] In one embodiment, the performing a connection process on the histograms of the respective detection regions to obtain the texture feature vector of the first image includes:
[0026] Perform a connection process on the histograms of the respective detection regions to obtain an initial texture feature vector;
[0027] Calculate the covariance matrix of the initial texture feature vector, and perform eigenvalue decomposition on the covariance matrix to obtain the eigenvalues corresponding to the respective feature dimensions;
[0028] Based on the eigenvalues corresponding to the respective feature dimensions, perform screening to obtain the target feature dimension, and based on the target feature dimension, calculate the feature vector transformation matrix;
[0029] Perform dimensionality reduction processing on the initial texture feature vector through the feature vector transformation matrix to obtain the texture feature vector of the first image.
[0030] In one embodiment, the preset face database includes identification information and texture feature vectors corresponding to multiple pictures; the querying in the preset face database based on the texture feature vector of the first image to obtain the face recognition result corresponding to the image to be detected includes:
[0031] Calculate the similarity between the texture feature vector of the first image and the texture feature vectors corresponding to the respective pictures included in the preset face database through a preset radial deviation kernel function;
[0032] Determine the identification information corresponding to the similarity that meets the preset similarity condition as the face recognition result corresponding to the image to be detected.
[0033] In a second aspect, the present application also provides a face recognition device. The device includes:
[0034] An acquisition module, configured to acquire an image to be detected, and perform preprocessing on the image to be detected to obtain a first image, where the preprocessing includes one or more of face alignment processing and histogram equalization processing;
[0035] A partitioning module, configured to partition the first image into multiple detection regions, and process the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain the texture feature vector of the first image;
[0036] A query module, configured to query in a preset face database based on the texture feature vector of the first image to obtain a face recognition result corresponding to the image to be detected.
[0037] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps in this embodiment are implemented.
[0038] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, the steps in this embodiment are implemented.
[0039] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps in this embodiment are implemented.
[0040] The above-mentioned face recognition method, device, computer device and storage medium, wherein the method includes: obtaining an image to be detected, and preprocessing the image to be detected to obtain a first image. The preprocessing includes one or more of face alignment processing and histogram equalization processing; dividing the first image into multiple detection regions, and processing the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain a texture feature vector of the first image; querying in a preset face database based on the texture feature vector of the first image to obtain a face recognition result corresponding to the image to be detected. By adopting this method, classification can be performed after dimensionality reduction processing of features, achieving accurate classification of color pictures, reducing the influence of external factors such as environment, target pose, and expression on face recognition, improving the accuracy of face recognition, and expanding the application scope. Description of the Drawings
[0041] Figure 1 It is a schematic flowchart of a face recognition method in an embodiment;
[0042] Figure 2 It is a schematic flowchart of the step of obtaining the first image in an embodiment;
[0043] Figure 3 It is a schematic flowchart of the step of obtaining the initial image in an embodiment;
[0044] Figure 4 It is a schematic flowchart of the step of obtaining the first image in an embodiment;
[0045] Figure 5 It is a schematic flowchart of the step of calculating the texture feature vector in an embodiment;
[0046] Figure 6 It is a schematic flowchart of the steps for calculating a texture feature vector in another embodiment;
[0047] Figure 7 It is a structural block diagram of a face recognition device in one embodiment;
[0048] Figure 8 It is an internal structure diagram of a computer device in one embodiment. Specific embodiments
[0049] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] Face recognition is a typical model recognition, image analysis and research problem. It has important application values in the fields of intelligent monitoring, daily life, finance, etc. In traditional technologies, there are face recognition based on convolutional neural network (CNN), face recognition based on fully convolutional network and sparse representation classification, and deep face recognition based on margin cosine loss method. However, face recognition in traditional technologies is usually experimented on standard grayscale face image datasets such as ORL, yale, jaffe, etc., and not enough non-grayscale sample images are collected, resulting in poor face recognition effects for non-grayscale images, and there are limitations in the face recognition effects; secondly, during the image acquisition process, the obtained face images will inevitably be affected by factors such as illumination, position, and posture in different environments, resulting in poor face recognition effects.
[0051] The face recognition method provided in this embodiment combines feature extraction of texture classification and global grayscale feature extraction of the image to be detected through data dimensionality reduction. After preprocessing the image to be detected, dimensionality reduction processing is performed to remove image noise and features of unimportant dimensions in the image, reducing the complexity of LBP (Local Binary Pattern) feature classification. It can also combine with the SVM (Support Vector Machine) algorithm to classify the features after dimensionality reduction, improving the face recognition effect, expanding the application scope of face recognition, achieving accurate recognition of color pictures, and also enhancing the robustness of face recognition, reducing the influence of factors such as environment, posture, and expression on face recognition.
[0052] That is to say, the face recognition method provided in this embodiment can avoid the problem that the face recognition effect is not ideal due to the influence of factors such as illumination, pose, expression, and color. By combining LBP, PCA (Principal Component Analysis), and SVM, a face alignment algorithm is used to correct and preprocess the face in the image. The main face is detected through key points and cropped into pictures of a unified size. LBP is used to extract the texture features of the face image, the PCA algorithm is used to reduce the dimension of the local features, reduce the influence between data components, and the SVM algorithm is used to classify the features. The similarity is estimated through the radial deviation RBF among them. Experiments can be carried out on the color picture dataset to improve the face recognition effect of this case. By combining preprocessing of the dataset, feature dimension reduction processing, and feature classification, the recognition of color pictures is realized, and the influence of illumination, pose, and expression on recognition is reduced.
[0053] In one embodiment, as Figure 1 shown, a face recognition method is provided. In this embodiment, an example is given where this method is applied to a terminal. It can be understood that this method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. The above terminal can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented by an independent server or a server cluster composed of multiple servers. In this embodiment, the face recognition method includes the following steps:
[0054] Step 102, obtain an image to be detected, and preprocess the image to be detected to obtain a first image.
[0055] Among them, the preprocessing includes one or more of face alignment processing and histogram equalization processing.
[0056] Specifically, the terminal can obtain an image to be subjected to face recognition, that is, the image to be detected, and preprocess the image to be detected to obtain a preprocessed image, that is, the first image. In this way, the terminal can perform face alignment processing on the image to be detected to obtain an image after face alignment processing, and perform histogram equalization processing on the image after face alignment processing to obtain the first image corresponding to the image to be detected.
[0057] Optionally, for the image to be detected, the terminal can perform face key point detection on the image to be detected to obtain key points of multiple parts, and perform face alignment processing based on the key points to obtain the image to be detected after face alignment processing. The terminal can also, for the image to be detected after face alignment processing, calculate the image gray value after equalization processing based on each pixel value in the image to be detected after face alignment processing, and obtain the image after equalization based on the image gray value after equalization processing, that is, obtain the first image.
[0058] Step 104: Divide the first image into multiple detection regions, and process the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain the texture feature vector of the first image.
[0059] Among them, the size of the detection region can be pre-configured based on the actual application scenario, and the preset pixel value comparison strategy can be to compare with the pixel values of adjacent pixel points.
[0060] Specifically, for each first image, the terminal can divide the first image into multiple detection regions based on the preset size information of the detection region, and each detection region contains multiple pixel points; for any pixel point in each detection region, the terminal can compare the pixel value of the pixel point with the pixel values of each adjacent pixel point of the pixel point to obtain the comparison results of each adjacent pixel point, and obtain the LBP value of the pixel point based on the comparison results. Processing based on the LBP values respectively corresponding to each pixel point in the detection region can obtain the texture feature vector corresponding to the first image.
[0061] Step 106: Query in the preset face database based on the texture feature vector of the first image to obtain the face recognition result corresponding to the image to be detected.
[0062] Among them, the texture feature vector can be the global gray feature vector of the image to be detected. The preset face database can contain multiple images, and each image is marked with identification information, and the identification information can be the identity identification information of the face on the image, such as the name information of the object to which the face belongs, etc.; that is to say, the target dataset contains at least two images of multiple people. For each image in the target dataset, the terminal can process according to the method provided in this embodiment to obtain the texture feature vector corresponding to the image, or the global gray feature vector corresponding to the image.
[0063] Specifically, after obtaining the texture feature vector of the image to be detected, the terminal can calculate the similarity between the texture feature vector of the image to be detected and the texture feature vectors of each image in the preset face database, screen the similarities corresponding to each image, and determine the identity identification information corresponding to the image with the highest similarity as the identity identification information of the image to be detected, that is, obtain the face recognition result of the image to be detected.
[0064] In the above face recognition method, an image to be detected is obtained, and the image to be detected is preprocessed to obtain a first image. The preprocessing includes one or more of face alignment processing and histogram equalization processing. The first image is divided into multiple detection regions, and the pixel values of each pixel point in each detection region are processed through a preset pixel value comparison strategy to obtain the texture feature vector of the first image. In the preset face database, a query is made based on the texture feature vector of the first image to obtain the face recognition result corresponding to the image to be detected. By adopting this method, classification can be performed after dimensionality reduction processing of the features, accurate classification of color pictures is achieved, the influence of external factors such as environment, target pose, and expression on face recognition is reduced, the accuracy of face recognition is improved, and the application range is extended.
[0065] In one embodiment, as Figure 2 shown, the specific processing process of the step "obtain an image to be detected, and preprocess the image to be detected to obtain a first image" includes:
[0066] Step 202, perform face alignment processing on the image to be detected through a preset face alignment strategy to obtain an initial image.
[0067] Specifically, the terminal can detect the face information in the image to be detected through a preset key point model. For example, the terminal can process the image to be detected through a 68-key point detection model in the dlib database to obtain the key points of each part of the face in the image to be detected. For example, each part of the face can include eyes, nose, mouth, etc., and the corresponding key points can include eye corner key points, nose tip key points, and mouth corner key points, etc. The terminal can perform rotation processing, cropping processing, and coordinate transformation processing on the image to be detected based on the coordinates of the detected key points to obtain the image to be detected after face alignment processing, that is, obtain the initial image corresponding to the image to be detected.
[0068] Step 204, perform equalization processing on the initial image through a preset histogram equalization strategy to obtain a first image.
[0069] Specifically, for the initial image, the terminal can count the number of pixel points in the initial image and the pixel values / gray values of each pixel point to obtain statistical data, analyze the statistical data to obtain the number of pixel points corresponding to each gray value, calculate probabilities based on the number of pixel points of each gray value, obtain the cumulative probabilities of each gray value, perform mapping processing on the gray values based on the cumulative probabilities of each gray value to obtain the mapped gray values, and perform equalization processing on the initial image based on the mapped gray values to obtain the first image corresponding to the initial image, that is, obtain the image after face alignment processing and histogram equalization processing on the image to be detected.
[0070] In this embodiment, by performing face alignment processing and histogram equalization processing on the image, face images with different postures and angles can be subjected to standard normalization processing, reducing recognition errors caused by differences in facial positions and angles; performing histogram equalization processing can expand the application of gray values, better display details in the image, make the gray distribution of the image more uniform, and provide a better data detection basis for subsequent face recognition.
[0071] In one embodiment, as Figure 3 shown, the specific processing process of the step "perform face alignment processing on the image to be detected through a preset face alignment strategy to obtain an initial image" includes:
[0072] Step 302, determine the coordinates of multiple key points in the image to be detected, where the key points at least include the key points of the first part and the key points of the second part.
[0073] Among them, the first part and the second part can be parts on the human face, such as the mouth, nose, eyes, eyebrows, and facial contour, etc. For example, the key point of the first part in the image can be the key point of the center of the left eye, and the key point of the second part can be the key point of the center of the right eye.
[0074] Specifically, the terminal can detect each key point in the image to be detected to obtain the coordinates of each key point. For example, the terminal can obtain the coordinates of the key point of the center of the left eye and the coordinates of the key point of the center of the right eye.
[0075] Step 304, calculate the rotation angle based on the coordinates of the key points of the first part and the coordinates of the key points of the second part, and perform rotation processing on each key point based on the rotation angle and the midpoint between the key points of the first part and the key points of the second part to obtain the adjusted key points.
[0076] Specifically, the terminal can determine the line connecting the center of the left eye and the center of the right eye based on the coordinates of the center key point of the left eye and the coordinates of the center key point of the right eye, and determine the angle θ between this connection and the horizontal direction, and determine this angle as the rotation angle. In this way, the terminal can determine the coordinates of the overall center of the two eyes based on the coordinates of the center key point of the left eye and the coordinates of the center key point of the right eye, and perform a rotation process on the image to be detected based on the coordinates of the overall center of the two eyes; for example, it can use the coordinates of the overall center of the two eyes as the base point, rotate the image to be detected counterclockwise by the angle corresponding to this angle, and rotate each key point on this detected image counterclockwise by the angle corresponding to this angle to obtain the rotated key points.
[0077] Step 306, perform a cropping process on the image to be detected according to the target size to obtain the cropped image to be detected. And perform coordinate transformation on each adjusted key point based on the cropped image to be detected to obtain the initial image.
[0078] Among them, the target size can be determined based on the actual application scenario. For example, the target size can be a fixed size of 150*150.
[0079] Specifically, among the multiple key points of the image to be detected, the terminal can use the midpoint between the coordinates of the key point located on the far left and the coordinates of the key point located on the far right (for example, the mean value of the coordinates of the two key points can be calculated as the coordinates of the center) as the first center point of the cropped image to be detected. The center point of the cropped image to be detected in the horizontal direction can ensure that the cropped face is centered in the horizontal direction; and divide the image to be detected into three parts in the vertical direction: the top, the middle, and the bottom; correspondingly, the terminal can also obtain the coordinates of multiple key points on the mouth part and perform a mean value process to obtain the coordinates of the center of the key points of the mouth part. In this way, the terminal can calculate the vertical distance S between the coordinates of the first center point and the center of the key points of the mouth part; this vertical distance represents the height range of the middle part of the face in the cropped image to be detected.
[0080] In this way, the terminal can calculate the height range between the bottom and the top through (size - d) / 2, where size represents the height of the image to be detected, and d represents the vertical distance S between the coordinates of the first center point and the center of the key points of the mouth part. The terminal can perform a cropping process on the image to be detected based on the height ranges of the middle, the top, and the bottom and the target size to obtain an image of the target size, that is, obtain the cropped image to be detected. Correspondingly, the terminal can perform coordinate transformation on the coordinates of the key points in the image to be detected to obtain the initial image.
[0081] In this embodiment, by performing face alignment processing and histogram equalization processing on the image, face images with different poses and angles can be subjected to standard normalization processing, reducing recognition errors caused by differences in facial positions and angles. Performing alignment processing on the images stored in the preset face database can enhance the consistency of the image set, improve the convenience of image recognition, and provide a more standard image data processing basis for subsequent image processing.
[0082] In one embodiment, as Figure 4 shown, the specific processing process of the step "performing equalization processing on the initial image through a preset histogram equalization strategy to obtain a first image" includes:
[0083] Step 402, statistically processing the gray values of each pixel point on the initial image to obtain the number of pixel points with each gray value, the total number of pixel points, and calculating the probability of each gray value.
[0084] Specifically, the terminal can obtain the pixel values of each pixel point in the initial image, that is, the gray values of each pixel point, and perform statistical processing on the gray values of each pixel point to obtain the number of pixel points corresponding to each gray value and the total number of all pixel points included in the initial image, that is, the total number of pixel points. For each gray value, the terminal can process based on the number of pixel points belonging to this gray value and the total number of pixel points to obtain the probability corresponding to each gray value. For example, the probability Pj of the gray value j can be calculated through the following formula:
[0085] Pj = n j / n
[0086] where n j represents the number of pixel points belonging to the gray value j, and n represents the total number of pixel points.
[0087] Step 404, calculating the cumulative probability of the initial image based on the probabilities of each gray value.
[0088] Specifically, the terminal can process through the probabilities of each gray value to obtain the cumulative probability S k of the initial image, for example, it can be calculated through the following formula:
[0089]
[0090] where l represents the total number of gray levels in the initial image.
[0091] Step 406, performing gray value mapping based on the cumulative probability to obtain the mapped gray value, and obtaining the image equalization gray value based on the mapped gray value.
[0092] Specifically, the terminal can filter based on the gray values of each pixel point in the initial image to obtain the highest gray value max(pix) and the lowest gray value min(pix), calculate the gray value difference between the highest gray value and the lowest gray value, and calculate the mapped gray value corresponding to each gray value based on the gray value difference and the cumulative probability corresponding to each gray value; for example, the product value between the gray value difference and the cumulative probability can be calculated, and the product value can be determined as the mapped gray value PIX. In this way, the terminal can determine the integer closest to the mapped gray value PIX and determine the integer as the image equalization gray value corresponding to the initial image, that is, determine it as the gray value of the equalized image.
[0093] Step 408: Perform equalization adjustment on the initial image based on the image equalization gray value to obtain the first image corresponding to the image to be detected.
[0094] Specifically, the terminal can obtain the image equalization gray value corresponding to each gray value respectively, and adjust each gray value to the image equalization gray value corresponding to the gray value to obtain the first image corresponding to the image to be detected.
[0095] In this embodiment, performing histogram equalization processing can expand the application of gray values, better display the details in the image, make the gray distribution of the image more uniform, and provide clearer gray change information and a better data detection basis for subsequent face recognition.
[0096] In one embodiment, as Figure 5 shown, the specific processing process of the step "Process the pixel values of each pixel point in each detection area through a preset pixel value comparison strategy to obtain the texture feature vector of the first image" includes:
[0097] Step 502: For each detection area, process the pixel values of each pixel point in the detection area based on the preset pixel value comparison strategy to obtain the pixel comparison value of each pixel point, arrange the pixel comparison values of each pixel point in the detection area in the preset order to obtain the target base value, and convert the target base value to obtain the texture classification feature value of the detection area.
[0098] Specifically, for each pixel point in each detection area, the terminal can determine the adjacent pixel points of the pixel point, and compare the pixel value of the pixel point (central pixel point) with the pixel values of the adjacent pixel points respectively. If the pixel value of the adjacent pixel point is greater than the pixel value of the central pixel point, it is determined that the pixel comparison value of the adjacent pixel point is 1; otherwise, it is 0. In this way, the terminal can read the pixel comparison values of the adjacent pixel points of the central pixel point in a preset order (counterclockwise order or clockwise order) to obtain the target base value (i.e., binary value); the terminal can convert the target base value to a decimal value to obtain a texture classification feature value that can represent the local texture feature of the central pixel point. That is to say, the terminal can obtain the texture classification feature values corresponding to each pixel point included in the detection area.
[0099] Step 504: Calculate a histogram based on the texture classification feature values to obtain the histogram of the detection area.
[0100] Specifically, for each detection area, the terminal can count the distribution of the texture classification feature values of the pixel points to obtain the histogram of the detection area. The first coordinate axis of the histogram of the detection area can identify the value-taking situations of different texture classification feature values, and the second coordinate axis can represent the frequencies of occurrence of each texture classification feature value. That is to say, the histogram of the detection area can represent the local texture feature information in the detection area.
[0101] Step 506: Perform a connection process on the histograms of each detection area to obtain the texture feature vector of the first image.
[0102] Specifically, the terminal can connect the histograms of each detection area in the first image in a preset order to obtain the texture feature vector corresponding to the first image.
[0103] In this embodiment, by dividing into multiple detection areas for feature extraction, the influence of different poses and expressions of the face on face recognition can be avoided, and more detailed and effective local feature information can be extracted. The extracted texture feature vector can contain the texture information in each local area of the image, providing a more reliable data basis for subsequent face recognition.
[0104] In one embodiment, as Figure 6 shown, the specific processing process of the step "Perform a connection process on the histograms of each detection area to obtain the texture feature vector of the first image" includes:
[0105] Step 602: Perform a connection process on the histograms of each detection area to obtain an initial texture feature vector.
[0106] Specifically, the terminal can connect the histograms of the detection regions in the first image in a preset order to obtain the initial texture feature vector corresponding to the first image.
[0107] Step 604: Calculate the covariance matrix of the initial texture feature vector, and perform eigenvalue decomposition on the covariance matrix to obtain the eigenvalues corresponding to each feature dimension.
[0108] Specifically, the terminal can calculate the mean value of the multi-dimensional feature vectors included in the initial texture feature vector to obtain the mean vector, and calculate the difference between each dimension's feature vector and the mean vector to implement the centering process of the initial texture feature vector, obtaining the centered initial texture feature vector. In this way, the terminal can calculate the covariance matrix of the centered initial texture feature vector, and perform eigenvalue decomposition on this covariance matrix to obtain the eigenvalues corresponding to each feature dimension. The eigenvalue characterizes the variance size on this feature dimension. The larger the variance, the more obvious the data change on this feature dimension and the more image data it contains.
[0109] Step 606: Based on the eigenvalues corresponding to each feature dimension, perform screening to obtain the target feature dimension, and based on the target feature dimension, calculate the feature vector transformation matrix; perform dimensionality reduction processing on the initial texture feature vector through the feature vector transformation matrix to obtain the texture feature vector of the first image.
[0110] Specifically, the terminal can perform screening based on each eigenvalue. For example, it can screen out the n feature dimensions with the largest eigenvalues as the target feature dimensions, and perform normalization processing on the feature vectors corresponding to each target feature dimension to obtain the feature vector transformation matrix. In this way, the terminal can map the initial texture feature vector into the space corresponding to this feature vector transformation matrix to obtain the dimensionality-reduced feature vector, that is, obtain the texture feature vector of the first image.
[0111] In this embodiment, taking the obtained LBP texture feature as the input sample and performing dimensionality reduction through the PCA method to obtain the dimensionality-reduced feature can reduce the dimension of the feature while retaining the main texture information of the face image, reducing the complexity of subsequent classification calculations.
[0112] In one embodiment, the preset face database includes the identification information and texture feature vectors corresponding to multiple pictures. Among them, the identification information represents the identity identification information of the object to which the face in the image / picture belongs. For example, it can be a name or ID information, etc.; the specific processing process of the step "query in the preset face database based on the texture feature vector of the first image to obtain the face recognition result corresponding to the image to be detected" includes:
[0113] Calculate the similarity between the texture feature vector of the first image and the texture feature vectors corresponding to the respective pictures included in the preset face database through a preset radial deviation kernel function. Determine the identification information corresponding to the similarity that meets the preset similarity condition as the face recognition result corresponding to the image to be detected.
[0114] Specifically, the terminal can calculate the pixel points between the texture feature vector of the first image and the texture feature vectors of the respective pictures included in the preset face database. The terminal can determine the picture with the largest similarity as the picture similar to the first image, and determine the identification information corresponding to the picture with the largest similarity as the face recognition result of the image to be detected. For example, the similarity K(x, y) between the image y to be detected and the picture x in the preset face database can be calculated through the following radial deviation RBF formula:
[0115] K(x,y)=exp[-||x - y|| 2 / (2σ 2 )]
[0116] Among them, σ controls the range of the radial action of the function.
[0117] In this embodiment, while ensuring the calculation accuracy, the complexity of calculating the similarity between high-dimensional feature vectors is reduced.
[0118] The following details the specific execution process of the above face recognition method in combination with a specific embodiment:
[0119] Step 1, data preprocessing, which specifically includes face alignment processing and picture histogram equalization.
[0120] Step 1.1, face alignment processing. The images in the LFW dataset all come from the network, and the images have been placed in the corresponding folders according to the names of the people respectively. Each person needs at least two pictures for the training set and the test set. The face pictures provided by the LFW dataset all come from natural scenes in life, including faces in different environments, poses, and ages, and there are more than one face in some pictures. In this embodiment, the 68 key point model in the dlib library can be used to detect faces, correct faces, and crop them into pictures of 150*150.
[0121] Specifically, detect the coordinates of the key points in the picture through the corners of the eyes, the tip of the nose, and the corners of the mouth, etc.; calculate the angle θ in the horizontal direction of the line connecting the center coordinates of the left and right eyes. With the overall center coordinates of the two eyes as the base point, rotate the picture counterclockwise by θ; with the center of the two eyes as the base point, rotate the face key points counterclockwise by θ; crop the face to a fixed size (150*150) according to the key points; transform the face key points to match the cropped picture to obtain the initial image.
[0122] Step 1.2, Histogram equalization processing of the image. Specifically, perform histogram equalization processing on the initial image to obtain the first image corresponding to the initial image.
[0123] Step 2, Feature extraction based on LBP. Specifically, for each pixel point in each detection area (5*5), the terminal can determine each adjacent pixel point of the pixel point, and compare the pixel value of the pixel point (central pixel point) with the pixel values of each adjacent pixel point respectively. If the pixel value of the adjacent pixel point is greater than the pixel value of the central pixel point, then determine the pixel comparison value of the adjacent pixel point as 1, otherwise as 0. In this way, the terminal can read the pixel comparison values of the adjacent pixel points of the central pixel point in the preset order to obtain a binary value, and the terminal can convert the binary value to a decimal value to obtain a texture classification feature value that can represent the local texture feature of the central pixel point. That is to say, the terminal can obtain the texture classification feature values corresponding to each pixel point included in the detection area. For each detection area, the terminal can count the distribution of the texture classification feature values of the pixel points to obtain the histogram of the detection area, and connect the histograms of each detection area in the first image in the preset order to obtain the texture feature vector corresponding to the first image.
[0124] Step 3, Reduce the computational complexity of feature classification through PCA, use PCA to extract the global grayscale features of the image, and use PCA to reduce the dimensionality of the feature space, remove noise and some unimportant features, and reduce the computational complexity of feature classification.
[0125] Specifically, input: n-dimensional sample set W = (x(1), x(2),..., x(m)), reduce it to t dimensions.
[0126] Output: The reduced sample set W'.
[0127] S1, Centralize the samples:
[0128]
[0129] Among them, represents the sample mean, x(i) is the sample, and m is the number of samples.
[0130] S2, Calculate the covariance matrix XX of the samples T .
[0131] S3, Perform eigenvalue decomposition on the covariance matrix.
[0132] S4, Remove the eigenvectors (w1, w2,..., wt) corresponding to the largest t eigenvalues, and standardize the eigenvectors to form the eigenvector matrix w.
[0133] S5. Transform the original sample into a new sample \(z(i) = w\) T \(x(i)\) to obtain an output sample set \(W'\), that is, obtain the texture feature vector after dimensionality reduction processing. That is to say, the LBP operator is used on the face image to obtain the image after LBP encoding. The texture features of the image are described by counting the histogram of the face image, and then the texture feature vector after dimensionality reduction is obtained through PCA dimensionality reduction.
[0134] The face recognition method provided in this embodiment is applied to the images included in the LFW dataset, ORL dataset, and Yale dataset. The application results show that after LBP and SVM in the method provided in this embodiment, the recognition accuracy rates in the ORL and Yale datasets are both above 90%, and the effect is good. After using PCA dimensionality reduction, the recognition rate is increased by an average of 2%, which is sufficient to reflect the function of PCA in reducing the feature dimension and improving the recognition rate. The face recognition method provided in this embodiment achieves the expected goal of recognizing color pictures, reducing the influence of illumination, pose, and expression on recognition on the LFW dataset. The experimental results are shown in Table 1:
[0135] Table 1
[0136]
[0137] The face recognition method provided in this embodiment can combine LBP and PCA. After preprocessing the picture, perform dimensionality reduction processing to remove noise and some unimportant features, reduce the complexity of using LBP features for classification, and combine the SVM method to classify the features after dimensionality reduction. It not only supports color face recognition but also reduces the influence of factors such as environment, pose, and expression, improving the effect of face recognition.
[0138] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same moment but can be executed at different moments. The execution order of these steps or stages is not necessarily sequential but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0139] Based on the same inventive concept, an embodiment of the present application further provides a face recognition device for implementing the face recognition method involved above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the face recognition device provided below can refer to the limitations on the face recognition method in the above text, and will not be repeated here.
[0140] In one embodiment, as Figure 7 shown, a face recognition device 700 is provided, including:
[0141] An acquisition module 702, configured to acquire an image to be detected, and perform preprocessing on the image to be detected to obtain a first image. The preprocessing includes one or more of face alignment processing and histogram equalization processing.
[0142] A partitioning module 704, configured to partition the first image into multiple detection regions, and process the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain a texture feature vector of the first image;
[0143] A query module 706, configured to query in a preset face database based on the texture feature vector of the first image to obtain a face recognition result corresponding to the image to be detected.
[0144] In one of the embodiments, the acquisition module is specifically configured to:
[0145] Perform face alignment processing on the image to be detected through a preset face alignment strategy to obtain an initial image;
[0146] Perform equalization processing on the initial image through a preset histogram equalization strategy to obtain a first image.
[0147] In one of the embodiments, the acquisition module is further specifically configured to:
[0148] Determine the coordinates of multiple key points in the image to be detected, where the key points at least include a first part key point and a second part key point;
[0149] Calculate a rotation angle based on the coordinates of the first part key point and the coordinates of the second part key point, and perform rotation processing on each of the key points based on the rotation angle and the midpoint between the first part key point and the second part key point to obtain adjusted key points;
[0150] Perform cropping processing on the image to be detected through a target size to obtain a cropped image to be detected; and perform coordinate transformation on each of the adjusted key points based on the cropped image to be detected to obtain an initial image.
[0151] In one embodiment, the obtaining module is further specifically configured to:
[0152] Perform statistical processing on the gray values of each pixel point on the initial image to obtain the number of pixel points for each gray value, the total number of pixel points, and calculate the probability of each gray value;
[0153] Based on the probabilities of each gray value, calculate the cumulative probability of the initial image;
[0154] Perform gray value mapping based on the cumulative probability to obtain the mapped gray value, and based on the mapped gray value, obtain the image equalized gray value;
[0155] Perform equalization adjustment on the initial image based on the image equalized gray value to obtain the first image corresponding to the image to be detected.
[0156] In one embodiment, the partitioning module is specifically configured to:
[0157] For each detection region, based on a preset pixel value comparison strategy, process the pixel values of each pixel point in the detection region to obtain the pixel comparison values of each pixel point, arrange the pixel comparison values of each pixel point in the detection region in a preset order to obtain the target base value, and perform conversion on the target base value to obtain the texture classification feature value of the detection region;
[0158] Perform histogram calculation based on the texture classification feature value to obtain the histogram of the detection region;
[0159] Perform connection processing on the histograms of each detection region to obtain the texture feature vector of the first image.
[0160] In one embodiment, the partitioning module is specifically configured to:
[0161] Perform connection processing on the histograms of each detection region to obtain an initial texture feature vector;
[0162] Calculate the covariance matrix of the initial texture feature vector, and perform eigenvalue decomposition on the covariance matrix to obtain the eigenvalues corresponding to each eigen-dimension;
[0163] Perform screening based on the eigenvalues corresponding to each eigen-dimension to obtain the target eigen-dimension, and based on the target eigen-dimension, calculate the eigenvector transformation matrix;
[0164] Perform dimensionality reduction processing on the initial texture feature vector through the eigenvector transformation matrix to obtain the texture feature vector of the first image.
[0165] In one embodiment, the preset face database includes identification information and texture feature vectors corresponding to multiple pictures; the query module is specifically configured to:
[0166] Calculate the similarity between the texture feature vector of the first image and the texture feature vectors corresponding to the pictures included in the preset face database through a preset radial deviation kernel function;
[0167] Determine the identification information corresponding to the similarity that meets the preset similarity condition as the face recognition result corresponding to the image to be detected.
[0168] Each module in the above face recognition device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0169] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 8 shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store image data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a face recognition method is implemented.
[0170] Those skilled in the art can understand that Figure 8 the structure shown in is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0171] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0172] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0173] In one embodiment, a computer program product is provided, including a computer program which, when executed by a processor, implements the steps in the above method embodiments.
[0174] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0175] Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to a memory, database, or other medium provided in the embodiments of the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memories can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments of the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments of the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0176] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0177] The above-described embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation to the scope of the patent of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A face recognition method, characterized in that, The method includes: Obtain an image to be detected, and preprocess the image to be detected to obtain a first image, where the preprocessing includes one or more of face alignment processing and histogram equalization processing; Perform region division on the first image to obtain a plurality of detection regions, and process the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain a texture feature vector of the first image; In a preset face database, query based on the texture feature vector of the first image to obtain a face recognition result corresponding to the image to be detected.
2. The method according to claim 1, wherein The obtaining of the image to be detected and the preprocessing of the image to be detected to obtain a first image includes: Perform face alignment processing on the image to be detected through a preset face alignment strategy to obtain an initial image; Perform equalization processing on the initial image through a preset histogram equalization strategy to obtain a first image.
3. The method according to claim 2, wherein The performing of face alignment processing on the image to be detected through a preset face alignment strategy to obtain an initial image includes: Determine the coordinates of a plurality of key points in the image to be detected, where the key points at least include a first part key point and a second part key point; Calculate a rotation angle based on the coordinates of the first part key point and the coordinates of the second part key point, and perform rotation processing on each key point based on the rotation angle and the midpoint between the first part key point and the second part key point to obtain adjusted key points; Perform cropping processing on the image to be detected through a target size to obtain a cropped image to be detected; and perform coordinate transformation on each adjusted key point based on the cropped image to be detected to obtain an initial image.
4. The method according to claim 2, wherein The performing of equalization processing on the initial image through a preset histogram equalization strategy to obtain a first image includes: Perform statistical processing on the gray values of each pixel point on the initial image to obtain the number of pixel points of each gray value, the total number of pixel points, and calculate the probability of each gray value; Calculate the cumulative probability of the initial image based on the probabilities of each gray value; Perform gray value mapping based on the cumulative probability to obtain a mapped gray value, and obtain an image equalized gray value based on the mapped gray value; Perform equalization adjustment on the initial image based on the image equalized gray value to obtain a first image corresponding to the image to be detected.
5. The method according to claim 1, characterized in that, The processing of the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain a texture feature vector of the first image includes: For each detection region, process the pixel values of each pixel point in the detection region through a preset pixel value comparison strategy to obtain pixel comparison values of each pixel point, arrange the pixel comparison values of each pixel point in the detection region in a preset order to obtain a target base value, and convert the target base value to obtain a texture classification feature value of the detection region; Perform histogram calculation based on the texture classification feature value to obtain a histogram of the detection region; Perform a connection process on the histograms of the respective detection regions to obtain the texture feature vector of the first image.
6. The method according to claim 1, characterized in that, The step of performing a connection process on the histograms of the respective detection regions to obtain the texture feature vector of the first image includes: Perform a connection process on the histograms of the respective detection regions to obtain an initial texture feature vector; Calculate the covariance matrix of the initial texture feature vector, and perform eigenvalue decomposition on the covariance matrix to obtain the eigenvalues corresponding to the respective feature dimensions; Based on the eigenvalues corresponding to the respective feature dimensions, perform screening to obtain the target feature dimension, and based on the target feature dimension, calculate a feature vector transformation matrix; Perform dimensionality reduction processing on the initial texture feature vector through the feature vector transformation matrix to obtain the texture feature vector of the first image.
7. The method according to claim 1, characterized in that, The preset face database includes identification information and texture feature vectors corresponding to multiple pictures; the step of querying in the preset face database based on the texture feature vector of the first image to obtain the face recognition result corresponding to the image to be detected includes: Calculate the similarity between the texture feature vector of the first image and the texture feature vectors corresponding to the respective pictures included in the preset face database through a preset radial deviation kernel function; Determine the identification information corresponding to the similarity that satisfies the preset similarity condition as the face recognition result corresponding to the image to be detected.
8. A face recognition device, characterized in that, The apparatus includes: An acquisition module, configured to acquire an image to be detected, and perform preprocessing on the image to be detected to obtain a first image, where the preprocessing includes one or more of face alignment processing and histogram equalization processing; A division module, configured to divide the first image into multiple detection regions, and process the pixel values of each pixel point in each detection region through a preset pixel value comparison strategy to obtain the texture feature vector of the first image; A query module, configured to query in the preset face database based on the texture feature vector of the first image to obtain the face recognition result corresponding to the image to be detected.
9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.