A face recognition method and device based on face posture
By calculating and processing the shooting posture of face images, and training face recognition models for different postures, the problem of low face recognition accuracy in the existing technology is solved, and the accuracy and similarity of recognition are improved.
Patent Information
- Application Number
- CN201910625597.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-11
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2039-07-11
AI Technical Summary
The existing 1:N face recognition system captures face images under non-standard conditions, resulting in low recognition accuracy and cannot effectively handle the different postures of face images and partial data loss.
By obtaining and calculating the shooting pose of the face image, finding and saving the corresponding preset face pose, training the face recognition model for each pose, and selecting the corresponding model for feature extraction and comparison based on the pose of the image to be recognized.
The accuracy of face recognition is improved, and the similarity and accuracy of recognition are enhanced by increasing the number of sample images and training models for different postures.
Smart Images

Figure CN110490067B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a face recognition method and device based on face posture. Background Art
[0002] 1:N face recognition refers to finding the current user's face data in a massive database of portraits and matching them. Fighting against abduction and exposing red light runners belong to 1:N face recognition, which means finding one target from N faces. Since most face images are captured under some non-standard conditions, they are easily affected by the rotation of the human head, such as the up and down rotation, left and right rotation and tilt of the human head. The features that can be seen in different postures are often different. For example, two eyes can be seen in the front face, but in extreme cases such as the side face, only one eye may be seen, resulting in the loss of part of the data of the captured face image. The current 1:N face recognition system often has only one photo per person in the sample library. The posture of this photo is generally required to be relatively straight, that is, there should not be a large pitch, left and right deflection, but the faces in the on-site snapshots are often not in a very straight posture, which often makes the overall recognition accuracy low.
[0003] In the prior art, in order to improve recognition accuracy, the method adopted is: obtaining a face image to be recognized; locating key points of the face in the face image; determining the face deflection angle in the face image according to the coordinates of the located key points; performing posture correction on the face in the face image according to the face deflection angle and in accordance with preset face rotation transformation rules; performing face recognition on the face image after posture correction to obtain a face recognition result.
[0004] The images captured by ordinary 2D cameras only contain information in the direction of shooting, and a lot of information in other directions is missing. When adjusting the posture, the missing information is actually guessed and supplemented. Therefore, the accuracy of face recognition after posture adjustment will be affected by the accuracy of information completion. In practice, there is not much difference in accuracy between face recognition after posture adjustment and directly comparing two faces with different postures without adjustment, resulting in lower recognition accuracy. Summary of the invention
[0005] In view of this, the present invention provides a face recognition method and device based on face posture, the main purpose of which is to solve the problem of low recognition accuracy in the face recognition process in the prior art.
[0006] According to one aspect of the present invention, a face recognition method based on face gesture is provided, comprising:
[0007] Obtain a face image taken according to a preset shooting method;
[0008] Calculating the facial posture of the facial image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle;
[0009] According to the photographed facial posture, searching for a preset facial posture to which the facial image belongs, and saving the facial image to which the preset facial posture belongs in a sample image set corresponding to the preset facial posture;
[0010] According to the face images in the sample image set corresponding to the preset face postures, training a face recognition model corresponding to each of the preset face postures;
[0011] Obtain an image to be recognized;
[0012] According to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, image features of the image to be recognized are extracted, and according to the image features, it is determined whether the image to be recognized is stored in the sample image set.
[0013] According to another aspect of the present invention, a face recognition device based on face gesture is provided, comprising:
[0014] A first acquisition module, used to acquire a face image captured in a preset shooting mode;
[0015] A calculation module, used for calculating the facial posture of the face image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle;
[0016] A search module, used for searching the preset face posture to which the face image belongs according to the photographed face posture, and saving the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture;
[0017] A training module, for training a face recognition model corresponding to each of the preset face postures according to the face images in the sample image set corresponding to the preset face postures;
[0018] A second acquisition module is used to acquire an image to be identified;
[0019] The judgment module is used to extract the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judge whether the image to be recognized is stored in the sample image set according to the image features.
[0020] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to perform operations corresponding to the above-mentioned face recognition method based on face posture.
[0021] According to another aspect of the present invention, there is provided a computer device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0022] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the above-mentioned face recognition method based on face posture.
[0023] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0024] The present invention provides a face recognition method and device based on face posture, firstly obtaining a face image shot in a preset shooting mode, then calculating the shooting face posture of the face image, then selecting the preset face posture to which the face image belongs according to the shooting face posture, and saving the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture, then training a face recognition model corresponding to each preset face posture according to the face images in the sample image set corresponding to the preset face posture, then obtaining an image to be recognized, finally extracting the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judging whether the image to be recognized is saved in the sample image set according to the image features. Compared with the prior art, the embodiment of the present invention can improve the recognition accuracy by shooting a large number of face images with different shooting face postures, increasing the number of sample images. Furthermore, the face images are classified according to the face postures, divided into sample image sets corresponding to different preset face postures, and a comparison image with a face posture similar to the image to be recognized is selected, so as to improve the recognition accuracy. Furthermore, a face recognition model corresponding to a sample image set corresponding to a preset face posture is trained, and different face recognition models are selected for images to be recognized with different face postures, so that the similarity between the image to be recognized and the face recognition model is higher, and recognition accuracy can also be improved.
[0025] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0027] Figure 1 A flow chart of a face recognition method based on face posture provided by an embodiment of the present invention is shown;
[0028] Figure 2 Another flow chart of a face recognition method based on face posture provided by an embodiment of the present invention is shown;
[0029] Figure 3 A block diagram of a face recognition device based on face posture provided by an embodiment of the present invention is shown;
[0030] Figure 4 A block diagram showing another face recognition device based on face posture provided by an embodiment of the present invention is shown;
[0031] Figure 5 A schematic structural diagram of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0032] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0033] The embodiment of the present invention provides a face recognition method based on face posture, such as Figure 1 As shown, the method includes:
[0034] 101. Obtain a face image captured using a preset capturing method.
[0035] Face recognition is to compare the facial features in two face images. The closer the facial postures in the face images are, the more facial features can be compared with each other, and the higher the accuracy of the comparison results. Based on this, this solution needs to obtain face images of multiple people and multiple postures. The face image is taken according to a preset shooting method. The shooting method can be dynamic continuous capture, static single shooting, or video shooting and then video screenshot. The preset shooting method is not limited in the embodiment of the present invention. If the face recognition system to which the present invention is applied includes a camera, when acquiring the face image, the system camera is directly controlled to shoot the face image according to the preset shooting method. If the face recognition system to which the present invention is applied does not include a camera, according to the transmission channel for transmitting the face image to the face recognition system through the shooting dedicated device, the shooting instruction of the preset shooting method is transmitted to the shooting dedicated device, and the shooting dedicated device is controlled to shoot the face image.
[0036] 102. Calculate the facial posture of the facial image.
[0037] The captured face posture includes three posture parameters: yaw angle, pitch angle and roll angle, which can be calculated in a staged manner and an end-to-end manner.
[0038] 103. According to the photographed facial posture, search for a preset facial posture to which the facial image belongs, and save the facial image to which the preset facial posture belongs in a sample image set corresponding to the preset facial posture.
[0039] The preset face pose and the photographed face pose both have three pose parameters: yaw angle, pitch angle and roll angle. The two poses are often not completely the same. Therefore, the preset face pose to which the face image belongs in this step means that the deviation between the photographed face pose of the face image and the preset face pose is less than a certain range. When searching for the preset face pose of the face image, each time a preset face pose to which a face image belongs is found, the face image is saved in the sample image set corresponding to the preset face pose.
[0040] After searching in this step, not all face images can necessarily find the preset face postures to which they belong. If the face image is not saved in the sample image set corresponding to the preset face posture, the face image needs to be obtained again to ensure the effectiveness of the solution of the present invention.
[0041] 104. Based on the face images in the sample image set corresponding to the preset face postures, train a face recognition model corresponding to each of the preset face postures.
[0042] The face recognition model is trained according to the face images in the sample image set corresponding to the preset face postures, that is, each preset face posture has a specific face recognition model.
[0043] 105. Obtain an image to be identified.
[0044] The source of the image to be identified is the same as that of the face image, but the image to be identified is usually shot in a single shot. When the image to be identified is actually acquired, the image quality may be poor due to occlusion, shooting angle, camera pixel, shooting light, etc. Therefore, after acquiring the image to be identified, the image to be identified can be preprocessed to improve the image quality of the image to be identified as much as possible.
[0045] 106. Extract image features of the image to be recognized according to a face recognition model corresponding to a preset face posture to which the image to be recognized belongs, and determine whether the image to be recognized is stored in the sample image set according to the image features.
[0046] Find the preset face posture corresponding to the image to be recognized, then extract the image features of the image to be recognized based on the face recognition model corresponding to the preset face posture, and determine whether the image to be recognized is stored in the sample image based on the image features.
[0047] The present invention provides a face recognition method based on face posture, firstly obtains a face image shot according to a preset shooting mode, then calculates the shooting face posture of the face image, then selects the preset face posture to which the face image belongs according to the shooting face posture, and saves the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture, then trains a face recognition model corresponding to each preset face posture according to the face images in the sample image set corresponding to the preset face posture, then obtains an image to be recognized, finally extracts the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judges whether the image to be recognized is saved in the sample image set according to the image features. Compared with the prior art, the embodiment of the present invention can improve the recognition accuracy by shooting a large number of face images with different shooting face postures, increasing the number of sample images. Furthermore, the face images are classified according to the face postures, divided into sample image sets corresponding to different preset face postures, and a comparison image with a face posture similar to the image to be recognized is selected, so as to improve the recognition accuracy. Furthermore, a face recognition model corresponding to a sample image set corresponding to a preset face posture is trained, and different face recognition models are selected for images to be recognized with different face postures, so that the similarity between the image to be recognized and the face recognition model is higher, and recognition accuracy can also be improved.
[0048] The embodiment of the present invention provides another face recognition method based on face posture, such as Figure 2 As shown, the method includes:
[0049] 201. Obtain a face image captured in a preset capturing mode.
[0050] This step and Figure 1 The method described in step 101 is the same as that shown and will not be repeated here.
[0051] 202. Calculate the facial posture of the facial image.
[0052] The photographed face posture includes three posture parameters: yaw angle, pitch angle and roll angle. If the photographed face posture of the face image is calculated in a staged manner, it specifically includes: extracting the face rectangular area in the face image according to the preset face recognition algorithm; establishing a face coordinate system with the upper left corner or lower right corner of the face rectangular area as the coordinate origin; searching for the face key points in the face rectangular area according to the cascaded convolutional neural network model, and recording the face key point coordinates of the face key points according to the face coordinate system; calculating the rotation angle of the preset three-dimensional model according to the rotation rule, the rotation rule means rotating the preset three-dimensional model to the projection of the face key points in the preset three-dimensional model on the face image, and the distance from the face key point coordinates is the smallest; determining the rotation angle as the photographed face posture.
[0053] When extracting the face rectangular frame diagram, it specifically includes determining the minimum detected face, scaling the face image, the scaling ratio is the ratio of the sliding window size to the minimum face size, building a pyramid with the scaled face image, and then obtaining patches for each layer of the pyramid through the sliding window, normalizing the patches, and then inputting the trained face detector for recognition, saving the window position and probability of the face recognition; mapping the face window to the face position in the input image, and the probability remains unchanged; using the non-maximum suppression algorithm NMS to process the overlapping windows; and drawing the face rectangular frame diagram containing the face position in the input image. In the embodiment of the present invention, the upper left corner or the lower right corner of the face rectangular area is used as the coordinate origin to facilitate calculation. In fact, any point in the face rectangular area or outside the area can be used as the coordinate origin to establish a face coordinate system. The number of face key points can be selected as 5, 19 or 68. In the embodiment of the present invention, it is preferred to include 19 face key points such as eyes, nose, mouth, and facial contour. The preset three-dimensional model is a three-dimensional, frontal standard model drawn by data points. In the process of rotating the preset three-dimensional model, that is, rotating the preset three-dimensional model to a position where the face rectangular frame can be projected, the facial posture of the photographed face image is calculated based on this rotation rule.
[0054] In parallel with the staged approach, an end-to-end approach can also be used to calculate the captured face posture of the face image, specifically including: extracting a face rectangular area in the face image according to a preset face recognition algorithm; scaling the face rectangular area according to a first preset size; establishing a face coordinate system with the upper left corner or lower right corner of the scaled face rectangular area as the coordinate origin; searching for face key points in the scaled face rectangular area according to a cascaded convolutional neural network model, and recording the face key point coordinates of the face key points according to the face coordinate system; inputting the scaled face rectangular area and the face key point coordinates into a VGGNet network model to calculate the captured face posture.
[0055] VGGNet is a deep convolutional neural network. By repeatedly stacking 3*3 small convolution kernels and 2*2 maximum pooling layers, a 16-19-layer deep convolutional neural network is successfully constructed. VGGNet is used to extract image features. VGGNet uses 3*3 convolution kernels and 2*2 pooling kernels throughout, and improves performance by continuously deepening the network structure. When training, VGGNet first trains a simple A network, and then reuses the weights of A network to initialize the following complex models, so that the convergence speed is faster.
[0056] 203. According to the photographed facial posture, search for a preset facial posture to which the facial image belongs, and save the facial image to which the preset facial posture belongs in a sample image set corresponding to the preset facial posture.
[0057] Both the preset face posture and the captured face posture have three posture parameters: yaw angle, pitch angle and roll angle. The two postures are often not exactly the same. Therefore, the preset face posture to which the face image belongs in this step means that the deviation between the captured face posture of the face image and the preset face posture is less than a certain range. Searching for a preset face posture to which a face image belongs specifically comprises: calculating a shooting angle difference between the photographed face posture and each of the preset face postures, the angle difference referring to the sum of squares of a shooting yaw angle difference, a shooting pitch angle difference and a shooting roll angle difference, the shooting yaw angle difference referring to the difference between the yaw angle of the photographed face posture and the yaw angle of each of the preset face postures, the shooting pitch angle difference referring to the difference between the pitch angle of the photographed face posture and the pitch angle of each of the preset face postures, the shooting roll angle difference referring to the difference between the roll angle of the photographed face posture and the roll angle of each of the preset face postures; and determining that a preset face posture corresponding to a minimum value among the shooting angle differences is the preset face posture to which the photographed face posture belongs.
[0058] The preset facial postures described in searching for facial images are saved in a sample image set corresponding to the preset facial posture each time a facial image is found. After searching in this step, not all facial images can necessarily find the preset facial posture to which they belong. If the facial image is not saved in the sample image set corresponding to the preset facial posture, it is necessary to obtain the facial image again to ensure the effectiveness of the solution of the present invention.
[0059] 204. Select a training sample image from a sample image set corresponding to the preset facial posture.
[0060] The training sample images include a first face image whose shooting angle difference with the preset face posture is less than a preset value, and a second face image whose shooting angle difference with the preset face posture is not less than a preset value, and the ratio of the number of images of the first face image to the number of images of the second face image is a preset ratio. The sample image set corresponding to the preset face posture includes face images with a certain deviation angle from the preset face posture, and some images are selected as training sample images corresponding to the preset face posture. The process of selecting the training sample images includes: calculating the shooting angle difference between each image in the sample image set corresponding to the preset face posture and the preset face posture, dividing the face images in the sample image set corresponding to the preset face posture into a first candidate set and a second candidate set according to whether the shooting angle difference is less than a preset value, selecting the first face image in the first candidate set, selecting the second face image in the second candidate set, and the ratio of the number of images of the first face image to the number of images of the second face image is a preset ratio. Exemplarily, assuming that the number of training sample images is sufficient, the preset facial posture is (pitch0, yaw0), and the preset value is 10, then the first candidate set includes facial images with pitch angles pitch∈[pitch0-10, pitch0+10], yaw angles yaw∈[yaw0-10, yaw0+10], and roll angles roll∈[roll0-10, roll0+10] in the training samples, and the second candidate set includes facial images with other facial postures in the preset training samples. Assuming the preset ratio is 1:1, the first facial images account for 50% and the second facial images account for 50%.
[0061] 205. Scale the training sample image according to a second preset size.
[0062] 206. Input the scaled training sample image into a RESNet network model to extract training image features of the sample image.
[0063] In actual use, different preset face postures correspond to different face recognition models. Different recognition models can refer to face recognition models with different model structures, or face recognition models with the same model structure but different model parameters. In the embodiment of the present invention, the face recognition model with the same model structure but different model parameters is the RESNet network model.
[0064] ResNet (Residual Neural Network) is a 152-layer neural network that was successfully trained using the ResNet Unit. The ResNet structure can greatly accelerate the training of the neural network, and the accuracy of the model has also been greatly improved. The RESNet network model is used to improve the speed and accuracy of image feature extraction.
[0065] 207. According to the training image features and the actual image features of the training samples, the model parameters of the RESNet network model are corrected using an a-softmax loss function so that the loss function value between the actual image features of the training samples and the training features is minimized.
[0066] The RESNet network model is trained multiple times through multiple training images, and the model parameters of the RESNet network model are repeatedly corrected according to the a-softmax loss function during the training process so that the loss function value between the actual image features of the training samples and the training features is minimized.
[0067] 208. Obtain an image to be identified.
[0068] 209. Extract image features of the image to be recognized based on a face recognition model corresponding to a preset face posture to which the image to be recognized belongs, and determine whether the image to be recognized is stored in the sample image set based on the image features.
[0069] Before this step, it is necessary to find the preset face posture of the image to be identified. The process of finding the preset face posture of the image to be identified is similar to the method of finding the preset face posture of the face image, which specifically includes: calculating the face posture of the image to be identified, and the face posture to be identified includes three posture parameters: yaw angle, pitch angle and roll angle; calculating the angle difference to be identified between the face posture to be identified and the preset face posture, and the angle difference to be identified refers to the yaw angle difference to be identified, the pitch angle difference to be identified and the roll angle difference to be identified. square sum, the yaw angle difference to be identified refers to the difference between the yaw angle of the face posture to be identified and the yaw angle of each of the preset face postures, the pitch angle difference to be identified refers to the difference between the pitch angle of the face posture to be identified and the pitch angle of each of the preset face postures, the roll angle difference to be identified refers to the difference between the roll angle of the face posture to be identified and the roll angle of each of the preset face postures; determine that the preset face posture corresponding to the minimum value of the angle differences to be identified is the preset face posture to which the face posture to be identified belongs.
[0070] According to a face recognition model corresponding to a preset face posture to which the image to be recognized belongs, image features of the image to be recognized are extracted, and it is determined whether the image to be recognized is stored in the sample image set, specifically comprising: according to the face recognition model corresponding to the preset face posture to which the face posture to be recognized belongs, calculating the image features to be recognized of the image to be recognized and sample image features of face images in the sample image set corresponding to the preset face posture to which the face posture to be recognized belongs; according to cosine similarity, calculating the feature similarity between the feature of the image to be recognized and the feature of the sample image; if the feature similarity is greater than the preset similarity, determining that the image to be recognized is stored in the sample image set.
[0071] The facial images in the sample image set are all pre-stored, and the personal information corresponding to the facial image can be accurately found. Therefore, it is determined that the image to be identified is stored in the sample image set. At the same time, the facial image most similar to the image to be identified can be determined, and then the personal information corresponding to the image to be identified can be accurately determined, so as to facilitate other processing based on the personal information.
[0072] The present invention provides a face recognition method based on face posture, firstly obtains a face image shot according to a preset shooting mode, then calculates the shooting face posture of the face image, then selects the preset face posture to which the face image belongs according to the shooting face posture, and saves the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture, then trains a face recognition model corresponding to each preset face posture according to the face images in the sample image set corresponding to the preset face posture, then obtains an image to be recognized, finally extracts the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judges whether the image to be recognized is saved in the sample image set according to the image features. Compared with the prior art, the embodiment of the present invention can improve the recognition accuracy by shooting a large number of face images with different shooting face postures, increasing the number of sample images. Furthermore, the face images are classified according to the face postures, divided into sample image sets corresponding to different preset face postures, and a comparison image with a face posture similar to the image to be recognized is selected, so as to improve the recognition accuracy. Furthermore, a face recognition model corresponding to a sample image set corresponding to a preset face posture is trained, and different face recognition models are selected for images to be recognized with different face postures, so that the similarity between the image to be recognized and the face recognition model is higher, and recognition accuracy can also be improved.
[0073] Furthermore, as a response to the above Figure 1 The embodiment of the present invention provides a face recognition device based on face posture, such as Figure 3 As shown, the device comprises:
[0074] A first acquisition module 31 is used to acquire a face image captured in a preset shooting mode;
[0075] A calculation module 32, used for calculating the facial posture of the facial image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle;
[0076] A search module 33, used for searching the preset face posture to which the face image belongs according to the photographed face posture, and saving the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture;
[0077] A training module 34, configured to train a face recognition model corresponding to each of the preset face postures according to the face images in the sample image set corresponding to the preset face postures;
[0078] The second acquisition module 35 is used to acquire the image to be recognized;
[0079] The judgment module 36 is used to extract the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judge whether the image to be recognized is stored in the sample image set according to the image features.
[0080] The present invention provides a face recognition method based on face posture, firstly obtains a face image shot according to a preset shooting mode, then calculates the shooting face posture of the face image, then selects the preset face posture to which the face image belongs according to the shooting face posture, and saves the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture, then trains a face recognition model corresponding to each preset face posture according to the face images in the sample image set corresponding to the preset face posture, then obtains an image to be recognized, finally extracts the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judges whether the image to be recognized is saved in the sample image set according to the image features. Compared with the prior art, the embodiment of the present invention can improve the recognition accuracy by shooting a large number of face images with different shooting face postures, increasing the number of sample images. Furthermore, the face images are classified according to the face postures, divided into sample image sets corresponding to different preset face postures, and a comparison image with a face posture similar to the image to be recognized is selected, so as to improve the recognition accuracy. Furthermore, a face recognition model corresponding to a sample image set corresponding to a preset face posture is trained, and different face recognition models are selected for images to be recognized with different face postures, so that the similarity between the image to be recognized and the face recognition model is higher, and recognition accuracy can also be improved.
[0081] Furthermore, as a response to the above Figure 2The embodiment of the present invention provides another face recognition device based on face posture, such as Figure 4 As shown, the device comprises:
[0082] A first acquisition module 41 is used to acquire a face image captured in a preset shooting mode;
[0083] A calculation module 42, used for calculating the facial posture of the facial image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle;
[0084] A search module 43, used for searching the preset face posture to which the face image belongs according to the photographed face posture, and saving the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture;
[0085] A training module 44, configured to train a face recognition model corresponding to each of the preset face postures according to the face images in the sample image set corresponding to the preset face postures;
[0086] The second acquisition module 45 is used to acquire the image to be recognized;
[0087] The judgment module 46 is used to extract the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judge whether the image to be recognized is stored in the sample image set according to the image features.
[0088] Furthermore, the calculation module 42 includes:
[0089] An extraction unit 421 is used to extract a face rectangular area in the face image according to a preset face recognition algorithm;
[0090] An establishing unit 422 is used to establish a face coordinate system with the upper left corner or the lower right corner of the face rectangular area as a coordinate origin;
[0091] A searching unit 423 is used to search for facial key points in the facial rectangular area according to the cascade convolutional neural network model, and record the facial key point coordinates of the facial key points according to the facial coordinate system;
[0092] A calculation unit 424 is used to calculate a rotation angle of the preset three-dimensional model according to a rotation rule, wherein the rotation rule is to rotate the preset three-dimensional model to a point where the projection of the facial key points in the preset three-dimensional model on the facial image has a minimum distance from the coordinates of the facial key points;
[0093] The determination unit 425 is used to determine the rotation angle as the photographed face posture.
[0094] Furthermore, the calculation module 42 includes:
[0095] The extraction unit 421 is further configured to extract a rectangular face region in the face image according to a preset face recognition algorithm;
[0096] A scaling unit 426, configured to scale the face rectangular area according to a first preset size;
[0097] The establishing unit 422 is further configured to establish a face coordinate system with the upper left corner or the lower right corner of the scaled face rectangular area as a coordinate origin;
[0098] The search unit 423 is further used to search for facial key points in the scaled facial rectangular area according to the cascade convolutional neural network model, and record the facial key point coordinates of the facial key points according to the facial coordinate system;
[0099] The calculation unit 424 is further used to input the scaled face rectangular area and the coordinates of the face key points into the VGGNet network model to calculate the photographed face posture.
[0100] Furthermore, the search module 43 includes:
[0101] A calculation unit 431 is used to calculate the shooting angle difference between the photographed face posture and each of the preset face postures, wherein the angle difference refers to the sum of the squares of the shooting yaw angle difference, the shooting pitch angle difference and the shooting roll angle difference, wherein the shooting yaw angle difference refers to the difference between the yaw angle of the photographed face posture and the yaw angle of each of the preset face postures, the shooting pitch angle difference refers to the difference between the pitch angle of the photographed face posture and the pitch angle of each of the preset face postures, and the shooting roll angle difference refers to the difference between the roll angle of the photographed face posture and the roll angle of each of the preset face postures;
[0102] The determining unit 432 is configured to determine that the preset face posture corresponding to the minimum value of the shooting angle difference is the preset face posture to which the shot face posture belongs.
[0103] Furthermore, the face recognition model is a RESNet network model; the training module 44 includes:
[0104] A selection unit 441 is used to select training sample images from a sample image set corresponding to the preset facial posture, wherein the training sample images include a first facial image whose shooting angle difference with the preset facial posture is less than a preset value, and a second facial image whose shooting angle difference with the preset facial posture is not less than a preset value, and a ratio of the number of images of the first facial image to the number of images of the second facial image is a preset ratio;
[0105] A scaling unit 442, configured to scale the training sample image according to a second preset size;
[0106] An extraction unit 443 is used to input the scaled training sample image into a RESNet network model to extract training image features of the sample image;
[0107] The correction unit 444 is used to correct the model parameters of the RESNet network model using an a-softmax loss function according to the training image features and the actual image features of the training samples, so as to minimize the loss function value between the actual image features of the training samples and the training features.
[0108] Furthermore, the method further comprises:
[0109] A calculation module 47 is used for calculating the face posture of the image to be recognized before judging whether the image to be recognized is stored in the sample image set according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, wherein the face posture to be recognized includes three posture parameters of yaw angle, pitch angle and roll angle;
[0110] The calculation module 47 is further used to calculate the angle difference to be identified between the face posture to be identified and the preset face posture, the angle difference to be identified refers to the square sum of the yaw angle difference to be identified, the pitch angle difference to be identified and the roll angle difference to be identified, the yaw angle difference to be identified refers to the difference between the yaw angle of the face posture to be identified and the yaw angle of each of the preset face postures, the pitch angle difference to be identified refers to the difference between the pitch angle of the face posture to be identified and the pitch angle of each of the preset face postures, and the roll angle difference to be identified refers to the difference between the roll angle of the face posture to be identified and the roll angle of each of the preset face postures;
[0111] The determination module 48 is used to determine that the preset face posture corresponding to the minimum value of the angle difference to be identified is the preset face posture to which the face posture to be identified belongs.
[0112] Furthermore, the judging module 46 includes:
[0113] A calculation unit 461 is used to calculate the image features to be recognized of the image to be recognized and the sample image features of the face images in the sample image set corresponding to the preset face posture to which the face posture to be recognized belongs, according to the face recognition model corresponding to the preset face posture to which the face posture to be recognized belongs;
[0114] The calculation unit 461 is further used to calculate the feature similarity between the to-be-identified image feature and the sample image feature according to the cosine similarity;
[0115] The determination unit 462 is configured to determine that the image to be identified is stored in the sample image set if the feature similarity is greater than a preset similarity.
[0116] The present invention provides a face recognition method based on face posture, firstly obtains a face image shot according to a preset shooting mode, then calculates the shooting face posture of the face image, then selects the preset face posture to which the face image belongs according to the shooting face posture, and saves the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture, then trains a face recognition model corresponding to each preset face posture according to the face images in the sample image set corresponding to the preset face posture, then obtains an image to be recognized, finally extracts the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judges whether the image to be recognized is saved in the sample image set according to the image features. Compared with the prior art, the embodiment of the present invention can improve the recognition accuracy by shooting a large number of face images with different shooting face postures, increasing the number of sample images. Furthermore, the face images are classified according to the face postures, divided into sample image sets corresponding to different preset face postures, and a comparison image with a face posture similar to the image to be recognized is selected, so as to improve the recognition accuracy. Furthermore, a face recognition model corresponding to a sample image set corresponding to a preset face posture is trained, and different face recognition models are selected for images to be recognized with different face postures, so that the similarity between the image to be recognized and the face recognition model is higher, and recognition accuracy can also be improved.
[0117] According to an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the face recognition method based on face gesture in any of the above method embodiments.
[0118] Figure 5 A schematic diagram of the structure of a computer device provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the computer device.
[0119] like Figure 5 As shown, the computer device may include: a processor (processor) 502 , a communication interface (Communications Interface) 504 , a memory (memory) 506 , and a communication bus 508 .
[0120] The processor 502 , the communication interface 504 , and the memory 506 communicate with each other via a communication bus 508 .
[0121] The communication interface 504 is used to communicate with other devices such as clients or other servers.
[0122] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above-mentioned embodiment of the face recognition method based on face posture.
[0123] Specifically, the program 510 may include program codes, which include computer operation instructions.
[0124] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the computer device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0125] The memory 506 is used to store the program 510. The memory 506 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0126] The program 510 may be specifically configured to enable the processor 502 to perform the following operations:
[0127] Obtain a face image taken according to a preset shooting method;
[0128] Calculating the facial posture of the facial image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle;
[0129] According to the photographed facial posture, searching for a preset facial posture to which the facial image belongs, and saving the facial image to which the preset facial posture belongs in a sample image set corresponding to the preset facial posture;
[0130] According to the face images in the sample image set corresponding to the preset face postures, training a face recognition model corresponding to each of the preset face postures;
[0131] Obtain an image to be recognized;
[0132] According to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, image features of the image to be recognized are extracted, and according to the image features, it is determined whether the image to be recognized is stored in the sample image set.
[0133] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0134] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A face recognition method based on face posture, characterized in that: include: Obtain a face image taken according to a preset shooting method; Calculating the facial posture of the facial image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle; According to the photographed facial posture, searching for a preset facial posture to which the facial image belongs, and saving the facial image to which the preset facial posture belongs in a sample image set corresponding to the preset facial posture, and if the facial image to which the preset facial posture belongs is not saved in the sample image set corresponding to the preset facial posture, reacquiring the facial image; According to the face images in the sample image set corresponding to the preset face postures, training a face recognition model corresponding to each of the preset face postures; Obtain an image to be recognized; Extracting image features of the image to be recognized according to a face recognition model corresponding to a preset face posture to which the image to be recognized belongs, and determining whether the image to be recognized is stored in the sample image set according to the image features; The calculating the facial posture of the facial image includes: Extracting a rectangular face area in the face image according to a preset face recognition algorithm; Establishing a face coordinate system with the upper left corner or the lower right corner of the face rectangular area as the coordinate origin; According to the cascade convolutional neural network model, searching for facial key points within the facial rectangular area, and recording the facial key point coordinates of the facial key points according to the facial coordinate system; Calculating a rotation angle of the preset three-dimensional model according to a rotation rule, wherein the rotation rule is to rotate the preset three-dimensional model to a point where the projection of the facial key points in the preset three-dimensional model on the facial image is at a minimum distance from the coordinates of the facial key points; Determine the rotation angle as the photographed face posture; Before judging whether the image to be recognized is stored in the sample image set according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, the method further comprises: Calculating the face posture of the image to be recognized, wherein the face posture includes three posture parameters: yaw angle, pitch angle and roll angle; Calculating the angle difference to be identified between the face posture to be identified and the preset face posture, the angle difference to be identified refers to the square sum of the yaw angle difference to be identified, the pitch angle difference to be identified and the roll angle difference to be identified, the yaw angle difference to be identified refers to the difference between the yaw angle of the face posture to be identified and the yaw angle of each of the preset face postures, the pitch angle difference to be identified refers to the difference between the pitch angle of the face posture to be identified and the pitch angle of each of the preset face postures, and the roll angle difference to be identified refers to the difference between the roll angle of the face posture to be identified and the roll angle of each of the preset face postures; The preset face posture corresponding to the minimum value of the to-be-recognized angle differences is determined as the preset face posture to which the to-be-recognized face posture belongs.
2. The method according to claim 1, characterized in that The calculating the facial posture of the facial image includes: Scaling the face rectangular area according to a first preset size; Establishing a face coordinate system with the upper left corner or the lower right corner of the scaled face rectangular area as the coordinate origin; According to the cascade convolutional neural network model, searching for facial key points within the scaled facial rectangular area, and recording the facial key point coordinates of the facial key points according to the facial coordinate system; The scaled face rectangular area and the coordinates of the face key points are input into the VGGNet network model to calculate the posture of the photographed face.
3. The method according to claim 1, characterized in that The step of searching for a preset face posture to which the face image belongs according to the photographed face posture comprises: Calculating the shooting angle difference between the photographed face posture and each of the preset face postures, the angle difference refers to the sum of the squares of the shooting yaw angle difference, the shooting pitch angle difference and the shooting roll angle difference, the shooting yaw angle difference refers to the difference between the yaw angle of the photographed face posture and the yaw angle of each of the preset face postures, the shooting pitch angle difference refers to the difference between the pitch angle of the photographed face posture and the pitch angle of each of the preset face postures, and the shooting roll angle difference refers to the difference between the roll angle of the photographed face posture and the roll angle of each of the preset face postures; The preset face posture corresponding to the minimum value of the shooting angle difference is determined as the preset face posture to which the shot face posture belongs.
4. The method according to claim 3, characterized in that The face recognition model is a RESNet network model; the training of the face recognition model corresponding to each of the preset face postures according to the face images in the sample image set corresponding to the preset face postures includes: Selecting training sample images from a sample image set corresponding to the preset facial posture, the training sample images including a first facial image having a shooting angle difference with the preset facial posture that is less than a preset value, and a second facial image having a shooting angle difference with the preset facial posture that is not less than a preset value, and a ratio of the number of images of the first facial image to the number of images of the second facial image is a preset ratio; Scaling the training sample image according to a second preset size; Inputting the scaled training sample image into the RESNet network model to extract training image features of the sample image; According to the training image features and the actual image features of the training samples, the model parameters of the RESNet network model are corrected using the a-softmax loss function so that the loss function value of the actual image features of the training samples and the training features is minimized.
5. The method according to claim 4, characterized in that The extracting the image features of the image to be recognized according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, and judging whether the image to be recognized is stored in the sample image set according to the image features, comprises: Calculating, according to a face recognition model corresponding to a preset face posture to which the face posture to be recognized belongs, image features to be recognized of the image to be recognized and sample image features of face images in a sample image set corresponding to the preset face posture to which the face posture to be recognized belongs; Calculating the feature similarity between the image feature to be identified and the sample image feature according to the cosine similarity; If the feature similarity is greater than a preset similarity, it is determined that the image to be identified is stored in the sample image set.
6. A face recognition device based on face posture, characterized in that: include: A first acquisition module, used to acquire a face image captured in a preset shooting mode; A calculation module, used for calculating the facial posture of the face image, wherein the facial posture includes three posture parameters: yaw angle, pitch angle and roll angle; a search module, configured to search for a preset face posture to which the face image belongs according to the photographed face posture, and save the face image to which the preset face posture belongs in a sample image set corresponding to the preset face posture, and if the face image to which the preset face posture belongs is not saved in the sample image set corresponding to the preset face posture, reacquire the face image; A training module, for training a face recognition model corresponding to each of the preset face postures according to the face images in the sample image set corresponding to the preset face postures; A second acquisition module is used to acquire an image to be identified; A judgment module, used for extracting image features of the image to be recognized according to a face recognition model corresponding to a preset face posture to which the image to be recognized belongs, and judging whether the image to be recognized is stored in the sample image set according to the image features; The computing module comprises: An extraction unit, used for extracting a rectangular face area in the face image according to a preset face recognition algorithm; An establishing unit, configured to establish a face coordinate system with the upper left corner or the lower right corner of the face rectangular area as a coordinate origin; A searching unit, configured to search for facial key points within the facial rectangular area according to a cascaded convolutional neural network model, and record facial key point coordinates of the facial key points according to the facial coordinate system; a calculation unit, configured to calculate a rotation angle of a preset three-dimensional model according to a rotation rule, wherein the rotation rule is to rotate the preset three-dimensional model to a point where the projection of a facial key point in the preset three-dimensional model on the facial image has a minimum distance from the coordinates of the facial key point; A determination unit, configured to determine the rotation angle as the photographed face posture; The calculation module is used for calculating the face posture of the image to be recognized before judging whether the image to be recognized is stored in the sample image set according to the face recognition model corresponding to the preset face posture to which the image to be recognized belongs, wherein the face posture to be recognized includes three posture parameters of yaw angle, pitch angle and roll angle; The calculation module is further used to calculate the angle difference to be identified between the face posture to be identified and the preset face posture, the angle difference to be identified refers to the square sum of the yaw angle difference to be identified, the pitch angle difference to be identified and the roll angle difference to be identified, the yaw angle difference to be identified refers to the difference between the yaw angle of the face posture to be identified and the yaw angle of each of the preset face postures, the pitch angle difference to be identified refers to the difference between the pitch angle of the face posture to be identified and the pitch angle of each of the preset face postures, and the roll angle difference to be identified refers to the difference between the roll angle of the face posture to be identified and the roll angle of each of the preset face postures; The determination module is used to determine that the preset face posture corresponding to the minimum value of the angle difference to be identified is the preset face posture to which the face posture to be identified belongs.
7. A storage medium storing at least one executable instruction, wherein the executable instruction enables a processor to perform operations corresponding to the face recognition method based on face gesture as described in any one of claims 1 to 5.
8. A computer device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the face recognition method based on face posture as described in any one of claims 1-5.
