Method, system, device and storage medium for estimating face posture based on feature matching
Through feature matching and matching of contour feature information, the problem of low accuracy and long time consumption caused by large poses and unsatisfactory lighting in face pose estimation is solved, and efficient and accurate face pose estimation is achieved.
Patent Information
- Application Number
- CN202111078266.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-09-15
AI Technical Summary
Existing face pose estimation methods have low accuracy in locating facial key points when dealing with large poses and unsatisfactory lighting conditions, resulting in inaccurate pose estimation. In addition, high-precision positioning of facial key points requires a lot of time and affects algorithm performance. .
The face pose estimation method based on feature matching is used to obtain the face image for face detection and cropping preprocessing, and then input it into the feature extraction network model to obtain the contour feature information, and match it with the multi-pose face template, using cosine similarity The degree function calculates the similarity score and obtains the pose information of the best matching template.
It improves the accuracy of facial pose estimation, reduces the impact of feature point positioning errors, shortens the time-consuming algorithm, and achieves more efficient gesture information output.
Smart Images

Figure CN113901884B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method, system, device and storage medium for estimating facial posture based on feature matching. Background Art
[0002] In the existing field of facial pattern recognition technology, face pose estimation refers to determining the rotation angle of a face in different dimensions in three-dimensional space through continuous video or a single picture. Two-dimensional images are usually used to solve the problem of head pose classification. Since one-dimensional information is reduced, face pose estimation has always been a challenging research project. With the application of intelligent algorithms, more and more people are studying face detection, face feature point positioning, face recognition, face attribute classification, face pose classification, etc., but no matter which algorithm, high-quality face images will provide performance guarantee for the development of algorithms. However, if the side face image with a large head deflection angle often has a negative impact on the results of algorithms such as face recognition, so the face pose estimation algorithm has always played a very important role in the field of facial modeling and analysis. Solving this problem can not only improve the performance of face-related algorithms, but also face pose estimation itself has high application value.
[0003] The commonly used method is to estimate the posture based on the facial key point algorithm. From the perspective of technical implementation, it is already very mature. However, if it involves large postures, poor lighting and other factors, it will affect the positioning accuracy of the facial key point algorithm. This error will be amplified in the second stage of calculating the facial posture, resulting in inaccurate estimation. In addition, if the facial key point positioning algorithm is more accurate, it will take a certain amount of time and consume hardware computing power. Therefore, there is an urgent need for an estimation method that can reduce the impact of positioning errors and reduce time consumption. Summary of the invention
[0004] In view of the shortcomings of the prior art, the present invention provides a method, system, device and storage medium for estimating face posture based on feature matching.
[0005] In order to solve the above technical problems, the present invention is solved by the following technical solutions:
[0006] A method for estimating face posture based on feature matching comprises the following steps:
[0007] Acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0008] Input the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0009] The contour feature information is matched with a preset face template to obtain a best matching template, wherein the posture information of the best matching template is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0010] As an implementable method, the face detection and cropping preprocessing are performed on the face image, specifically: face detection is performed on the face image and the face image is cropped into a uniform size, and the cropped size is uniformly adjusted to 256*256.
[0011] As an implementable method, each face template contains information of three rotation directions, specifically:
[0012] Obtain head data of different people in different postures;
[0013] The head dataset is used as a benchmark for head posture estimation. Each face image contains information in three rotation directions, where the angles in the three rotation directions are pitch angle, yaw angle and roll angle, which are converted into Euler angles.
[0014] As an implementable method, the contour feature information is obtained, the data of the 6th, 7th, 8th and 9th channels are taken, the information of the 6th and 7th channels is superimposed into a matrix A, the information of the 8th and 9th channels is superimposed into a matrix B, the matrices A and B are converted into corresponding visualization images, and the center of gravity points Pa and Pb of the visualization images are respectively calculated, the center of gravity points Ma and Mb of the face template image are obtained, and the center of gravity points Pa and Pb are made close to the center of gravity points Ma and Mb through similar changes, so that the face in the visualization image and the face template image are aligned, and the transformation matrix M is obtained, and the data of the extracted 13 channels are calculated through the matrix M to obtain feature maps F1, F2, ..., F 13 ;
[0015] The similarity between the 13 groups of features is calculated based on the cosine similarity function. The formula is as follows:
[0016]
[0017] Among them, F i is the feature map of the ith channel, b i is the face template feature map of the i-th channel, W i is the weight of the i-th channel, indicating the importance of the channel to the final similarity score;
[0018] The feature map and the feature map of the face template image Ft are calculated by the cosine similarity function to obtain a similarity score, and the similarity between the feature map and the feature map of the face template image is determined based on the similarity score.
[0019] As an implementable embodiment, the feature extraction network model feature extraction network selects the LAB face feature point positioning network and takes the 13-channel features of the middle layer "hourglass_4 / pred_heatmap / +".
[0020] A face posture estimation system based on feature matching, comprising a data acquisition module, a contour acquisition module and a matching and comparison module;
[0021] The data acquisition module is used to acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0022] The contour acquisition module is used to input the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0023] The matching and comparison module is used to match the contour feature information with the preset face template to obtain the best matching template, and the posture information of the best matching template is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0024] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the following method steps:
[0025] Acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0026] Input the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0027] The contour feature information is matched with a preset face template to obtain a best matching template, wherein the posture information of the best matching template is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0028] A face posture estimation device based on feature matching includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following method steps are implemented:
[0029] Acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0030] Input the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0031] The contour feature information is matched with a preset face template to obtain a best matching template, wherein the posture information of the best matching template is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0032] The present invention has significant technical effects due to the adoption of the above technical solution:
[0033] The method has high accuracy. Compared with the posture estimation method based on facial feature point positioning, the present invention avoids the influence of feature point positioning error on the result by extracting facial contour features, and outputs posture information by feature matching, which has higher accuracy.
[0034] The algorithm takes less time. Since the time required to extract the face contour features in the present invention is less than that required to locate the face key points, the feature matching only needs to match the optimal template under a certain strategy, which saves the time of the method.
[0035] The implementation is simple. The present invention uses a pre-trained facial feature point positioning model and only uses the facial contour features of the middle layer. The whole system is implemented based on Python, including calling the face detection algorithm, contour feature extraction, image alignment, and feature matching. It is simple and easy to use, and the learning speed is fast. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0037] Figure 1 It is a schematic diagram of the overall process of the method of the present invention;
[0038] Figure 2 It is a schematic diagram of the result of the visualization operation of the present invention. DETAILED DESCRIPTION
[0039] The present invention is further described in detail below in conjunction with embodiments. The following embodiments are for explanation of the present invention but the present invention is not limited to the following embodiments.
[0040] Embodiment 1:
[0041] A method for estimating face posture based on feature matching comprises the following steps:
[0042] S100, obtaining a face image containing a posture to be estimated, and performing face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0043] S200, inputting the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0044] S300, matching the contour feature information with a preset face template to obtain a template with the best matching degree, wherein the posture information of the template with the best matching degree is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0045] Based on the above example method, Figure 1 As shown, there may be the following specific implementations:
[0046] a) Prepare multi-person and multi-pose face templates and feature extraction network
[0047] The important part of template matching is the richness of the template. The template is the BIWI head pose dataset. The BIWI dataset contains 24 videos and about 15,678 frames of face images. The collection process is that the collector sits in front of the sensor and turns their head freely. This method is used to collect head data of different people in different postures. This dataset is usually used as a benchmark for head pose estimation using deep methods. Each face image provides information in three rotation directions.
[0048] Euler angles are a set of independent angular parameters used to determine the rotational position of a rigid body, namely pitch, yaw, and roll. Here we take Python operation as an example to convert the information W provided by the BIWI dataset into Euler angles.
[0049] Specifically: roll = -numpy.arctan2(W[1][0],W[0][0])*180 / numpy.pi
[0050] yaw=-numpy.arctan2(-W[2][0],numpy.sqrt(W[2][1]**2+W[2][2]**2))*
[0051] 180 / numpy.pi
[0052] pitch=numpy.arctan2(pose_w[2][1],pose_w[2][2])*180 / numpy.pi
[0053] The known head rotation matrix is:
[0054]
[0055] The Euler angles are:
[0056]
[0057]
[0058]
[0059] Among them, roll represents the pitch angle, yaw represents the yaw angle, and pitch represents the roll angle.
[0060] The feature extraction network uses the LAB facial feature point positioning network, loads the pre-trained model, and only takes the 13-channel features of the middle layer "hourglass_4 / pred_heatmap / +" as the feature information of the facial posture. Since the LAB network accurately locates the facial feature points, this method only needs the facial contour features of the middle layer, so the parameters in the network are reduced, and some convolutional layers and fully connected layers are deleted to obtain the optimized network LAB_s. Then take the 13-channel features of the middle layer "hourglass_4 / pred_heatmap / +".
[0061] It should be noted that the extracted feature is the contour information of the face, and the selection of this feature can effectively avoid errors in the subsequent feature point positioning.
[0062] b) Perform face detection and cropping on the input image. Since the input image often contains other information besides the face, it is necessary to perform face detection on the image and crop it to a uniform size before feature extraction. The yoloface face detection algorithm is used here, and the cropped size is uniformly adjusted to 256*256, which can be other sizes. The two existing versions of the algorithm are 256*256 and 112*112. Other sizes can also be set, but the model parameters need to be adjusted according to different input sizes. However, it is recommended to set it too large or too small. Too large is unnecessary and will increase the algorithm time; too small will lose a lot of image information and affect performance. 256*256 is a more suitable input size.
[0063] c) Input the processed face image into the prepared feature extraction network to extract the face contour features. After the feature information is visualized, Figure 2 shown.
[0064] d) Match the features of the template with the features of the face image
[0065] After obtaining the feature information of the input image, it is necessary to find the best template through feature matching to determine the posture information of the face in the current input image. Since the position of the cropped face in the image is not completely consistent, it is necessary to complete it through image alignment first. Here, Python operation is used as an example to explain its calculation process in detail.
[0066] (1) After obtaining the feature Fi of the input image, take the data of the 6th, 7th, 8th, and 9th channels, superimpose the information of the 6th and 7th channels into matrix A, and superimpose the information of the 8th and 9th channels into matrix B. Convert matrices A and B into corresponding visual images, and calculate the center of gravity points Pa and Pb of the images respectively. Perform the same operation on the template image to obtain points Ma and Mb. Through similar changes, translate and scale the input image so that points Pa and Pb are as close as possible to the defined points Ma and Mb, so that the faces in the two images are aligned, thereby obtaining the transformation matrix M and the transformed feature map Fr, that is, the feature maps F1, F2, ..., F 13 .
[0067] Template_size = Fi.shape
[0068] Fr=cv2.warpAffine(Fi,M,Template_size)
[0069] (2) The system uses cosine similarity to calculate the similarity between two feature maps. A set of cosine similarity functions is constructed in advance as follows:
[0070]
[0071] Among them, F i is the feature map of the ith channel, b i is the face template feature map of the i-th channel, W i is the weight of the ith channel, indicating the importance of the channel to the final similarity score. The similarity of the 13 sets of features corresponding to the number of channels is calculated and multiplied by the weights. Finally, the similarity scores are added together to determine the similarity between the features and the features of the face template image. However, in order to make the cosine similarity function closer to the actual situation, the cosine similarity function needs to be optimized to adjust the features of the face template and the channel. Therefore, the cosine similarity function is transformed into Here, F i is the feature map of the ith channel, b i is the face template feature map of the i-th channel, W i is the weight of the ith channel, Represents the adaptive coefficient of the ith channel, which is selected based on the iteration of each channel. represents the maximum inertia coefficient, represents the minimum inertia coefficient, X represents the number of iterations of the current channel, and X max Represents the maximum number of iterations of the channel. (3) The cosine similarity of the obtained new feature map Fr and the feature map Ft of the template is calculated through the above cosine similarity function to obtain the similarity score cos.
[0072] cos=Cosine_similarity(Fr,Ft)
[0073] e) Get the best template. The posture information of the current template is the input face image posture information.
[0074] Template matching starts with the frontal face posture calculation, and then calculates with the posture templates distributed around the frontal face to obtain the rotation direction with the greatest similarity improvement, and then performs the next stage of calculation along this rotation direction. Note that each stage proceeds downward along the rotation direction with the greatest similarity improvement until the similarity score no longer increases. This mechanism can effectively reduce the amount of calculation and greatly reduce the time consumption of the algorithm. Finally, the posture information of the face in the matched optimal template is the posture information of the face in the input image.
[0075] Embodiment 2:
[0076] A face posture estimation system based on feature matching, comprising a data acquisition module, a contour acquisition module and a matching and comparison module;
[0077] The data acquisition module is used to acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0078] The contour acquisition module is used to input the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0079] The matching and comparison module is used to match the contour feature information with the preset face template to obtain the best matching template, and the posture information of the best matching template is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0080] Embodiment 3:
[0081] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the following method steps:
[0082] Acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image;
[0083] Input the preprocessed image into a preset feature extraction network model to obtain contour feature information;
[0084] The contour feature information is matched with a preset face template to obtain a best matching template, wherein the posture information of the best matching template is the input face image posture information, wherein the face template is a multi-posture face template, and each face template contains information of three rotation directions.
[0085] Embodiment 4:
[0086] In one embodiment, a facial posture assessment device based on feature matching is provided, and the facial posture assessment device based on feature matching can be a server or a mobile terminal. The facial posture assessment device based on feature matching includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the facial posture assessment device based on feature matching is used to provide computing and control capabilities. The memory of the facial posture assessment device based on feature matching 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 stores all data of the facial posture assessment device based on feature matching. 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 method for facial posture assessment based on feature matching is implemented.
[0087] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0088] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0089] The present invention is described with reference to the flowcharts and / or block diagrams of the method, terminal device (system), and computer program product according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0090] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0091] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0092] It should be noted that:
[0093] The "one embodiment" or "embodiment" mentioned in the specification means that the specific features, structures or characteristics described in conjunction with the embodiment are included in at least one embodiment of the present invention. Therefore, the phrases "one embodiment" or "embodiment" appearing in various places throughout the specification do not necessarily refer to the same embodiment.
[0094] In addition, it should be noted that the specific embodiments described in this specification may have different functional expressions and names in the programs. Any equivalent or simple changes made based on the structure, features and principles described in the patent concept of the present invention are included in the protection scope of the patent of the present invention. Technicians in the technical field to which the present invention belongs can make various modifications or supplements to the specific embodiments described or replace them in a similar manner, as long as they do not deviate from the structure of the present invention or exceed the scope defined by the claims, they should all fall within the protection scope of the present invention.
Claims
1. A method for estimating facial posture based on feature matching, characterized in that: The following steps are involved: Acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image; Input the preprocessed image into a preset feature extraction network model to obtain contour feature information; Matching the contour feature information with a preset face template to obtain a template with the best matching degree, wherein the posture information of the template with the best matching degree is the posture information of the input face image, wherein the face template is a multi-pose face template, and each face template contains information of three rotation directions; The specific steps of matching the contour feature information with the preset face template are as follows: Obtain contour feature information, take the data of the 6th, 7th, 8th and 9th channels, superimpose the information of the 6th and 7th channels into matrix A, superimpose the information of the 8th and 9th channels into matrix B, convert matrices A and B into corresponding visualization images, and respectively calculate the center of gravity points Pa and Pb of the visualization images, obtain the center of gravity points Ma and Mb of the face template image, and through similar changes, make the center of gravity points Pa and Pb close to the center of gravity points Ma and Mb, so that the face in the visualization image and the face template image are aligned, and obtain the transformation matrix M, and calculate the data of the extracted 13 channels through the matrix M to obtain feature maps F1, F2, ..., F 13 ; The similarity between the 13 groups of features is calculated based on the cosine similarity function. The formula is as follows: Among them, F i is the feature map of the ith channel, b i is the face template feature map of the i-th channel, W i is the weight of the i-th channel, indicating the importance of the channel to the final similarity score; The feature map and the feature map of the face template image Ft are calculated by the cosine similarity function to obtain a similarity score, and the similarity between the feature map and the feature map of the face template image is determined based on the similarity score.
2. The method for estimating facial posture based on feature matching according to claim 1, characterized in that: The face detection and cropping preprocessing are performed on the face image, specifically: face detection is performed on the face image and the face image is cropped into a uniform size, and the cropped size is uniformly adjusted to 256*256.
3. The method for estimating facial posture based on feature matching according to claim 1, characterized in that: Each face template contains information about three rotation directions, specifically: Obtain head data of different people in different postures; The head dataset is used as a benchmark for head posture estimation. Each face image contains information on three rotation directions, where the angles of the three rotation directions are pitch angle, yaw angle and roll angle, which are converted into Euler angles.
4. The method for estimating facial posture based on feature matching according to claim 1, characterized in that: The feature extraction network model feature extraction network selects the LAB face feature point positioning network, and the network is optimized first.
5. A face pose estimation system based on feature matching, characterized in that: It includes a data acquisition module, a contour acquisition module and a matching and comparison module; The data acquisition module is used to acquire a face image containing a posture to be estimated, and perform face detection and cropping preprocessing on the face image to obtain a preprocessed image; The contour acquisition module is used to input the preprocessed image into a preset feature extraction network model to obtain contour feature information; The matching and comparison module is used to match the contour feature information with the preset face template to obtain the best matching degree template, the posture information of the best matching degree template is the input face image posture information, wherein the face template is a multi-pose face template, and each face template contains information of three rotation directions; Match the contour feature information with the preset face template, specifically: Obtain contour feature information, take the data of the 6th, 7th, 8th and 9th channels, superimpose the information of the 6th and 7th channels into matrix A, superimpose the information of the 8th and 9th channels into matrix B, convert matrices A and B into corresponding visualization images, and respectively calculate the center of gravity points Pa and Pb of the visualization images, obtain the center of gravity points Ma and Mb of the face template image, and through similar changes, make the center of gravity points Pa and Pb close to the center of gravity points Ma and Mb, so that the face in the visualization image and the face template image are aligned, and obtain the transformation matrix M, and calculate the data of the extracted 13 channels through the matrix M to obtain feature maps F1, F2, ..., F 13 ; The similarity between the 13 groups of features is calculated based on the cosine similarity function. The formula is as follows: Among them, F i is the feature map of the ith channel, b i is the face template feature map of the i-th channel, W i is the weight of the i-th channel, indicating the importance of the channel to the final similarity score; The feature map and the feature map of the face template image Ft are calculated by the cosine similarity function to obtain a similarity score, and the similarity between the feature map and the feature map of the face template image is determined based on the similarity score.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method steps according to any one of claims 1 to 4 are implemented.
7. A face posture estimation device based on feature matching, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method steps according to any one of claims 1 to 4 are implemented.
