The present disclosure relates to the field of Internet technologies, especially to a method and device for locating human facial feature points and a storage medium.
The locating of key feature points on a human face is not only an essential issue in a human face recognition research, but also a fundamental issue in the fields of graphics and computer vision. The locating of human facial feature points is such a technology that human face detection is conducted on a video stream by adopting technologies such as a digital image processing technology and a pattern recognition technology and key feature points on the human face are accurately located and tracked, for the purpose of determining and researching shape information of major organs such as mouth through the located key feature points on the human face.
The above locating is implemented by human face detecting technologies in an existing technical scheme, but a preliminary facial location located according to a result of human face detecting is not accurate enough in the prior art, resulting in that the locating of key feature points on the human face is not accurate enough, and hence the fitting of the key feature points on the human face is likely failed. In addition, an Active Shape Model (ASM) algorithm is adopted as a facial feature point fitting algorithm in the prior art, but the accuracy of the ASM algorithm is not high enough because only shape information is considered in the ASM algorithm.
The disclosure provides a method and device for locating human facial feature points and a storage medium, which are intended to solve problems of a failure in fitting key feature points on a human face and a low accuracy of the fitting which are caused in that locating of the key feature points on the human face is not accurate enough in the prior art.
The disclosure is realized as follows.
A method for locating human facial feature points, including:
preliminarily locating a human face location by a face detecting technology in combination with an eye matching technology, and obtaining preliminary location information;
fitting human facial feature points according to the preliminary location information; and
accomplishing locating of the human facial feature points according to a result of the fitting.
A technical scheme of another embodiment of the disclosure includes a device for locating human facial feature points, and the device includes a face detecting module, a feature point fitting module and a feature point locating module; where the face detecting module is configured to preliminarily locating for a location of a human face through a face detecting technology and an eye matching technology; the feature point fitting module is configured to fit human facial feature points according to the preliminary location information; and the feature point locating module is configured to accomplish the locating of the human facial feature points according to a result of the fitting.
In addition, the disclosure further provides a storage medium including computer-executable instructions, and the computer-executable instructions are configured to execute a method for locating human facial feature points including:
preliminarily locating a human face location by a face detecting technology in combination with an eye matching technology, and obtaining preliminary location information;
fitting human facial feature points according to the preliminary location information; and
accomplishing locating of the human facial feature points according to a result of the fitting.
Technical schemes of the disclosure possess following advantages or beneficial effects. The method and device for locating human facial feature points and the storage medium according to the embodiments of the disclosure implement preliminary locating of a face location by the face detecting technology in combination with the eye matching technology, therefore the facial location information of the human face can be located more accurately compared with the case of using the face detecting technology only. And the human facial feature points are fitted by using an Inverse Compositional algorithm according to the preliminary location information in conjunction with grayscale features, gradient features, and edge and angular point features, so as to complete the accurate locating of the human facial feature points. Appearance models such as gradient values in directions of X axis and Y axis as well as edge and angular point features are added in the AAM, thus making the fitting of the human facial feature points more accurate and effectively alleviating a problem of an existing AAM that local minimization and poor anti-interference ability likely occurs in the process of fitting.
To make the purpose, the technical scheme and the advantage of the disclosure more clear, the disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments described here are only used for interpreting the disclosure instead of limiting the disclosure.
Referring to
Step S100: preliminarily locating a human face location through a face detecting technology in connection with an eye matching technology.
In Step S100, cascaded Harr feature classifiers are adopted in the present embodiment of the disclosure to detect a human face, so as to obtain preliminary location information and preliminary facial size information of the human face; further, an eye matching algorithm is used to match location information of both eyes, thus locating the human face location more accurately compared with the case where merely a face detecting method is used.
Step S110: fitting human facial feature points according to the preliminary location information and at least one feature of the AAM.
In Step S110, features of the AAM include features such as grayscale, gradient, edge and angular point; in the present embodiment of the disclosure, a combination of the AAM algorithm and multiple features such as grayscale values, gradient values in the directions of X axis and Y axis, edges and angular points is regarded as an appearance model of the AAM, thus the fitted locations of the human facial feature points are more accurate; in the present embodiment of the disclosure, the Inverse Compositional algorithm is adopted for the fitting of the human facial feature points.
Step S120: accomplishing the locating of the human facial feature points according to a result of the fitting.
In Step S120, an image of both eyes can be obtained according to locations of human facial feature points after the human facial feature points are located; in an image of a next frame, an eye searching ROI (a term in picture processing) in the image of the next frame is determined, and locations of both eyes in the current frame are obtained within the eye searching ROI by an image matching algorithm, with an image of both eyes in an image of a previous frame being used as a template. The eye searching ROI may be determined in such a way that: a center of the eye searching ROI overlaps with a center of an eye, and if eye_height and eye_width respectively represent a height and a width of an eye, and roi_height and roi_width respectively represent a height and a width of the eye searching ROI, then
roi_height=αeye_height;
roi_width=βeye_width;
where α and β represent ROI size control factors, and in this technical scheme, α=3, and β=2.
In the method for locating human facial feature points of the present embodiment of the disclosure, the face location is preliminarily located by the face detecting technology in combination with the eye matching technology, so that the facial location information can be located more accurately compared with the case of using the face detecting technology only.
Referring to
Step S200: inputting a video, and obtaining corresponding facial image information in the video.
Step S210: determining whether an eye is detected in an image of a previous frame, and if an eye is detected in an image of a previous frame, executing Step S220; otherwise, executing Step S240.
In Step S210, an eye matching algorithm is adopted for eye matching at the time of face detecting in the present embodiment of the disclosure, thus locating the facial location more accurately compared with the case of using the face detecting method only.
Step S220: searching in the eye searching ROI (a term in picture processing), to match the preliminary location information of the eye.
In Step S220, the eye searching ROI is determined in such a way that: a center of the eye searching ROI overlaps with a center of an eye, and if eye_height and eye_width respectively represent a height and a width of an eye, and roi_height and roi_width respectively represent a height and a width of the eye searching ROI, specifically referring to
roi_height=α·eye_height
roi_width=β·eye_width;
where α and β represent ROI size control factors, and in the present embodiment of the disclosure, α=3, and β=2; and the eye matching algorithm specifically includes that: if T(x, y) represents an image of an eye, I(x,y) represents an eye searching ROI, and R(x,y) represents a matching resultant image, then
The matching resultant image R(x, y) is located at a best-matching location in the searching ROI I(x, y) and the eye image T(x,y) when the matching resultant image R(x,y) reaches its maximum value.
Step S230: facial feature points are fitted by the AAM according to the preliminary location information of the eye, and executing Step S260.
Step S240: detecting a human face and determining whether the human face is detected, and if the human face is detected, executing Step S250; otherwise, executing Step S200 again.
In Step S240, cascaded Harr feature classifiers are adopted to detect the human face in the present embodiment of the disclosure, so as to obtain the preliminary location information and preliminary facial size information of the human face.
Step S250: obtaining the preliminary location information (x, y) and the preliminary facial size information s of the human face, and fitting the facial feature points by the AAM according to the preliminary location information and the preliminary facial size information of the human face in conjunction with features such as grayscale values, gradient values in directions of X axis and Y axis of the preliminary location of the human face, edges and angular points.
In Step S250, after the preliminary location information and the preliminary facial size information of the human face are obtained, features such as grayscale values, gradient values in directions of X axis and Y axis of the preliminary location of the human face, edges and angular points are combined as an appearance model of the AAM to fit the human facial feature points, thus making the fitted locations of the human facial feature points more accurate. The appearance model is a parameterized model, which is used for unified modeling of a shape and textures of a variable object through principal component analysis, and matching of an unknown object by using a two norm-minimizing strategy. The ASM of the human facial feature points may be represented by a vector S={x1, y1 . . . xn, yn}, where xi, yi represent a location coordinate of the i-th human facial feature point. In the present embodiment of the disclosure, 82 facial label points are adopted, specifically referring to
where S0 represents an average shape, Si represents a PCA base of a shape, and pi represents a factor of the PCA base. A vector S of the corresponding ASM can be obtained as long as the respective factors pi are calculated in the process of fitting, specifically referring to
Step S251: excising a mean for coordinate vectors of all facial feature points, and transferring the coordinate vectors to a centroidal coordinate system;
Step S252: selecting a sample as an initial average shape, and calibrating a dimension of the initial average shape so that |
Step S253: denoting the estimated initial average shape as
Step S254: calibrating coordinate vectors of feature points of all training samples onto the current average shape through affine transformation;
Step S255: recalculating an average shape for all calibrated samples;
Step S256: calibrating the current average shape onto
Step S257: determining whether the calibrated average shape is greater than a given threshold value, and if the calibrated average shape is greater than a given threshold value, executing Step S254 again; otherwise, executing Step S258;
Step S258: conducting statistical shape modeling for aligned samples through a PCA approach, to obtain
An AAM A is obtained by mapping points from a region surrounded by an ASM onto the average shape, where a piecewise affine mapping algorithm may be adopted for the mapping here; similarly, the PCA based learning may be conducted for the AAM, to obtain
where A0 represents an average appearance, Ai represents a PCA base of the AAM, and λi represents a factor of the PCA base.
A modeling approach of the AAM specifically includes: mapping each training sample into the average shape, and then respectively calculating three kinds of features including grayscale values, gradient values in directions of X axis and Y axis, and feature values of edges and angular points so as to form the AAM; where a grayscale value Agray may be calculated in such a way that: if I(x,y) denotes a grayscale image of each sample mapped into the average shape, then a value of a grayscale appearance model is:
A
gray(x,y)=I(x,y)
The gradient values in directions of X axis and Y axis may be calculated in such a way of: calculating gradient values in directions of X axis and Y axis by using a Sobel operator (which is one of operators in image processing, and is mainly used for edge detecting):
Hence, values Adx and Ady of appearance models of gradient values in directions of X axis and Y axis can be obtained with following formulas:
A
dx(x,y)=Gx(x,y)2;
A
dy(x,y)=Gy(x,y)2.
The edge and angular point features Aedge
Edgexy(x,y)=Gx(x,y)·Gx(x,y);
Edgeyy(x,y)=Gy(x,y)·Gy(x,y);
Edgexy(x,y)=Gx(x,y)·Gy(x,y);
then Edgexx(x, y), Edgeyy(x, y), Edgexy(x, y) are respectively filtered by using a 3×3 Gaussian window to obtain:
and the edge and angular point features are calculated by the following formula:
A
edge
and
corner(x,y)=(Edgexx′(x,y)+Edgeyy′(x,y))2·(Edgexx′(x,y)·Edgeyy′(x,y)−Edgexy′(x,y)·Edgexy′(x,y))
The features such as grayscale values, gradient values in directions of X axis and Y axis, and edges and angular points are not represented in the same scale, and therefore need to be normalized to the same scale after calculation. A Sigmoidal approach is selected for such normalization of feature values in the present embodiment of the disclosure specifically as follows:
A
gray′(x,y)=Agray(x,y)/(Agray(x,y)+
A
dx′(x,y)=Adx(x,y)/(Adx(x,y)+
A
dy′(x,y)=Ady(x,y)/(Ady(x,y)+
A
edge
and
corner′(x,y)=Aedge
After the normalization, these three kinds of features including grayscale values, gradient values in directions of X axis and Y axis, and edges and angular points are all in the same scale, and each training sample corresponds to these three kinds of features and four feature values; after the AAM with four feature values is obtained, the PCA based learning results in:
In an embodiment of the disclosure, an Inverse Compositional algorithm (which is a commonly used algorithm in the art) is adopted to fit the human facial feature points and specifically includes: transforming an input image I(x,y) according to four initial global affine transformation parameters q obtained by a face detecting algorithm or an eye matching algorithm, obtaining I(N(W(x|p)|q)), where W is defined as piecewise affine mapping from a basic shape S0 to the current shape S, N represents two-dimension similarity transformation, and q represents a parameter of the similarity transformation, hence
where q=(a,b,tx, ty) and may be obtained by calculating with the eye matching algorithm. Those three kinds of feature appearance models are calculated for transformed images to obtain A(I(N(W(x|p))|q)); an appearance model difference value A((N(W(x|p))|q))−A0(x) is calculated; and then (∇q, ∇p)=H−1ΣSDT·(A(I(N(W(x|p))|q))−A0(x)) is calculated; where H represents a Hessian matrix (which is a square matrix formed of second-order partial derivatives of a real-valued function whose independent variable is a vector), SD represents the steepest descent graph which is calculated by the following formulas in advance when models are trained:
A shape parameter (N◯W)(x; q, p)←(N◯W)(x; q, p)◯(N◯W)(x; ∇q, ∇p)−1 is updated till ∥∇q,∇p∥<ε.
Step S260: determining whether the human facial feature points are fitted successfully, and if so, executing Step S270; otherwise, executing Step S200 again.
Step S270: accomplishing the locating of the human facial feature points according to a result of the fitting, obtaining an eye image according to the human facial feature points, and matching, in the eye searching ROI, locations of both eyes in an image of a next frame by taking an eye image in the image of the previous frame as a template.
In Step S270, an image of both eyes is obtained according to the locations of the human facial feature points, an eye searching ROI in the image of the next frame is determined, and locations of both eyes in the current frame are re-matched in the determined eye searching ROI by using the image matching algorithm and taking an eye image in an image of a previous frame as a template.
In the method for locating human facial feature points according to the present embodiment of the disclosure, human facial feature points are fitted by using an Inverse Compositional algorithm according to the preliminary location information in conjunction with grayscale features, gradient features, and edge and angular point features, so as to complete accurate locating of the human facial feature points. Appearance models such as gradient values in directions of X axis and Y axis as well as edge and angular point features are added in the Active Appearance Model (AAM), thus making the fitting of the human facial feature points more accurate and effectively alleviating a problem of an existing AAM that local minimization and poor anti-interference ability likely occurs in the process of fitting.
Referring to
The face detecting module includes an eye detecting unit and a face detecting unit.
The eye detecting unit is configured to determine whether an eye is detected from an image of a previous frame, and if an eye is detected from the image of the previous frame, search in the eye searching ROI (which is a term in picture processing) to match location information of the eye; otherwise, the face detecting unit detects the human face; as such, an eye matching algorithm is adopted for eye matching in addition to the face detecting in the present embodiment of the disclosure, thus the human face location may be located more accurately compared with the case of using the face detecting method only. The eye searching ROI may be determined in such a way that: a center of the eye searching ROI overlaps with a center of an eye, and if eye_height and eye_width respectively represent a height and a width of an eye, an roi_height and roi_width respectively represent a height and a width of an eye searching ROI, specifically referring to
roi_height=αeye_height,
roi_width=βeye_width;
where α and β represent ROI size control factors, and in the present embodiment of the disclosure, α=3, and β=2; and the eye matching algorithm specifically includes that: if T(x,y) represents an eye image, I(x, y) represents a searching ROI, and R(x, y) represents a matching resultant image, hence
The matching resultant image R(x, y) is located at a best-matching location in the searching ROI I(x,y) and the eye image T(x,y) when the matching resultant image R (x, y) reaches its maximum value.
The face detecting unit is configured to detect a human face and determine whether the human face is detected, and if the human face is detected, obtain the preliminary location information (x, y) and the preliminary facial size information s of the human face; otherwise, a video is inputted again; here, cascaded Harr feature classifiers are adopted for detecting the human face in an embodiment of the disclosure, so as to obtain preliminary location information and preliminary facial size information of the human face.
The feature point fitting module includes an eye fitting unit, a face fitting unit and a fitting judgment unit.
The eye fitting unit is configured to fit the facial feature points by the AAM according to the preliminary location information of the eye, and whether the fitting is successful is determined by the fitting judgment unit.
The face fitting unit is configured to fit the facial feature points by the AAM according to the preliminary location information and the preliminary facial size information of the human face in conjunction with features such as grayscale values, gradient values in directions of X axis and Y axis of the preliminary location of the human face, and edges and angular points, and whether the fitting is successful is determined by the fitting judgment unit. As such, after the preliminary location information and the preliminary facial size information of the human face are obtained, features such as grayscale values, gradient values in directions of X axis and Y axis of the preliminary location of the human face, and edges and angular points are combined as an appearance model of the AAM, so as to implement the fitting of the human facial feature points, thus making the location obtained from the fitting of the human facial feature points more accurate. The ASM of the human facial feature points may be represented by a vector S={x1, y1 . . . xn, yn}, the xi, yi represent a location coordinate of the i-th human facial feature point. In the present embodiment of the disclosure, 82 facial label points are adopted, specifically referring to
where S0 represents an average shape, Si represents a PCA base of a shape, and pi represents a factor of the PCA base. A vector S of a corresponding AAM can be obtained as long as the respective factors pi are calculated in the process of fitting. The modeling approach of the shape model of the human facial feature points in the disclosure specifically includes: excising a mean for coordinate vectors of all facial feature points, and transferring the coordinate vectors to a centroidal coordinate system; selecting a sample as an initial average shape, and calibrating a dimension of the initial average shape so that |
An AAM A is obtained by mapping points from a region surrounded by an ASM onto the average shape, where a piecewise affine mapping algorithm may be adopted for the mapping here; similarly, the PCA based learning may be conducted for the AA M, to obtain
where A0 represents an average appearance, Ai represents a PCA base of the AAM, and λi represents a factor of the PCA base.
A modeling approach of the AAM specifically includes: mapping each training sample into the average shape, and then respectively calculating three kinds of features including grayscale values, gradient values in directions of X axis and Y axis, and feature values of edges and angular points so as to form the AAM; where a grayscale value Agray may be calculated in such a way that: if I(x,y) denotes a grayscale image of each sample mapped into the average shape, then a value of a grayscale appearance model is:
A
gray(x,y)=I(x,y)
The gradient values in directions of X axis and Y axis may be calculated in such a way of: calculating gradient values in directions of X axis and Y axis by using a Sobel operator (which is one of operators in image processing, and is mainly used for edge detecting):
Hence, values Adx and Ady of appearance models of gradient values in directions of X axis and Y axis can be obtained with following formulas:
A
dx(x,y)=Gx(x,y)2;
A
dy(x,y)=Gy(x,y)2.
The edge and angular point features Aedge
Edgexx(x,y)=Gx(x,y)·Gx(x,y);
Edgeyy(x,y)=Gy(x,y)·Gy(x,y);
Edgexy(x,y)=Gx(x,y)·Gy(x,y);
then Edgexx(x, y), Edgeyy(x, y), Edgexy(x, y) are respectively filtered by using a 3×3 Gaussian window to obtain:
and the edge and angular point features are calculated by the following formula:
A
edge
and
corner(x,y)=(Edgexx′(x,y)+Edgeyy′(x,y))2−2·(Edgexy′(x,y)·Edgeyy(x,y)−Edgexy′(x,y)·Edgexy′(x,y)).
The features such as grayscale values, gradient values in directions of X axis and Y axis, and edges and angular points are not represented in the same scale, and therefore need to be normalized to the same scale after calculation. A Sigmoidal approach is selected for such normalization of feature values in the present embodiment of the disclosure specifically as follows:
A
gray′(x,y)=Agray(x,y)/(Agray(x,y)+
A
dx′(x,y)=Adx(x,y)/(Adx(x,y)+
A
dy′(x,y)=Ady(x,y)/(Agray(x,y)+
A
edge
and
corner′(x,y)=Aedge
After the normalization, these three kinds of features including grayscale values, gradient values in directions of X axis and Y axis, and edges and angular points are all in the same scale, and each training sample corresponds to these three kinds of features and four feature values; after the AAM with four feature values is obtained, the PCA based learning results in:
In an embodiment of the disclosure, an Inverse Compositional algorithm (which is a commonly used algorithm in the art) is adopted to fit the human facial feature points and specifically includes: transforming an input image I(x,y) according to four initial global affine transformation parameters q obtained by a face detecting algorithm or an eye matching algorithm, obtaining I(N(W(x|p)|q)), where W is defined as piecewise affine mapping from a basic shape S0 to the current shape S, N represents two-dimension similarity transformation, and q represents a parameter of the similarity transformation, hence
where q=(a,b,tx, ty) and may be obtained by calculating with the eye matching algorithm. Those three kinds of feature appearance models are calculated for transformed images to obtain A(I(N(W(x|p))|q)); an appearance model difference value A(I(N(W(x|p))|q))−A0(x) is calculated; and then (∇q,∇p)=H−1ΣSDT·(A(I(N(W(x|p))|q))−A0(x)) is calculated; where H represents a Hessian matrix (which is a square matrix formed of second-order partial derivatives of a real-valued function whose independent variable is a vector), SD represents the steepest descent graph which is calculated by the following formulas in advance when models are trained:
A shape parameter (N◯W)(x; q, p)←(N◯W)(x; q, p)◯(N◯W)(x; ∇q, ∇p)−1 is updated till ∥(∇q,∇p)∥<ε.
The fitting judgment unit is configured to determine whether the human facial feature points are fitted successfully, and if so, the human facial feature points are located by the feature point locating module; otherwise, a video is inputted again.
The feature point locating module is configured to accomplish the locating of the human facial feature points according to a result of the fitting, obtain an eye image according to the human facial feature points, and match, in the eye searching ROI, locations of both eyes in an image of a next frame by the eye detecting unit by taking an eye image in the image of the previous frame as a template. An image of both eyes can be obtained according to the locations of the human facial feature points, an eye searching ROI in the image of the next frame is determined, and locations of both eyes in the current frame are obtained in the determined eye searching ROI by using image matching algorithm and taking an eye image in an image of a previous frame as a template.
Those of ordinary skills in the art would understand that all or part of steps for achieving the above embodiments may be accomplished through hardware, or through a program instructing corresponding hardware. The program may be stored in a computer-readable storage medium and is executable by at least one computer processor, so as to implement methods and flows shown in
The method and device for locating human facial feature points and the storage medium according to the embodiments of the disclosure implement preliminary locating of a face location by the face detecting technology in combination with the eye matching technology, therefore the facial location information of the human face can be located more accurately compared with the case of using the face detecting technology only. And the human facial feature points are fitted by using an Inverse Compositional algorithm according to the preliminary location information in conjunction with grayscale features, gradient features, and edge and angular point features, so as to complete the accurate locating of the human facial feature points. Appearance models such as gradient values in directions of X axis and Y axis as well as edge and angular point features are added in the AAM, thus making the fitting of the human facial feature points more accurate and effectively alleviating a problem of an existing AAM that local minimization and poor anti-interference ability likely occurs in the process of fitting.
The preferred embodiments of the disclosure have been described as above, but are not intended to limit the disclosure. Any modifications, equivalent replacement or improvements within the spirit and principles of the disclosure fall within the protection scope of the disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201210309313.6 | Aug 2012 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2013/080526 | 7/31/2013 | WO | 00 |