Human face angle determination method and device based on computer vision, equipment and medium
By combining the target area detection model and the three-dimensional key point detection model, and using the basic three-dimensional face key point template and large angle judgment standards, the problem of low face angle calculation accuracy is solved and accurate calculation of the face angle is achieved.
Patent Information
- Application Number
- CN202410834513.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology has large errors when calculating the face angle. Especially when the face angle is large, the calculation accuracy is low and it is difficult to accurately calculate the face angle.
The video frame is recognized and processed by the target area detection model to generate the facial recognition area, and the key points are extracted based on the improved three-dimensional key point detection model. It is calculated and evaluated based on the basic three-dimensional face key point template and the preset large-angle judgment standard to determine the face. angle.
It improves the calculation accuracy of the face angle, avoids errors caused by inaccurate detection of some key points at large angles, and achieves accurate calculation of the face angle.
Smart Images

Figure CN118609189A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a method, device, equipment and medium for determining a human face angle based on computer vision. Background Art
[0002] With the rapid development of computer vision technology, face angle and posture estimation has been widely used in security monitoring control systems, virtual reality and augmented reality applications, medical image analysis and biometrics. Therefore, it is very important to accurately calculate the face angle.
[0003] The prior art usually calculates the face angle using the 2D key points of the face detected on the image. However, the prior art face angle calculation method is prone to large errors, especially when the face angle is large, the calculated face angle error is even greater. Therefore, how to accurately calculate the face angle and improve the calculation accuracy of the face angle is a problem that needs to be solved urgently. Summary of the invention
[0004] The present invention provides a method, device, equipment and medium for determining a face angle based on computer vision, which can solve the problem of low calculation accuracy of the face angle.
[0005] According to one aspect of the present invention, a method for determining a face angle based on computer vision is provided, comprising:
[0006] Acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame;
[0007] Based on the target region detection model, the current video frame is processed to generate a basic facial recognition region including facial detection information, and the basic facial recognition region is expanded and cropped based on the facial detection information to generate a target facial recognition region corresponding to the current video frame; wherein the facial detection information includes coordinate position information corresponding to the basic facial recognition region;
[0008] Extract key points from the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame;
[0009] The target facial key point set is calculated and evaluated based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target face angle corresponding to the current video frame.
[0010] According to another aspect of the present invention, there is provided a device for determining a face angle based on computer vision, comprising:
[0011] A data acquisition module, used to acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame;
[0012] A region recognition module, used to process the current video frame based on the target region detection model, generate a basic face recognition region containing face detection information, and perform outward expansion and cropping of the basic face recognition region based on the face detection information to generate a target face recognition region corresponding to the current video frame; wherein the face detection information includes coordinate position information corresponding to the basic face recognition region;
[0013] A key point extraction module is used to extract key points from the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame;
[0014] The angle calculation module is used to calculate and evaluate the target facial key point set based on the basic three-dimensional facial key point template and the preset large angle judgment standard to determine the target face angle corresponding to the current video frame.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the computer vision-based face angle determination method described in any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the computer vision-based face angle determination method described in any embodiment of the present invention when executed.
[0020] According to another aspect of the present invention, a computer program product is provided, including a computer program, which, when executed by a processor, implements the method for determining a face angle based on computer vision as described in any embodiment of the present invention.
[0021] The technical solution of the embodiment of the present invention is to identify and process the current video frame corresponding to the target area through a target area detection model, generate a basic facial recognition area containing facial detection information, and perform outward expansion and cropping on the basic facial recognition area based on the facial detection information to generate a target facial recognition area corresponding to the current video frame, and then perform key point extraction on the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame, and finally, perform calculation and evaluation on the target facial key point set based on a basic three-dimensional face key point template and a preset large-angle judgment standard to determine the target face angle corresponding to the current video frame, thereby solving the problem of low calculation accuracy of the face angle. The three-dimensional face key point and large-angle judgment can avoid the problem of errors in the face angle calculation results caused by inaccurate detection of some key points in large angle situations, and can accurately calculate the face angle, thereby improving the calculation accuracy of the face angle.
[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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 creative work.
[0024] Figure 1 is a flowchart of a method for determining a face angle based on computer vision according to Embodiment 1 of the present invention;
[0025] Figure 2 is a schematic structural diagram of an improved target three-dimensional key point detection model provided according to the first embodiment of the present invention;
[0026] Figure 3 is a flowchart of a method for determining a face angle based on computer vision according to Embodiment 2 of the present invention;
[0027] Figure 4 is a schematic diagram of the structure of a device for determining a face angle based on computer vision according to Embodiment 3 of the present invention;
[0028] Figure 5 It is a structural schematic diagram of an electronic device for implementing the method for determining a face angle based on computer vision according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", "target", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] It is worth noting that the acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of national laws and regulations.
[0032] Embodiment 1
[0033] Figure 1 The flowchart of a method for determining a face angle based on computer vision provided in the first embodiment of the present invention is applicable to the case where the face angle in the camera area is calculated. The method can be performed by a device for determining a face angle based on computer vision. The device for determining a face angle based on computer vision can be implemented in the form of hardware and / or software. The device for determining a face angle based on computer vision can be configured in an electronic device, and for example, can be configured in a server. Figure 1 As shown, the method includes:
[0034] S110. Acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame.
[0035] The target area may refer to an area where the face angle needs to be calculated. The current video data may refer to a real-time video corresponding to the target area. Exemplarily, the current video data may be collected by a camera installed in the target area.
[0036] The current video frame may refer to each video frame included in the current video data. Usually, the current video frame includes at least one face image. It is worth noting that in the embodiment of the present invention, the current video data is a video shot after being authorized by the user.
[0037] S120. Process the current video frame based on the target area detection model to generate a basic facial recognition area containing facial detection information, and perform outward expansion and cropping on the basic facial recognition area based on the facial detection information to generate a target facial recognition area corresponding to the current video frame; wherein the facial detection information includes coordinate position information corresponding to the basic facial recognition area.
[0038] Among them, the target area detection model may refer to a pre-trained facial area detection model. Exemplarily, the target area detection model may be a Sample and Computation Redistribution for Efficient Face Detection (SCRFD) face detection model for efficient face detection. The target area detection model may be used to accurately identify and select the face in the current video frame. The basic facial recognition area may refer to a partial area in the current video frame that only contains a facial image. Usually, one facial image corresponds to one basic facial recognition area. Facial detection information may refer to coordinate position information corresponding to the basic facial recognition area. Exemplarily, it may be the coordinate position of the upper left corner of the detection box corresponding to the basic facial recognition area, and the coordinate position of the lower right corner.
[0039] Among them, the expansion cropping may refer to the operation of expanding and cropping the basic facial recognition area according to the detection frame. Exemplarily, the length and width of the detection frame may be enlarged by 1.2 times according to the 1:1.2 expansion standard and then cropped. The target facial recognition area may refer to the image area generated after the expansion cropping of the basic facial recognition area. Generally, the current video frame may contain multiple target facial recognition areas.
[0040] Specifically, the target region detection model can be used to perform face detection on the current video frame to obtain a basic face recognition region including a face detection frame and the detection frame coordinate position information. Afterwards, the face detection frame is expanded and cropped according to the detection frame coordinate position information to generate a target face recognition region corresponding to the basic face recognition region. In this way, it can be ensured that a larger range of face images is included in the target face recognition region, avoiding the situation where the detection frame is at the edge of the face, and providing an effective basis for subsequent operations.
[0041] S130, extracting key points from the target facial recognition area based on an improved target three-dimensional key point detection model, and generating a target facial key point set corresponding to the current video frame.
[0042] Among them, the target facial key point set may refer to a set of all key point coordinates corresponding to the same face area in the current video frame. Usually, one face area corresponds to a target facial key point set. The target 3D key point detection model may refer to a pre-trained 3D key point detection model. Exemplarily, the target 3D key point detection model may be an improved Joint 3D Face Reconstruction and Dense Alignment with Position Map Regression Network (PRNet). The target 3D key point detection model may be used to extract the 3D key points of the face in the target facial recognition area.
[0043] In an optional embodiment, the feature extraction part in the improved target three-dimensional key point detection model is a visual geometry group convolutional neural network re-emphasis backbone model. Figure 2 The figure shows a schematic diagram of the structure of an improved target three-dimensional key point detection model provided by an embodiment of the present invention. Specifically, the original residual network (ResNet) in PRNet is replaced by the Making Visual Geometry Group-style ConvNets Great Again (RepVGG) backbone model, and the result after the previous sum operation is introduced into each subsequent sum operation, that is, multiple branches that pass shallow semantic information downward are added, so that the deep feature map contains enough shallow semantic information. In this way, the nonlinear function (Rectified Linear Unit, ReLU) and the weight parameters of the convolution kernel can be separated, and the two processes can be decoupled, thereby simplifying the network structure, improving the interpretability and training efficiency of the network, and enabling the model to achieve better results without increasing parameters.
[0044] S140, calculating and evaluating the target facial key point set based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target facial angle corresponding to the current video frame.
[0045] Among them, the basic three-dimensional face key point template may refer to a pre-constructed standard three-dimensional face key point set. The basic three-dimensional face key point template can be used to perform matching evaluation on each target facial key point set. The preset large-angle judgment standard may refer to a pre-set large-angle evaluation standard. When a face is offset at a large angle, some key points may be detected inaccurately, resulting in a large error in the offset angle calculated based on the basic three-dimensional face key point template. Therefore, the offset angle can be re-judged by the preset large-angle judgment standard, thereby ensuring the accuracy of the target face angle finally obtained.
[0046] The target face angle may refer to the deflection angle corresponding to the face image in the current video frame. It is worth noting that in the embodiment of the present invention, the target face angle corresponds to the basic face recognition area, that is, one basic face recognition area corresponds to one target face angle. If there are multiple basic face recognition areas in the same current video frame, the current video frame also corresponds to multiple target face angles.
[0047] The technical solution of the embodiment of the present invention is to identify and process the current video frame corresponding to the target area through a target area detection model, generate a basic facial recognition area containing facial detection information, and perform outward expansion and cropping on the basic facial recognition area based on the facial detection information to generate a target facial recognition area corresponding to the current video frame, and then perform key point extraction on the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame, and finally, perform calculation and evaluation on the target facial key point set based on a basic three-dimensional face key point template and a preset large-angle judgment standard to determine the target face angle corresponding to the current video frame, thereby solving the problem of low calculation accuracy of the face angle. The three-dimensional face key points and large-angle judgment can avoid the problem of errors in the face angle calculation results caused by inaccurate detection of some key points in large angle situations, and can accurately calculate the face angle, thereby improving the calculation accuracy of the face angle.
[0048] Embodiment 2
[0049] Figure 3A flowchart of a method for determining facial angle based on computer vision is provided in the second embodiment of the present invention. This embodiment is refined based on the above-mentioned embodiment. In this embodiment, the operation of calculating and evaluating the target facial key point set based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target facial angle corresponding to the current video frame is specifically refined. It may include: matching the target facial key point set based on the basic three-dimensional facial key point template to generate deviation coordinates corresponding to the target facial key point set; determining the basic facial angle corresponding to the deviation coordinates based on a preset rotation matrix; determining the angle category corresponding to the target facial key point based on the preset large-angle judgment standard. If the angle category is a preset angle category, the basic facial angle is used as the target facial angle corresponding to the current video frame. Figure 3 As shown, the method includes:
[0050] S210: Obtain current video data corresponding to the target area.
[0051] The current video data includes at least one current video frame.
[0052] S220, identifying and processing the current video frame based on the target region detection model, generating a basic facial recognition region including facial detection information, and performing outward expansion and cropping on the basic facial recognition region based on the facial detection information to generate a target facial recognition region corresponding to the current video frame.
[0053] The facial detection information includes coordinate position information corresponding to the basic facial recognition area.
[0054] In an optional embodiment, the method also includes: obtaining historical video data, and performing data collection on the historical video data to generate a historical image data set corresponding to the historical video data; wherein the historical image data set includes each historical image data frame; performing facial annotation on each historical image data frame based on a preset area detection model to generate a target face detection sample including a facial bounding box, and combining and processing each target face detection sample to generate a target face detection data set; and training a basic area detection model based on the target face detection data set to obtain a trained target area detection model.
[0055] Among them, historical video data may refer to videos containing facial images collected within a historical time period. It is worth noting that the historical video data may be video data collected in a target area or may be video data collected in other areas, and the embodiments of the present invention do not limit this. Historical image data frames may refer to individual video frames contained in historical video data. A historical image data set may refer to a data set containing all historical image data frames in the same historical video data. Generally, the historical video data may be extracted frame by frame to obtain the historical image data frames corresponding to the historical video data, and then the historical image data frames may be arranged in sequence to form a historical image data set.
[0056] The preset region detection model may refer to a preset region detection model. Generally, the preset region detection model may be a region detection model that has been trained and has a certain accuracy, and the preset region detection model may be directly used to perform face detection on the historical image data frame. The face bounding box may refer to a face region detection box. Exemplarily, the face bounding box may be a rectangular box. Face annotation may refer to the operation of selecting a face region using a face bounding box.
[0057] Among them, the target face detection sample may refer to sample data containing only the face area. Usually, one face area corresponds to one target face detection sample. The target face detection data set may refer to a data set consisting of all target face detection samples corresponding to the historical video data. It is worth noting that in order to ensure the accuracy of the sample data, after the face is annotated for each historical image data frame based on the preset area detection model, the model output result can be corrected for missing or mislabeled by manual correction, and the corrected result can be used as the target face detection sample.
[0058] Among them, the basic region detection model may refer to a facial region detection model selected for subsequent face recognition. Exemplarily, it may be a SCRFD face detection model. It is worth noting that in an embodiment of the present invention, the basic region detection model and the target region detection model are the same region detection model in different states, and the two have the same model structure, that is, the basic region detection model is trained to obtain the target region detection model. Specifically, when the basic region detection model is trained using a target face detection data set, the basic region detection model may be trained using a regression loss function or a classification loss function, and a loss component including a regularization term or other customized components may also be used to further optimize the training effect and generalization ability of the model, and the embodiment of the present invention does not limit this.
[0059] S230, extracting key points from the target facial recognition area based on an improved target three-dimensional key point detection model, and generating a target facial key point set corresponding to the current video frame.
[0060] In an optional embodiment, after the facial annotation of each historical image data frame based on the preset area detection model is performed to generate a target face detection sample containing a facial bounding box, and each target face detection sample is combined and processed to generate a target face detection data set, it also includes: performing outward expansion cropping on each target face detection sample in the target face detection data set to obtain an initial key point annotation sample; performing key point extraction on each initial key point annotation sample based on a preset two-dimensional key point detection model to generate an initial key point sample containing two-dimensional facial key points; performing angle rotation on each initial key point sample based on a preset angle enhancement technology to generate a basic key point sample corresponding to each initial key point sample; converting the basic key point samples into target key point samples containing three-dimensional key point coordinates based on a preset three-dimensional conversion technology, and combining and processing each target key point sample to generate a target three-dimensional key point data set; training an improved basic three-dimensional key point detection model based on the target three-dimensional key point data set to obtain a trained target three-dimensional key point detection model.
[0061] Among them, the initial key point annotation sample may refer to the basic sample for key point extraction. The preset two-dimensional key point detection model may refer to a preset two-dimensional key point extraction model. Usually, the preset two-dimensional key point detection model may be a trained two-dimensional key point detection model with a certain accuracy, and the preset two-dimensional key point detection model may be directly used to extract key points from the initial key point annotation sample. The initial key point sample may refer to the two-dimensional facial key points extracted based on the preset two-dimensional key point detection model. Usually, the initial key point sample contains 68 key point coordinates, and one target face detection sample corresponds to one initial key point sample. It is worth noting that in order to ensure the accuracy of the sample data, after the key points of each initial key point annotation sample are extracted based on the preset two-dimensional key point detection model, the model output result can be corrected by manual correction, and the corrected result can be used as the initial key point sample.
[0062] The preset angle enhancement technology may refer to a preset face angle enhancement technology. The preset angle enhancement technology can be used to randomly rotate the front and side face angles according to the annotated initial key point samples, thereby enhancing the diversity of data samples. The basic key point samples may refer to the two-dimensional key point samples generated after angle enhancement.
[0063] Among them, the preset three-dimensional conversion technology may refer to a preset three-dimensional key point conversion technology. The two-dimensional key point coordinates in the basic key point sample can be converted into three-dimensional key point coordinates by the preset three-dimensional conversion technology. Exemplarily, the preset three-dimensional conversion technology may be a three-dimensional deformable face model (3DMM). The target key point sample may refer to a three-dimensional key point sample that matches the basic key point sample. The target three-dimensional key point data set may refer to a data set composed of each target key point sample.
[0064] Among them, the basic 3D key point detection model may refer to a model selected for subsequent 3D key point extraction. Exemplarily, it may be an improved PRNet model. It is worth noting that in the embodiment of the present invention, the basic 3D key point detection model and the target 3D key point detection model are the same 3D key point detection model in different states, and the two have the same model structure, that is, the basic 3D key point detection model is trained to obtain the target 3D key point detection model.
[0065] S240, performing matching processing on the target facial key point set based on the basic three-dimensional facial key point template to generate deviation coordinates corresponding to the target facial key point set.
[0066] The deviation coordinates may refer to the coordinate deviation values of the target facial key point set relative to the basic three-dimensional facial key point template.
[0067] In an optional embodiment, before the target facial key point set is calculated and evaluated based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target facial angle corresponding to the current video frame, it also includes: determining a target number of standard facial images in a standard facial database based on preset screening criteria; determining the standard facial key points corresponding to each standard facial image based on a preset three-dimensional conversion technology; and averaging the basic key point coordinates of the same set position in each standard facial key point to generate a basic three-dimensional facial key point template.
[0068] Among them, the preset screening criteria may refer to pre-set screening conditions. Exemplarily, the preset screening criteria may be face offset angle, age or face pixel size, etc. The standard face database may refer to an existing public database with good face data quality. The standard face image may refer to each face image contained in the standard face database. The target number may refer to a numerical value that limits the number of standard face images extracted. Exemplarily, if the standard face database contains 20 million face images, the target number may be 5 million. The standard face key points may refer to the three-dimensional face key point coordinates corresponding to each standard face image. The basic key point coordinates may refer to the key point coordinates selected for calculation among the standard face key points. Mean processing may refer to the operation of calculating the average value of the basic key point coordinates at the same set position.
[0069] Specifically, after determining the target number of standard facial images in the standard facial database based on the preset screening criteria, the preset three-dimensional conversion technology can be used to extract the standard facial key points in each standard facial image to obtain the three-dimensional key point coordinates corresponding to each standard facial image, and then the basic key point coordinates at the same position in each standard facial key point are averaged. Exemplarily, if 5 million standard facial images are determined from the standard facial database, that is, the number of standard facial key points is 5 million, if the standard facial key points contain 34 three-dimensional key point coordinates, then it is necessary to calculate the average value of the key point coordinates at position 0 of the 5 million standard facial key points, the average value of the key point coordinates at position 1, and so on, to complete the average value calculation of the coordinates of the 34 key points, and finally, mark the coordinate result after the average value calculation of the corresponding position as the coordinate of the corresponding position in the basic three-dimensional face key point template, that is, after the average value calculation of the key point coordinates at position 0 of the 5 million standard facial key points, the coordinate result can be used as the key point coordinates at position 0 in the basic three-dimensional face key point template. In this way, the construction of a basic three-dimensional facial key point template is achieved, providing an effective basis for angle calculation.
[0070] S250. Determine a basic face angle corresponding to the deviation coordinate based on a preset rotation matrix.
[0071] The preset rotation matrix may refer to a preset angle calculation function. For example, it may be a rotation matrix of an open source computer vision library (Open Source Computer Vision Library, OpenCV). The basic face angle may refer to a face offset angle preliminarily calculated based on a basic three-dimensional face key point template.
[0072] S260, determining the angle category corresponding to the target facial key point based on a preset large-angle judgment standard, and if the angle category is a preset angle category, using the basic face angle as the target face angle corresponding to the current video frame.
[0073] The angle category may refer to a classification for evaluating the angle deviation range of a face. Exemplarily, the angle category may be divided into a small angle category with a smaller angle deviation range and a large angle category with a larger angle deviation range. The preset angle category may refer to the small angle category.
[0074] In an optional embodiment, determining the angle category corresponding to the target facial key point based on a preset large-angle judgment standard includes: determining the eye distance and eye-lip distance corresponding to the current video frame based on the target facial key point set; determining the angle category corresponding to the target facial key point based on a first deviation relationship between the eye distance and a first set threshold, and a second deviation relationship between the eye-lip distance and a second set threshold.
[0075] The eye distance may refer to the distance between two eyes in the same facial area, that is, the distance between the centers of the two eyeballs. The first set threshold may refer to a pre-set value for evaluating the eye distance. Usually, it can be set according to the actual angle of the camera in the target area. The first deviation relationship may refer to the size relationship between the eye distance and the first set threshold.
[0076] The eye-lip distance may refer to the distance between the centers of the two eyes and the centers of the two corners of the mouth in the same facial region. The second set threshold may refer to a pre-set value for evaluating the eye-lip distance. Usually, it can be set according to the actual angle of the camera in the target area. The second deviation relationship may refer to the size relationship between the eye-lip distance and the second set threshold.
[0077] Specifically, the coordinate positions of the two eyes and the two corners of the mouth corresponding to the current facial area can be determined based on the target facial key point set, and then the eye distance and eye-lip distance are calculated. Further, the eye distance is compared with the first set threshold, and the eye-lip distance is compared with the second set threshold. If the eye distance is greater than the first set threshold, and the eye-lip distance is greater than the second set threshold, then the target facial key point is determined to be a small angle category, otherwise, it is a large angle category. Therefore, the first deviation relationship between the eye distance and the first set threshold can be used to determine whether the angle category is a large-angle side face, and the second deviation relationship between the eye-lip distance and the second set threshold can be used to determine whether the angle category is a large-angle lowering or raising the head, providing an effective basis for the subsequent secondary screening of basic facial angles according to angle categories.
[0078] It is worth noting that in an embodiment of the present invention, after determining the angle category corresponding to the target facial key point based on the preset large-angle judgment standard, if the angle category is a small-angle category, the basic face angle is used as the target face angle corresponding to the current video frame, and the timing information corresponding to the current video frame can be obtained, and the timing information corresponding to the current video frame and the target face angle are combined and then stored in the background memory for subsequent use.
[0079] The technical solution of the embodiment of the present invention is to identify and process the current video frame corresponding to the target area through the target area detection model, generate a basic facial recognition area containing facial detection information, and perform outward expansion and cropping on the basic facial recognition area based on the facial detection information to generate the target facial recognition area corresponding to the current video frame, and then extract the key points of the target facial recognition area based on the improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame, further, match the target facial key point set based on the basic three-dimensional face key point template to generate deviation coordinates corresponding to the target facial key point set, and determine the basic face angle corresponding to the deviation coordinates based on a preset rotation matrix, and finally, determine the angle category corresponding to the target facial key point based on a preset large angle judgment standard, if the angle category is a preset angle category, use the basic face angle as the target face angle corresponding to the current video frame, solve the problem of low calculation accuracy of the face angle, and avoid the problem of errors in the face angle calculation result caused by inaccurate detection of some key points in the case of large angles through three-dimensional face key points and large angle judgment, so that the face angle can be accurately calculated, and the calculation accuracy of the face angle is improved.
[0080] Embodiment 3
[0081] Figure 4 FIG. 1 is a schematic diagram of a device for determining a face angle based on computer vision provided in Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a data acquisition module 310, a region identification module 320, a key point extraction module 330 and an angle calculation module 340;
[0082] The data acquisition module 310 is used to acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame;
[0083] A region recognition module 320 is used to recognize and process the current video frame based on a target region detection model, generate a basic face recognition region including face detection information, and perform outward expansion and cropping of the basic face recognition region based on the face detection information to generate a target face recognition region corresponding to the current video frame; wherein the face detection information includes coordinate position information corresponding to the basic face recognition region;
[0084] A key point extraction module 330 is used to extract key points from the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame;
[0085] The angle calculation module 340 is used to calculate and evaluate the target facial key point set based on the basic three-dimensional facial key point template and the preset large angle judgment standard to determine the target face angle corresponding to the current video frame.
[0086] The technical solution of the embodiment of the present invention is to identify and process the current video frame corresponding to the target area through a target area detection model, generate a basic facial recognition area containing facial detection information, and perform outward expansion and cropping on the basic facial recognition area based on the facial detection information to generate a target facial recognition area corresponding to the current video frame, and then perform key point extraction on the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame, and finally, perform calculation and evaluation on the target facial key point set based on a basic three-dimensional face key point template and a preset large-angle judgment standard to determine the target face angle corresponding to the current video frame, thereby solving the problem of low calculation accuracy of the face angle. The three-dimensional face key points and large-angle judgment can avoid the problem of errors in the face angle calculation results caused by inaccurate detection of some key points in large angle situations, and can accurately calculate the face angle, thereby improving the calculation accuracy of the face angle.
[0087] Optionally, the angle calculation module 340 may specifically include: a coordinate matching unit, a first angle calculation unit and a second angle calculation unit;
[0088] The coordinate matching unit is used to match the target facial key point set based on the basic three-dimensional facial key point template to generate deviation coordinates corresponding to the target facial key point set;
[0089] A first angle calculation unit, used to determine a basic face angle corresponding to the deviation coordinate based on a preset rotation matrix;
[0090] The second angle calculation unit is used to determine the angle category corresponding to the target facial key point based on a preset large angle judgment standard. If the angle category is a preset angle category, the basic face angle is used as the target face angle corresponding to the current video frame.
[0091] Optionally, the second angle calculation unit may be specifically used for:
[0092] Determine the eye distance and eye-lip distance corresponding to the current video frame based on the target facial key point set;
[0093] Based on a first deviation relationship between the eye distance and a first set threshold, and a second deviation relationship between the eye-lip distance and a second set threshold, the angle category corresponding to the target facial key point is determined.
[0094] Optionally, the face angle determination device based on computer vision may also include: a first model training module, used to obtain historical video data, and perform data collection on the historical video data to generate a historical image data set corresponding to the historical video data; wherein the historical image data set includes each historical image data frame; based on a preset area detection model, each historical image data frame is facially annotated to generate a target face detection sample including a facial bounding box, and each target face detection sample is combined and processed to generate a target face detection data set; based on the target face detection data set, a basic area detection model is trained to obtain a trained target area detection model.
[0095] Optionally, the face angle determination device based on computer vision may also include: a second model training module, which is used to perform facial annotation on each historical image data frame based on the preset area detection model to generate a target face detection sample containing a facial bounding box, and combine and process each target face detection sample to generate a target face detection data set, and then perform outward expansion and cropping on each target face detection sample in the target face detection data set to obtain an initial key point annotation sample; perform key point extraction on each initial key point annotation sample based on a preset two-dimensional key point detection model to generate an initial key point sample containing two-dimensional facial key points; perform angle rotation on each initial key point sample based on a preset angle enhancement technology to generate a basic key point sample corresponding to each initial key point sample; convert the basic key point samples into target key point samples containing three-dimensional key point coordinates based on a preset three-dimensional conversion technology, and combine and process each target key point sample to generate a target three-dimensional key point data set; train an improved basic three-dimensional key point detection model based on the target three-dimensional key point data set to obtain a trained target three-dimensional key point detection model.
[0096] Optionally, the face angle determination device based on computer vision may also include: a template generation module, which is used to determine a target number of standard facial images in a standard facial database based on preset screening criteria before calculating and evaluating the target facial key point set based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target face angle corresponding to the current video frame; determine the standard facial key points corresponding to each standard facial image based on a preset three-dimensional conversion technology; and average process the basic key point coordinates of the same set position in each standard facial key point to generate a basic three-dimensional facial key point template.
[0097] Optionally, the feature extraction part in the improved target 3D key point detection model is a visual geometry group convolutional neural network re-emphasis backbone model.
[0098] The computer vision-based face angle determination device provided in the embodiment of the present invention can execute the computer vision-based face angle determination method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0099] Embodiment 4
[0100] Figure 5 A schematic diagram of an electronic device 410 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0101] like Figure 5 As shown, the electronic device 410 includes at least one processor 420, and a memory connected to the at least one processor 420 in communication, such as a read-only memory (ROM) 430, a random access memory (RAM) 440, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 420 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 430 or the computer program loaded from the storage unit 490 to the random access memory (RAM) 440. In the RAM 440, various programs and data required for the operation of the electronic device 410 can also be stored. The processor 420, the ROM 430, and the RAM 440 are connected to each other via a bus 450. An input / output (I / O) interface 460 is also connected to the bus 450.
[0102] Multiple components in the electronic device 410 are connected to the I / O interface 460, including: an input unit 470, such as a keyboard, a mouse, etc.; an output unit 480, such as various types of displays, speakers, etc.; a storage unit 490, such as a disk, an optical disk, etc.; and a communication unit 4100, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 4100 allows the electronic device 410 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0103] The processor 420 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 420 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 420 performs the various methods and processes described above, such as a method for determining a face angle based on computer vision.
[0104] The method includes:
[0105] Acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame;
[0106] Based on the target region detection model, the current video frame is processed to generate a basic facial recognition region including facial detection information, and the basic facial recognition region is expanded and cropped based on the facial detection information to generate a target facial recognition region corresponding to the current video frame; wherein the facial detection information includes coordinate position information corresponding to the basic facial recognition region;
[0107] Extract key points from the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame;
[0108] The target facial key point set is calculated and evaluated based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target face angle corresponding to the current video frame.
[0109] In some embodiments, the face angle determination method based on computer vision may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 490. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 410 via the ROM 430 and / or the communication unit 4100. When the computer program is loaded into the RAM 440 and executed by the processor 420, one or more steps of the face angle determination method based on computer vision described above may be performed. Alternatively, in other embodiments, the processor 420 may be configured to perform the face angle determination method based on computer vision in any other appropriate manner (e.g., by means of firmware).
[0110] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0111] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0112] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0113] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0114] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0115] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0116] The present application also discloses a computer program product, which includes a computer program. When the computer program is executed by a processor, the computer program implements the computer vision-based face angle determination method provided in any embodiment of the present application. The program product and the computer vision-based face angle determination method disclosed in each embodiment of the present application belong to the same inventive concept, so it will not be described here.
[0117] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0118] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for determining face angle based on computer vision, characterized in that: include: Acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame; Based on the target region detection model, the current video frame is processed to generate a basic facial recognition region including facial detection information, and the basic facial recognition region is expanded and cropped based on the facial detection information to generate a target facial recognition region corresponding to the current video frame; wherein the facial detection information includes coordinate position information corresponding to the basic facial recognition region; Extract key points from the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame; The target facial key point set is calculated and evaluated based on the basic three-dimensional facial key point template and the preset large-angle judgment standard to determine the target face angle corresponding to the current video frame.
2. The method according to claim 1, characterized in that The step of calculating and evaluating the target facial key point set based on the basic three-dimensional facial key point template and the preset large angle judgment standard to determine the target facial angle corresponding to the current video frame includes: Performing matching processing on the target facial key point set based on the basic three-dimensional facial key point template to generate deviation coordinates corresponding to the target facial key point set; Determine the basic face angle corresponding to the deviation coordinate based on a preset rotation matrix; The angle category corresponding to the target facial key point is determined based on a preset large-angle judgment standard. If the angle category is a preset angle category, the basic face angle is used as the target face angle corresponding to the current video frame.
3. The method according to claim 2, characterized in that The determining the angle category corresponding to the target facial key point based on a preset large angle judgment standard includes: Determine the eye distance and eye-lip distance corresponding to the current video frame based on the target facial key point set; Based on a first deviation relationship between the eye distance and a first set threshold, and a second deviation relationship between the eye-lip distance and a second set threshold, the angle category corresponding to the target facial key point is determined.
4. The method according to claim 1, characterized in that: The method further comprises: Acquire historical video data, and perform data collection on the historical video data to generate a historical image data set corresponding to the historical video data; wherein the historical image data set includes each historical image data frame; Based on the preset region detection model, each historical image data frame is face-labeled to generate a target face detection sample containing a face bounding box, and each target face detection sample is combined and processed to generate a target face detection data set; The basic region detection model is trained based on the target face detection data set to obtain a trained target region detection model.
5. The method according to claim 4, characterized in that After performing facial annotation on each historical image data frame based on the preset region detection model to generate a target face detection sample including a face bounding box, and combining and processing each target face detection sample to generate a target face detection data set, the method further includes: Perform outward expansion and cropping on each target face detection sample in the target face detection data set to obtain the initial key point annotation samples; Based on a preset two-dimensional key point detection model, key points are extracted from each initial key point annotation sample to generate an initial key point sample containing two-dimensional facial key points; Based on the preset angle enhancement technology, each initial key point sample is rotated to generate a basic key point sample corresponding to each initial key point sample; The basic key point samples are converted into target key point samples containing three-dimensional key point coordinates based on a preset three-dimensional conversion technology, and the target key point samples are combined and processed to generate a target three-dimensional key point data set; The improved basic 3D key point detection model is trained based on the target 3D key point data set to obtain a trained target 3D key point detection model.
6. The method according to claim 1, characterized in that Before calculating and evaluating the target facial key point set based on the basic 3D facial key point template and the preset large angle judgment standard to determine the target facial angle corresponding to the current video frame, the method further includes: Determine a target number of standard facial images in a standard facial database based on a preset screening criterion; Determine the standard facial key points corresponding to each standard facial image based on a preset three-dimensional conversion technology; The coordinates of the basic key points at the same set position in each standard facial key point are processed by averaging to generate a basic three-dimensional facial key point template.
7. The method according to claim 1, characterized in that The feature extraction part in the improved target three-dimensional key point detection model is a visual geometry group convolutional neural network heavy highlight backbone model.
8. A device for determining face angle based on computer vision, characterized in that: include: A data acquisition module, used to acquire current video data corresponding to the target area; wherein the current video data includes at least one current video frame; A region recognition module, used to recognize and process the current video frame based on a target region detection model, generate a basic face recognition region containing face detection information, and perform outward expansion and cropping of the basic face recognition region based on the face detection information to generate a target face recognition region corresponding to the current video frame; wherein the face detection information includes coordinate position information corresponding to the basic face recognition region; A key point extraction module is used to extract key points from the target facial recognition area based on an improved target three-dimensional key point detection model to generate a target facial key point set corresponding to the current video frame; The angle calculation module is used to calculate and evaluate the target facial key point set based on the basic three-dimensional facial key point template and the preset large angle judgment standard to determine the target face angle corresponding to the current video frame.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the computer vision-based face angle determination method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the computer vision-based face angle determination method according to any one of claims 1 to 7 when executed.
