CN109711328B - Face recognition method and device and electronic equipment - Google Patents
Face recognition method and device and electronic equipment Download PDFInfo
- Publication number
- CN109711328B CN109711328B CN201811589438.2A CN201811589438A CN109711328B CN 109711328 B CN109711328 B CN 109711328B CN 201811589438 A CN201811589438 A CN 201811589438A CN 109711328 B CN109711328 B CN 109711328B
- Authority
- CN
- China
- Prior art keywords
- face image
- recognized
- pixel value
- value
- adjustment coefficient
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Image Processing (AREA)
- Collating Specific Patterns (AREA)
Abstract
The embodiment of the invention provides a face recognition method, a face recognition device and electronic equipment, wherein the method comprises the following steps: acquiring a face image to be recognized; determining the shooting time of a face image to be recognized; judging whether the shooting time belongs to a preset pixel value adjusting time range or not; when the shooting time belongs to a preset pixel value adjusting time range, determining a pixel value adjusting time period to which the shooting time belongs; determining a current pixel value adjustment coefficient corresponding to shooting time according to different preset pixel value adjustment coefficients corresponding to different preset pixel value adjustment time periods; performing pixel value adjustment on the face image to be recognized according to the current pixel value adjustment coefficient to obtain an adjusted face image to be recognized; and carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result. In the invention, the pixel value adjusting time range is divided into different pixel value adjusting time periods according to the illumination difference, so the accuracy of face recognition can be improved.
Description
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a face recognition method, a face recognition device, and an electronic device.
Background
In recent years, with the rapid development of face recognition technology, products based on face recognition technology have been widely used in various fields of daily life, such as security, e-commerce, company management, and the like.
At present, the main methods for face recognition are: acquiring a face image to be recognized; and carrying out similarity calculation on the face image to be recognized and each face image in a preset registration set to obtain a face recognition result. Specifically, feature extraction may be performed on a face image to be recognized, feature extraction may be performed on each face image in the registered set, a similarity between the face image to be recognized and each face image in the registered set is calculated according to the features, if the similarity between the face image to be recognized and a certain face image in the registered set is greater than a preset threshold, face recognition is determined to be successful, and user information of a registered user corresponding to the face image to be recognized is output.
When the method is applied to face recognition, if the face image to be recognized is obtained under different illumination conditions, that is, if the illumination intensity of the face image to be recognized is different, for example: the face recognition method is used for solving the problem that the face recognition accuracy is low because some features cannot be extracted when the features of the acquired image are extracted under the condition of dark light.
Disclosure of Invention
The embodiment of the invention aims to provide a face recognition method, a face recognition device and electronic equipment so as to improve the accuracy of face recognition. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a face recognition method, including:
acquiring a face image to be recognized;
acquiring the shooting time of the face image to be recognized;
judging whether the shooting time belongs to a preset pixel value adjusting time range or not;
when the shooting time belongs to a preset pixel value adjusting time range, determining a pixel value adjusting time period to which the shooting time belongs; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range;
determining a current pixel value adjustment coefficient corresponding to the shooting time according to different pixel value adjustment coefficients corresponding to preset different pixel value adjustment time periods;
adjusting the pixel value of the face image to be recognized according to the current pixel value adjustment coefficient to obtain an adjusted face image to be recognized;
and carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result.
Further, the step of obtaining the face image to be recognized includes: and acquiring the currently shot face image to be recognized.
Further, the pixel value adjustment coefficient includes: a contrast adjustment coefficient and/or a brightness adjustment coefficient;
the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods include: different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods;
the step of determining the current pixel value adjustment coefficient corresponding to the shooting time according to different pixel value adjustment coefficients corresponding to different preset pixel value adjustment time periods includes:
determining a current contrast adjustment coefficient and/or a current brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods;
further, the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods are obtained by adopting the following steps:
acquiring registered face images of a plurality of registered users contained in the registered set;
acquiring a plurality of test sets corresponding to each preset different pixel value adjusting time period; the test set corresponding to each different pixel value adjustment time period comprises: a plurality of test face images shot in the preset pixel value adjusting time period; the testing face image is a face image of a registered user;
calculating the mean value of the contrast of the registered set and/or the mean value of the brightness of the registered set of the plurality of registered face images;
calculating the contrast mean value and/or the brightness mean value of the test set of a plurality of test face images shot in the preset pixel value adjustment time period aiming at each test set corresponding to different pixel value adjustment time periods;
and determining a contrast adjustment coefficient and/or a brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast mean value, the test set contrast mean value, the registration set brightness mean value, the test set brightness mean value and the pixel condition required for correctly recognizing the face in the pixel value adjustment time period.
Further, the step of determining the contrast adjustment coefficient and/or the brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast average value, the test set contrast average value, the registration set brightness average value, the test set brightness average value, and the pixel condition required for correctly recognizing the face in the pixel value adjustment time period includes:
taking the ratio of the registration set contrast mean value to the test set contrast mean value as an initial contrast adjustment coefficient;
taking the ratio of the registered set brightness mean value to the test set brightness mean value as an initial brightness adjustment coefficient;
and adjusting the initial contrast adjustment coefficient and/or the initial brightness adjustment coefficient by adopting a mode search optimization method under the condition that the similarity between the face image of the test set and the face image of the registration set is the highest as a pixel, and determining a final contrast adjustment coefficient and/or a final brightness adjustment coefficient.
Further, the step of performing face recognition on the adjusted face image to be recognized to obtain a face recognition result includes:
carrying out similarity calculation on the adjusted face image to be recognized and the face images of all registered users in a preset registration set to obtain a plurality of first similarity values;
carrying out similarity calculation on the face image to be recognized before adjustment and the face images of all registered users in a preset registration set to obtain a plurality of second similarity values;
and taking the registered user corresponding to the highest similarity value in the plurality of first similarity values and the plurality of second similarity values as an identification result.
In a second aspect, an embodiment of the present invention provides a face recognition apparatus, including:
the image acquisition module is used for acquiring a face image to be recognized;
the shooting time acquisition module is used for acquiring the shooting time of the face image to be recognized;
the time range judging module is used for judging whether the shooting time belongs to a preset pixel value adjusting time range or not;
the time period determining module is used for determining a pixel value adjusting time period to which the shooting time belongs when the shooting time belongs to a preset pixel value adjusting time range; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range;
the adjustment coefficient determining module is used for adjusting different pixel value adjustment coefficients corresponding to time periods according to preset different pixel values and determining a current pixel value adjustment coefficient corresponding to the shooting time;
the pixel value adjusting module is used for adjusting the pixel value of the face image to be recognized according to the current pixel value adjusting coefficient to obtain an adjusted face image to be recognized;
and the result acquisition module is used for carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result.
Further, the image acquisition module is specifically configured to acquire a currently shot face image to be recognized; the shooting time obtaining module is specifically used for obtaining the current shooting time.
Further, the pixel value adjustment coefficient includes: a contrast adjustment coefficient and/or a brightness adjustment coefficient; the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods include: different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods;
the adjustment coefficient determining module is specifically configured to determine a current contrast adjustment coefficient and/or a brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods.
Further, the apparatus further comprises: a pixel value adjusting coefficient presetting module;
the pixel value adjustment coefficient presetting module comprises: the device comprises a first obtaining submodule, a second obtaining submodule, a first calculating submodule, a second calculating submodule and an adjusting coefficient determining submodule;
the first acquisition sub-module is used for acquiring registered face images of a plurality of registered users contained in the registered set;
the second obtaining submodule is used for obtaining a plurality of test sets corresponding to each preset different pixel value adjusting time period; the test set corresponding to each different pixel value adjustment time period comprises: a plurality of test face images shot in the preset pixel value adjusting time period; the testing face image is a face image of a registered user;
the first calculating submodule is used for calculating the mean value of the contrast of the registered set and/or the mean value of the brightness of the registered set of the plurality of registered face images;
the second calculating submodule is used for calculating the test set contrast mean value and/or the test set brightness mean value of a plurality of test face images shot in the preset pixel value adjusting time period aiming at each test set corresponding to different pixel value adjusting time periods;
and the adjustment coefficient determining submodule is used for determining a contrast adjustment coefficient and/or a brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast mean value, the test set contrast mean value, the registration set brightness mean value, the test set brightness mean value and the pixel condition required by correctly recognizing the face in the pixel value adjustment time period.
Further, the adjustment coefficient determining submodule is specifically configured to use a ratio of the registration set contrast mean to the test set contrast mean as an initial contrast adjustment coefficient; taking the ratio of the registered set brightness mean value to the test set brightness mean value as an initial brightness adjustment coefficient; and adjusting the initial contrast adjustment coefficient and/or the initial brightness adjustment coefficient by adopting a mode search optimization method under the condition that the similarity between the face image of the test set and the face image of the registration set is the highest as a pixel, and determining a final contrast adjustment coefficient and/or a final brightness adjustment coefficient.
Further, the pixel value adjustment coefficient presetting module further includes: a first face image transformation submodule;
the first facial image transformation submodule is used for converting a plurality of registered facial images in the registered set and test facial images in the test set into an RGB format; according to preset standard facial feature information, performing facial feature coordinate similarity transformation on a registered facial image and a tested facial image in RGB format respectively; respectively cutting the converted registered face image and the converted tested face image into a standard format registered face image and a standard format tested face image with preset sizes;
the first calculating submodule is specifically used for calculating the registered set contrast mean value and/or the registered set brightness mean value of the plurality of registered face images for the registered face images in the standard format;
the second calculating submodule is specifically configured to calculate a test set contrast average value and/or a test set brightness average value of a plurality of test face images captured in the preset pixel value adjustment time period for the standard format test face image for each test set corresponding to each different pixel value adjustment time period.
Further, the pixel value adjusting module includes: the RGB value obtaining sub-module, the third calculating sub-module and the pixel value adjusting sub-module;
the RGB value obtaining submodule is used for converting the face image to be recognized into an RGB format and obtaining the RGB value of each pixel point in the face image to be recognized;
the third computing sub-module is used for computing the RGB mean value of the pixel points in the face image to be recognized;
and the pixel value adjusting submodule is used for adjusting the pixel value of the face image to be recognized in the RGB format based on the RGB value and the RGB mean value of each pixel point in the face image to be recognized according to the current ratio adjusting coefficient and/or the current brightness adjusting coefficient to obtain the adjusted face image to be recognized.
Further, the pixel value adjusting submodule is specifically configured to:
if the current pixel value adjustment coefficient only contains the current contrast adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr
Gn=(Go-Mg)*αg+Mg
Bn=(Bo-Mb)*αb+Mb
if the current pixel value adjustment coefficient only contains the current brightness adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=Ro-Mr+Mr*βr
Gn=Go-Mg+Mg*βg
Bn=Bo-Mb+Mb*βb
if the current pixel value adjustment coefficient comprises a current contrast adjustment coefficient and a current brightness adjustment coefficient, obtaining an adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr*βr
Gn=(Go-Mg)*αg+Mg*βg
Bn=(Bo-Mb)*αb+Mb*βb
wherein R isnThe value of the R component of each pixel point in the adjusted face image to be recognized is obtained; roThe value of the R component of each pixel point in the face image to be recognized is obtained; gnThe value of the G component of each pixel point in the adjusted face image to be recognized is obtained; goThe value of the G component of each pixel point in the face image to be recognized is obtained; b isnThe value of the B component of each pixel point in the adjusted face image to be recognized is obtained; b isoThe value of the B component of each pixel point in the face image to be recognized is obtained; mrThe average value of R components of pixel points in the face image to be recognized is obtained; mgThe average value of G components of pixel points in the face image to be recognized is obtained; mbThe average value of B components of pixel points in the face image to be recognized is obtained; alpha is alpharA current contrast adjustment coefficient for the R component; alpha is alphagA current contrast adjustment coefficient for the G component; alpha is alphabAdjusting the coefficient for the current contrast of the B component; beta is arA current luminance adjustment coefficient for the R component; beta is agIs the G componentThe current brightness adjustment coefficient; beta is abAnd adjusting the coefficient for the current brightness of the B component.
Further, the pixel value adjusting module further includes: a second face image transformation submodule;
the second facial image transformation submodule is used for carrying out facial coordinate similarity transformation on the facial image to be recognized in the RGB format according to preset standard facial feature information; cutting the transformed face image to be recognized into a standard format face image to be recognized with a preset size;
the third computation submodule is specifically configured to compute an RGB mean value of a pixel point in a to-be-recognized face image in a standard format.
Further, the result obtaining module is specifically configured to perform similarity calculation on the adjusted face image to be recognized and face images of registered users in a preset registration set to obtain a plurality of first similarity values; carrying out similarity calculation on the face image to be recognized before adjustment and the face images of all registered users in a preset registration set to obtain a plurality of second similarity values; and taking the registered user corresponding to the highest similarity value in the plurality of first similarity values and the plurality of second similarity values as an identification result.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the steps of any human face recognition method when executing the program stored in the memory.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer is caused to execute any one of the above-mentioned face recognition methods.
In a fifth aspect, an embodiment of the present invention further provides a computer program product including instructions, which when run on a computer, causes the computer to execute any one of the above-mentioned face recognition methods.
The embodiment of the invention provides a face recognition method, a face recognition device and electronic equipment, wherein a face image to be recognized is obtained; acquiring shooting time of the face image to be recognized and judging whether the shooting time belongs to a preset pixel value adjusting time range; when the shooting time belongs to a preset pixel value adjusting time range, determining a pixel value adjusting time period to which the shooting time belongs; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range; determining a current pixel value adjusting coefficient corresponding to the shooting time according to different preset pixel value adjusting coefficients corresponding to different time periods; adjusting the pixel value of the face image to be recognized according to the current pixel value adjustment coefficient to obtain an adjusted face image to be recognized; and carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result. In the embodiment of the invention, the shooting time of the face image to be recognized is determined, the current pixel value adjustment coefficient corresponding to the shooting time is obtained, then the face image to be recognized is adjusted based on the current pixel value adjustment coefficient, and then the face image to be recognized after the adjustment is subjected to face recognition to obtain a face recognition result.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a schematic flow chart of a face recognition method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating obtaining pixel value adjustment coefficients corresponding to different time periods in the embodiment shown in FIG. 1;
fig. 3 is another schematic flow chart of a face recognition method according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating obtaining pixel value adjustment coefficients corresponding to different time periods in the embodiment shown in FIG. 2;
fig. 5 is a schematic structural diagram of a face recognition apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
In order to improve the accuracy of face recognition, embodiments of the present invention provide a face recognition method, a face recognition device and an electronic device, which are described in detail below.
Fig. 1 is a schematic flow chart of a face recognition method provided in an embodiment of the present invention, which specifically includes the following steps:
The face image to be recognized acquired in this step may be an image containing the facial features of a person, which is acquired at any time and under any illumination condition.
Further, the step of acquiring the face image to be recognized may include: and acquiring the currently shot face image to be recognized.
In this embodiment, the application scenario of the face recognition method may be a company access control system or an attendance system, and the face image to be recognized in this case is a face image captured by the system at the current moment.
And 102, acquiring the shooting time of the face image to be recognized.
And 103, judging whether the shooting time belongs to a preset pixel value adjusting time range.
In the embodiment of the present invention, the pixel value adjustment time range is a preset time range in which the pixel value adjustment is required, for example, in a day, since the illumination condition is better within the time range of 10:00 to 15:00, the pixel value adjustment time range may be set to be other than the above time range: and the image of the face to be recognized shot in the pixel value adjusting range is required to be subjected to subsequent pixel value adjustment in the ranges of 0:00-10:00 and 15:00-24: 00.
104, when the shooting time belongs to a preset pixel value adjusting time range, determining a pixel value adjusting time period to which the shooting time belongs; the pixel value adjustment time period is divided according to the illumination difference of different time periods in the pixel value adjustment time range.
According to the example in step 103, the pixel value adjustment time range 0:00-10:00 and 15:00-24:00 can be divided into 4 pixel value adjustment time periods: the first pixel value adjusting time period is 0:00-7: 00; the second pixel value adjustment time period is 7:00-10: 00; the third pixel value adjusting time period is 15:00-18: 00; the fourth pixel value adjustment period is 18:00-24: 00. And if the shooting time is 8:00, determining that the pixel value adjustment time period to which the shooting time belongs is 7:00-10:00 of the second pixel value adjustment time period.
And 105, determining a current pixel value adjustment coefficient corresponding to the shooting time according to different pixel value adjustment coefficients corresponding to preset different pixel value adjustment time periods.
In this step, the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods may be preset by a worker in the field according to experience, or may be obtained through calculation, for example, may be obtained through calculation according to the similarity between the face image in the registration set and the face image in the acquired test set.
Further, the pixel value adjustment coefficient may include a contrast adjustment coefficient and/or a brightness adjustment coefficient. Correspondingly, the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods include: different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods; the method comprises the following steps of determining a current pixel value adjustment coefficient corresponding to shooting time according to different pixel value adjustment coefficients corresponding to different preset pixel value adjustment time periods, wherein the steps comprise: and determining the current contrast adjustment coefficient and/or brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods.
And 106, adjusting the pixel value of the face image to be recognized according to the current pixel value adjustment coefficient to obtain the adjusted face image to be recognized.
When the pixel value adjustment coefficients in step 105 include contrast adjustment coefficients and/or brightness adjustment coefficients; in time, the method comprises the following steps: the pixel value adjustment of the face image to be recognized according to the current pixel value adjustment coefficient to obtain the adjusted face image to be recognized may include: and adjusting the pixel value of the face image to be recognized according to the current contrast adjustment coefficient, and/or adjusting the pixel value of the face image to be recognized according to the current brightness adjustment coefficient to obtain the adjusted face image to be recognized.
Further, before the pixel value of the face image to be recognized is adjusted, facial coordinate similarity transformation can be carried out on the face image to be recognized, so that the transformed face image to be recognized is obtained; cutting the transformed face image to be recognized to obtain a cut face image with a preset size to be recognized; then, according to the pixel value adjustment coefficient, carrying out pixel value adjustment on the cut human face image to be recognized to obtain an adjusted human face image to be recognized; or after the pixel value of the face image to be recognized is adjusted according to the pixel value adjustment coefficient, the face image to be recognized after the conversion adjustment is cut, so as to obtain the adjusted face image to be recognized with the preset size. Performing five-sense organ coordinate similarity transformation on the obtained initially adjusted face image to be recognized to obtain a transformed and adjusted face image to be recognized;
after the pixel value is adjusted, similarity transformation is carried out, the transformed image is cut into an image with a preset size, so that the feature vector of the image to be recognized is conveniently extracted by a subsequent convolutional neural network model, and the accuracy of the recognition result can be improved.
Before the pixel value is adjusted, similarity transformation is firstly carried out, and the transformed image is cut into an image with a preset size, so that the extraction of a characteristic vector is facilitated, meanwhile, the adjustment time can be saved during the subsequent pixel value adjustment, and the efficiency of face recognition is improved.
And 107, carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result.
Specifically, two ways can be adopted to obtain a face recognition result:
in a first way,
Carrying out similarity calculation on the adjusted face image to be recognized and the face images of all registered users in a preset registration set to obtain a plurality of similarity values; and taking the registered user with the highest similarity value with the adjusted face image to be recognized as a face recognition result.
The second way,
Carrying out similarity calculation on the adjusted face image to be recognized and the face images of all registered users in a preset registration set to obtain a plurality of first similarity values;
carrying out similarity calculation on the face image to be recognized before adjustment and the face images of all registered users in a preset registration set to obtain a plurality of second similarity values;
and taking the registered user corresponding to the highest similarity value in the plurality of first similarity values and the plurality of second similarity values as a face recognition result.
In the two modes, the first mode has a simple process and high recognition speed; in the second mode, the registered user corresponding to the highest similarity value is taken as the face recognition result from the plurality of first similarity values and the plurality of second similarity values, so that the accuracy of face recognition can be further improved compared with the first mode.
In the embodiment of the invention, no matter the mode I or the mode II, the similarity of the face is calculated based on the face feature vector.
Specifically, before similarity calculation is performed on the adjusted to-be-recognized face image and the face images of the registered users in the preset registration set, the adjusted to-be-recognized face image and the face images of the registered users in the preset registration set are respectively input into a convolutional neural network model obtained through pre-training, so that face feature vectors of the adjusted to-be-recognized face image and the face images of the registered users are obtained; and then, based on the face feature vector, carrying out similarity calculation on the adjusted face image to be recognized and the face image of each registered user in a preset registration set.
Similarly, before similarity calculation is performed on the face image to be recognized before adjustment and the face images of all registered users in a preset registration set, the face image to be recognized before adjustment is input into a convolutional neural network model obtained through pre-training, and a face feature vector of the face image to be recognized before adjustment is obtained; and then, based on the face feature vector, carrying out similarity calculation on the face image to be recognized before adjustment and the face image of each registered user in a preset registration set.
In the embodiment of the present invention, how to obtain the convolutional neural network model is not limited, for example, the process of obtaining the convolutional neural network model may include: constructing an initial convolutional neural network model; acquiring a training face image sample, wherein the face image sample is a face image with correctly labeled image types (a registered image and an unregistered image); and inputting the classified image samples into an initial convolutional neural network model, and training to obtain the convolutional neural network model.
In the embodiment of the invention, the shooting time of the face image to be recognized is determined, the current pixel value adjustment coefficient corresponding to the shooting time is obtained, then the face image to be recognized is adjusted based on the current pixel value adjustment coefficient, then the face image to be recognized is subjected to face recognition after adjustment, and a face recognition result is obtained.
In the embodiment shown in fig. 1, the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods may be a contrast adjustment coefficient and/or a brightness adjustment coefficient, and referring to fig. 2, the different pixel value adjustment coefficients may be obtained by the following steps:
In this step, the contrast value of each registered face image may be calculated first, and then averaged. In the calculation of the contrast value, a contrast calculation formula may be adopted: c ∑ r (i, j) × p (i, j), where r (i, j) is a gray level difference between adjacent pixels; p (i, j) is the pixel distribution probability of the gray difference of the adjacent pixels being r; and C is the contrast value of the registered face image.
The brightness mean value of the registered set is the mean value of the brightness values of the registered face images, wherein the brightness value of each registered face image is the RGB mean value of the image.
In this step, the method for calculating the contrast mean and the brightness mean of the test set is the same as the method for calculating the contrast mean and the brightness mean of the registered set in step 203.
In this embodiment, the ratio of the registration set contrast mean to the test set contrast mean is used as the initial contrast adjustment coefficient, and the ratio of the registration set brightness mean to the test set brightness mean is used as the initial brightness adjustment coefficient, so that the algorithm is simple and easy to implement.
Fig. 3 is another schematic flow chart of the face recognition method provided in the embodiment of the present invention, which specifically includes the following steps:
and 305, determining a current contrast adjustment coefficient and a current brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and brightness adjustment coefficients corresponding to preset different pixel value adjustment time periods.
In this step, the face image to be recognized is first converted into an image in an RGB color mode, so as to perform pixel value adjustment on the image based on a contrast adjustment coefficient and a brightness adjustment coefficient in the following process.
The process of performing facial coordinate similarity transformation on a face image to be recognized in RGB format can be illustrated by the following example: for example: when the preset standard information of five sense organs is: and when the interpupillary distance is 10mm, the face image to be recognized is enlarged or reduced, so that the interpupillary distance in the face image to be recognized is 10 mm.
The similarity transformation is carried out on the face image to be recognized, and the transformed image is cut into an image with a preset size, so that the extraction of the feature vectors in the face image to be recognized is facilitated, meanwhile, the adjustment time can be saved during the subsequent pixel value adjustment, and the face recognition efficiency is improved.
And 308, calculating the RGB mean value of all pixel points in the standard-format face image to be recognized.
In this step, the adjusted face image to be recognized can be obtained by calculation according to the following formula:
Rn=(Ro-Mr)*αr+Mr*βr
Gn=(Go-Mg)*αg+Mg*βg
Bn=(Bo-Mb)*αb+Mb*βb
in another embodiment provided by the invention, the pixel value of the standard format to-be-recognized face image can be adjusted based on the RGB mean value and the RGB value of each pixel point in the standard format to-be-recognized face image only according to the current contrast adjustment coefficient, so as to obtain the adjusted to-be-recognized face image. At this time, the adjusted face image to be recognized may be obtained by calculation according to the following formula:
Rn=(Ro-Mr)*αr+Mr
Gn=(Go-Mg)*αg+Mg
Bn=(Bo-Mb)*αb+Mb
in another embodiment provided by the present invention, the pixel value of the standard format to-be-recognized face image may be adjusted based on the RGB mean value and the RGB values of the pixels in the standard format to-be-recognized face image only according to the current brightness adjustment coefficient, so as to obtain the adjusted to-be-recognized face image. At this time, the adjusted face image to be recognized may be obtained by calculation according to the following formula:
Rn=Ro-Mr+Mr*βr
Gn=Go-Mg+Mg*βg
Bn=Bo-Mb+Mb*βb
wherein R isnThe value of the R component of each pixel point in the adjusted face image to be recognized is obtained; roThe value of the R component of each pixel point in the face image to be recognized is obtained; gnThe value of the G component of each pixel point in the adjusted face image to be recognized is obtained; goThe value of the G component of each pixel point in the face image to be recognized is obtained; b isnThe value of the B component of each pixel point in the adjusted face image to be recognized is obtained; b isoThe value of the B component of each pixel point in the face image to be recognized is obtained; mrThe average value of R components of pixel points in the face image to be recognized is obtained; mgThe average value of G components of pixel points in the face image to be recognized is obtained; mbThe average value of B components of pixel points in the face image to be recognized is obtained; alpha is alpharA current contrast adjustment coefficient for the R component; alpha is alphagA current contrast adjustment coefficient for the G component; alpha is alphabAdjusting the coefficient for the current contrast of the B component; beta is arA current luminance adjustment coefficient for the R component; beta is agA current brightness adjustment coefficient for the G component; beta is abAnd adjusting the coefficient for the current brightness of the B component.
And 310, inputting the adjusted face image to be recognized into a convolutional neural network model obtained by pre-training, and extracting the feature vector of the adjusted face image to be recognized.
And 311, comparing the adjusted feature vectors of the face image to be recognized with the feature vectors of the registered face images in the registered set to obtain a plurality of first similarity values.
And step 312, inputting the facial image to be recognized in the standard format into a convolutional neural network model obtained by pre-training, and extracting the characteristic vector of the facial image to be recognized.
In this embodiment, as shown in fig. 3, step 312 may be processed in parallel with step 308, but in other embodiments, it may also be processed in series as long as step 312 is executed after step 307.
And 313, comparing the facial image feature vectors to be recognized with the registered facial image feature vectors in the registered set to obtain a plurality of second similarity values.
In the embodiment of the invention, the shooting time of a face image to be recognized is determined, a current pixel value adjustment coefficient corresponding to the shooting time is obtained, format conversion and facial feature coordinate similarity transformation are carried out on the face image to be recognized in a standard format to obtain the face image to be recognized in the standard format, according to the current contrast adjustment coefficient and the current brightness adjustment coefficient, the pixel value adjustment is carried out on the face image to be recognized in the standard format based on an RGB mean value and an RGB value of each pixel point in the face image to be recognized in the standard format, then the similarity calculation is carried out on the adjusted face image to be recognized and face images of all registered users in a preset registered set to obtain a first similarity value, and feature vectors of the face image to be recognized, which are not subjected to the pixel value adjustment, are compared with feature vectors of all registered face images in the registered set to obtain a second similarity value; and taking the registered user corresponding to the highest similarity value in the first similarity value and the second similarity value as the identification result. The pixel value adjustment time range is divided into different pixel value adjustment time periods according to the difference of the illumination conditions, and each pixel value adjustment time period corresponds to different pixel value adjustment coefficients, so that the current pixel value adjustment coefficient corresponding to the shooting time is adopted to adjust the face image to be recognized, and the accuracy of face recognition can be improved.
In the embodiment shown in fig. 3, the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods may be a contrast adjustment coefficient and a brightness adjustment coefficient, and referring to fig. 4, the different pixel value adjustment coefficients may be obtained by the following steps:
And 403, performing five-sense organ coordinate similarity transformation on the transitional registered face image, and cutting to obtain a standard format registered face image with a preset size.
The process of performing the similarity transformation of the coordinates of the facial features of the transition registration facial image is similar to the process of performing the similarity transformation of the coordinates of the facial features to be recognized in step 307, and details are not repeated here.
And step 404, registering the face images by using a standard format, and respectively calculating a registered set contrast mean value and a registered set brightness mean value.
And 408, carrying out five-sense organ coordinate similarity transformation on the transition test face image, and cutting to obtain a standard format test face image with a preset size.
The process of performing the facial coordinate similarity transformation on the transition test face image is similar to the process of performing the facial coordinate similarity transformation on the face row to be recognized in step 307, and the details are not repeated here.
And 409, testing the face image by using a standard format, and respectively calculating the contrast mean value and the brightness mean value of the test set.
And step 410, taking the ratio S2/S1 of the registration set contrast mean value and the test set contrast mean value as an initial contrast adjustment coefficient.
The objectives of the pattern search optimization method are: finding a contrast adjustment coefficient which enables the similarity of the face images of the test set and the face images of the registration set to be highest, wherein the specific method comprises the following steps: defining F (X1) to be 1-F (X1), wherein X1 is a contrast adjustment coefficient, an initial value of X1 is an initial contrast adjustment coefficient, and F (X1) is an average value of similarity of the face images in the test set and the registered set under different contrast adjustment coefficients; the pattern optimization search is performed on F (X1), and the search is stopped under the condition that F (X1) < epsilon, wherein epsilon can be a certain known constant set according to experience, that is, the value of X1 when F (X1) < epsilon is taken as the contrast adjustment coefficient.
In step 412, the ratio of the registered set luminance mean to the test set luminance mean is used as the initial luminance adjustment coefficient.
And 413, adjusting the brightness adjustment coefficient by adopting a mode search optimization method to enable the similarity between the face image of the test set and the face image of the registration set to be highest as a pixel condition, and obtaining the brightness adjustment coefficient corresponding to the current pixel value adjustment time period.
The objectives of the pattern search optimization method are: finding a brightness adjustment coefficient which enables the similarity of the face images of the test set and the face images of the registration set to be highest, wherein the specific method comprises the following steps: defining F (X2) ═ 1-F (X2), where X1 is a brightness adjustment coefficient, an initial value of X1 is an initial brightness adjustment coefficient, and F (X2) is an average value of the similarity of the face images in the test set and the registered set under different brightness adjustment coefficients; the mode optimization search is performed on F (X2), and the search is stopped under the condition that F (X2) < η, where η may be a known constant set empirically, that is, the value of X2 when F (X2) < η is taken as the brightness adjustment coefficient.
In the embodiment, before calculating the registration set contrast mean value, the registration set brightness mean value, the test set contrast mean value and the registration set brightness mean value, facial images in the registration set and the test set are subjected to facial coordinate similarity transformation and clipping, so that the adjustment time can be saved and the facial recognition efficiency can be improved when the pixel value is adjusted subsequently; meanwhile, the ratio of the registration set contrast mean value to the test set contrast mean value is used as an initial contrast adjustment coefficient, the ratio of the registration set brightness mean value to the test set brightness mean value is used as an initial brightness adjustment coefficient, and the algorithm is simple and easy to implement.
Based on the same inventive concept, according to the face recognition method provided in the above embodiment of the present invention, correspondingly, an embodiment of the present invention further provides a face recognition apparatus, a schematic structural diagram of which is shown in fig. 5, including:
an image obtaining module 501, configured to obtain a face image to be recognized;
a shooting time obtaining module 502, configured to obtain shooting time of a face image to be recognized;
a time range determining module 503, configured to determine whether the shooting time belongs to a preset pixel value adjusting time range;
a time period determining module 504, configured to determine a pixel value adjustment time period to which the shooting time belongs when the shooting time belongs to a preset pixel value adjustment time range; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range;
an adjustment coefficient determining module 505, configured to determine a current pixel value adjustment coefficient corresponding to the shooting time according to different preset pixel value adjustment coefficients corresponding to different preset pixel value adjustment time periods;
the pixel value adjusting module 506 is configured to perform pixel value adjustment on the face image to be recognized according to the current pixel value adjusting coefficient to obtain an adjusted face image to be recognized;
and the result obtaining module 507 is configured to perform face recognition on the adjusted face image to be recognized, so as to obtain a face recognition result.
Further, the image obtaining module 501 is specifically configured to obtain a currently shot face image to be recognized; the shooting time obtaining module is specifically used for obtaining the current shooting time.
Further, the pixel value adjustment coefficient includes: a contrast adjustment coefficient and/or a brightness adjustment coefficient; the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods include: different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods;
the adjustment coefficient determining module 505 is specifically configured to determine a current contrast adjustment coefficient and/or a current brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods.
Further, the apparatus may further include: a pixel value adjusting coefficient presetting module;
the pixel value adjustment coefficient presetting module may include: the device comprises a first obtaining submodule, a second obtaining submodule, a first calculating submodule, a second calculating submodule and an adjusting coefficient determining submodule;
the first acquisition sub-module is used for acquiring registered face images of a plurality of registered users contained in a registered set;
the second obtaining submodule is used for obtaining a plurality of test sets corresponding to each preset different time period; the test set corresponding to each different time period comprises: a plurality of test face images shot in the preset time period; the testing face image is the face image of the registered user;
the first calculation submodule is used for calculating the mean value of the contrast of the registered set and/or the mean value of the brightness of the registered set of a plurality of registered face images;
the second calculation submodule is used for calculating the test set contrast mean value and/or the test set brightness mean value of a plurality of test face images shot in the preset pixel value adjustment time period aiming at each test set corresponding to different pixel value adjustment time periods;
and the adjustment coefficient determining submodule is used for determining a contrast adjustment coefficient and/or a brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast mean value, the test set contrast mean value, the registration set brightness mean value, the test set brightness mean value and the pixel condition required by correctly recognizing the face in the pixel value adjustment time period.
Further, an adjustment coefficient determining submodule, which is specifically configured to use a ratio of the registration set contrast mean to the test set contrast mean as an initial contrast adjustment coefficient; taking the ratio of the registered set brightness mean value to the test set brightness mean value as an initial brightness adjustment coefficient; and adjusting the initial contrast adjustment coefficient and/or the initial brightness adjustment coefficient by adopting a mode search optimization method under the condition that the similarity between the face image of the test set and the face image of the registration set is the highest as a pixel, and determining the final contrast adjustment coefficient and/or the final brightness adjustment coefficient.
Further, the pixel value adjustment coefficient presetting module may further include: a first face image transformation submodule;
the first facial image transformation submodule is used for converting a plurality of registered facial images in the registered set and the test facial images in the test set into an RGB format; according to preset standard facial feature information, performing facial feature coordinate similarity transformation on a registered facial image and a tested facial image in RGB format respectively; respectively cutting the converted registered face image and the converted tested face image into a standard format registered face image and a standard format tested face image with preset sizes;
the first calculation submodule is specifically used for calculating the registered set contrast mean value and/or the registered set brightness mean value of a plurality of registered face images for the registered face images in the standard format;
and the second calculating submodule is specifically used for calculating the test set contrast mean value and/or the test set brightness mean value of a plurality of test face images shot in the preset pixel value adjusting time period for the standard format test face images aiming at each test set corresponding to each different pixel value adjusting time period.
Further, the pixel value adjusting module 506 may include: the RGB value obtaining sub-module, the third calculating sub-module and the pixel value adjusting sub-module;
the RGB value obtaining submodule is used for converting the face image to be recognized into an RGB format and obtaining the RGB value of each pixel point in the face image to be recognized;
the third calculation sub-module is used for calculating the RGB mean value of the pixel points in the face image to be recognized;
and the pixel value adjusting submodule is used for adjusting the pixel value of the face image to be recognized in the RGB format based on the RGB value and the RGB mean value of each pixel point in the face image to be recognized according to the current contrast adjusting coefficient and/or the current brightness adjusting coefficient to obtain the adjusted face image to be recognized.
The pixel value adjustment submodule is specifically configured to:
if the current pixel value adjustment coefficient only contains the current contrast adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr
Gn=(Go-Mg)*αg+Mg
Bn=(Bo-Mb)*αb+Mb
if the current pixel value adjustment coefficient only contains the current brightness adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=Ro-Mr+Mr*βr
Gn=Go-Mg+Mg*βg
Bn=Bo-Mb+Mb*βb
if the current pixel value adjustment coefficient comprises a current contrast adjustment coefficient and a current brightness adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr*βr
Gn=(Go-Mg)*αg+Mg*βg
Bn=(Bo-Mb)*αb+Mb*βb
wherein R isnThe value of the R component of each pixel point in the adjusted face image to be recognized is obtained; roThe value of the R component of each pixel point in the face image to be recognized is obtained; gnThe value of the G component of each pixel point in the adjusted face image to be recognized is obtained; goThe value of the G component of each pixel point in the face image to be recognized is obtained; b isnThe value of the B component of each pixel point in the adjusted face image to be recognized is obtained; b isoThe value of the B component of each pixel point in the face image to be recognized is obtained; mrThe average value of R components of pixel points in the face image to be recognized is obtained; mgThe average value of G components of pixel points in the face image to be recognized is obtained; mbThe average value of B components of pixel points in the face image to be recognized is obtained; alpha is alpharA current contrast adjustment coefficient for the R component; alpha is alphagA current contrast adjustment coefficient for the G component; alpha is alphabAdjusting the coefficient for the current contrast of the B component; beta is arA current luminance adjustment coefficient for the R component; beta is agA current brightness adjustment coefficient for the G component; beta is abAnd adjusting the coefficient for the current brightness of the B component.
Further, the pixel value adjusting module 506 may further include: a second face image transformation submodule;
the second face image transformation submodule is used for carrying out facial feature coordinate similarity transformation on the face image to be recognized in the RGB format according to preset standard facial feature information; cutting the transformed face image to be recognized into a standard format face image to be recognized with a preset size;
and the third calculation sub-module is specifically used for calculating the RGB mean value of the pixel points in the face image to be recognized in the standard format.
Further, the result obtaining module 507 is specifically configured to perform similarity calculation on the adjusted face image to be recognized and face images of registered users in a preset registration set to obtain a plurality of first similarity values; carrying out similarity calculation on the face image to be recognized before adjustment and the face images of all registered users in a preset registration set to obtain a plurality of second similarity values; and taking the registered user corresponding to the highest similarity value in the plurality of first similarity values and the plurality of second similarity values as the identification result.
In the embodiment of the present invention, a shooting time obtaining module 502 determines the shooting time of a face image to be recognized, and a time period determining module 504 determines a pixel value adjustment time period to which the shooting time belongs; the adjustment coefficient determining module 505 obtains a pixel value adjustment coefficient corresponding to the shooting time, then the pixel value adjusting module 506 adjusts the face image to be recognized based on the pixel value adjustment coefficient, the result obtaining module 507 performs face recognition on the adjusted face image to be recognized, and a face recognition result is obtained.
An embodiment of the present invention further provides an electronic device, as shown in fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to implement the following steps when executing the program stored in the memory 603:
acquiring a face image to be recognized;
acquiring the shooting time of a face image to be recognized;
judging whether the shooting time belongs to a preset pixel value adjusting time range or not;
when the shooting time belongs to a preset pixel value adjusting time range, determining a pixel value adjusting time period to which the shooting time belongs; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range;
determining a current pixel value adjustment coefficient corresponding to shooting time according to different preset pixel value adjustment coefficients corresponding to different preset pixel value adjustment time periods;
performing pixel value adjustment on the face image to be recognized according to the current pixel value adjustment coefficient to obtain an adjusted face image to be recognized;
and carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, in which instructions are stored, and when the instructions are executed on a computer, the computer is enabled to execute the face recognition method in any one of the above embodiments.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the face recognition method of any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the embodiments of the apparatus and the electronic device, since they are substantially similar to the embodiments of the method, the description is simple, and the relevant points can be referred to only in the partial description of the embodiments of the method.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Claims (19)
1. A face recognition method, comprising:
acquiring a face image to be recognized;
acquiring the shooting time of the face image to be recognized;
judging whether the shooting time belongs to a preset pixel value adjusting time range or not;
when the shooting time belongs to a preset pixel value adjusting time range, determining a pixel value adjusting time period to which the shooting time belongs; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range;
determining a current pixel value adjustment coefficient corresponding to the shooting time according to different pixel value adjustment coefficients corresponding to preset different pixel value adjustment time periods;
adjusting the pixel value of the face image to be recognized according to the current pixel value adjustment coefficient to obtain an adjusted face image to be recognized;
carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result;
the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods are obtained by adopting the following steps:
acquiring registered face images of a plurality of registered users contained in a registered set;
acquiring a plurality of test sets corresponding to each preset different pixel value adjusting time period; the test set corresponding to each different pixel value adjustment time period comprises: a plurality of test face images shot in a preset pixel value adjusting time period; the testing face image is a face image of a registered user;
calculating the mean value of the contrast of the registered set and/or the mean value of the brightness of the registered set of the plurality of registered face images;
calculating the contrast mean value and/or the brightness mean value of the test set of a plurality of test face images shot in the preset pixel value adjusting time period aiming at each test set corresponding to different time periods;
and determining a contrast adjustment coefficient and/or a brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast mean value, the test set contrast mean value, the registration set brightness mean value, the test set brightness mean value and the pixel condition required for correctly identifying the face in the pixel value adjustment time period, wherein the pixel condition is that the similarity between the test set face image and the registration set face image is highest.
2. The method according to claim 1, wherein the step of obtaining the face image to be recognized comprises: and acquiring the currently shot face image to be recognized.
3. The method of claim 1, wherein the pixel value adjustment factor comprises: a contrast adjustment coefficient and/or a brightness adjustment coefficient;
the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods include: different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods;
the step of determining the current pixel value adjustment coefficient corresponding to the shooting time according to different pixel value adjustment coefficients corresponding to different preset pixel value adjustment time periods includes:
and determining a current contrast adjustment coefficient and/or a current brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different preset pixel value adjustment time periods.
4. The method according to claim 1, wherein the step of determining the contrast adjustment coefficient and/or the brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast average value and the test set contrast average value, the registration set brightness average value and the test set brightness average value, and the pixel condition required for correctly recognizing the face in the pixel value adjustment time period comprises:
taking the ratio of the registration set contrast mean value to the test set contrast mean value as an initial contrast adjustment coefficient;
taking the ratio of the registered set brightness mean value to the test set brightness mean value as an initial brightness adjustment coefficient;
and adjusting the initial contrast adjustment coefficient and/or the initial brightness adjustment coefficient by adopting a mode search optimization method under the condition that the similarity between the face image of the test set and the face image of the registration set is the highest as a pixel, and determining a final contrast adjustment coefficient and/or a final brightness adjustment coefficient.
5. The method of claim 1, further comprising, prior to the step of calculating a registered set contrast mean and/or a registered set brightness mean of the plurality of registered face images:
converting a plurality of registered face images in the registered set and test face images in the test set into RGB format;
according to preset standard facial feature information, performing facial feature coordinate similarity transformation on a registered facial image and a tested facial image in RGB format respectively;
respectively cutting the converted registered face image and the converted tested face image into a standard format registered face image and a standard format tested face image with preset sizes;
the step of calculating the registered set contrast mean value and/or the registered set brightness mean value of the plurality of registered face images comprises the following steps:
for the registered face images in the standard format, calculating the registered set contrast mean value and/or the registered set brightness mean value of the plurality of registered face images;
the step of calculating the test set contrast mean value and/or the test set brightness mean value of a plurality of test face images shot in the preset pixel value adjustment time period for each test set corresponding to each different pixel value adjustment time period includes:
and aiming at each test set corresponding to each different pixel value adjusting time period, testing the face images in the standard format, and calculating the test set contrast mean value and/or the test set brightness mean value of a plurality of test face images shot in the preset pixel value adjusting time period.
6. The method according to claim 3, wherein the step of adjusting the pixel value of the facial image to be recognized according to the current pixel value adjustment coefficient to obtain the adjusted facial image to be recognized comprises:
converting the face image to be recognized into an RGB format, and obtaining RGB values of all pixel points in the face image to be recognized;
calculating the RGB mean value of pixel points in the face image to be recognized;
and adjusting the pixel value of the face image to be recognized in the RGB format based on the RGB value and the RGB mean value of each pixel point in the face image to be recognized according to the current contrast adjustment coefficient and/or the current brightness adjustment coefficient to obtain the adjusted face image to be recognized.
7. The method according to claim 6, wherein the step of performing pixel value adjustment on the to-be-recognized face image in the RGB format based on the RGB values and the RGB mean values of the respective pixel points in the to-be-recognized face image according to the current contrast adjustment coefficient and/or the current brightness adjustment coefficient to obtain the adjusted to-be-recognized face image comprises:
if the current pixel value adjustment coefficient only contains the current contrast adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr
Gn=(Go-Mg)*αg+Mg
Bn=(Bo-Mb)*αb+Mb
if the current pixel value adjustment coefficient only contains the current brightness adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=Ro-Mr+Mr*βr
Gn=Go-Mg+Mg*βg
Bn=Bo-Mb+Mb*βb
if the current pixel value adjustment coefficient comprises a current contrast adjustment coefficient and a current brightness adjustment coefficient, obtaining an adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr*βr
Gn=(Go-Mg)*αg+Mg*βg
Bn=(Bo-Mb)*αb+Mb*βb
wherein R isnThe value of the R component of each pixel point in the adjusted face image to be recognized is obtained; roThe value of the R component of each pixel point in the face image to be recognized is obtained; gnThe value of the G component of each pixel point in the adjusted face image to be recognized is obtained; goThe value of the G component of each pixel point in the face image to be recognized is obtained; b isnThe value of the B component of each pixel point in the adjusted face image to be recognized is obtained; b isoThe value of the B component of each pixel point in the face image to be recognized is obtained; mrThe average value of R components of pixel points in the face image to be recognized is obtained; mgThe average value of G components of pixel points in the face image to be recognized is obtained; mbThe average value of B components of pixel points in the face image to be recognized is obtained; alpha is alpharA current contrast adjustment coefficient for the R component; alpha is alphagA current contrast adjustment coefficient for the G component; alpha is alphabAdjusting the coefficient for the current contrast of the B component; beta is arA current luminance adjustment coefficient for the R component; beta is agA current brightness adjustment coefficient for the G component; beta is abAnd adjusting the coefficient for the current brightness of the B component.
8. The method according to claim 6, wherein before the step of calculating the RGB mean value of the pixel points in the face image to be recognized, the method further comprises:
according to preset standard facial feature information, performing facial feature coordinate similarity transformation on the face image to be recognized in the RGB format;
cutting the transformed face image to be recognized into a standard format face image to be recognized with a preset size;
the step of calculating the RGB mean value of the pixel points in the face image to be recognized comprises the following steps:
and calculating the RGB mean value of pixel points in the face image to be recognized in a standard format.
9. The method according to claim 1, wherein the step of performing face recognition on the adjusted face image to be recognized to obtain a face recognition result comprises:
carrying out similarity calculation on the adjusted face image to be recognized and the face images of all registered users in a preset registration set to obtain a plurality of first similarity values;
carrying out similarity calculation on the adjusted face image to be recognized and the face images of all registered users in a preset registration set to obtain a plurality of second similarity values;
and taking the registered user corresponding to the highest similarity value in the plurality of first similarity values and the plurality of second similarity values as an identification result.
10. A face recognition apparatus, comprising:
the image acquisition module is used for acquiring a face image to be recognized;
the shooting time acquisition module is used for acquiring the shooting time of the face image to be recognized;
the time range judging module is used for judging whether the shooting time belongs to a preset pixel value adjusting time range or not;
the time period determining module is used for determining a pixel value adjusting time period to which the shooting time belongs when the shooting time belongs to a preset pixel value adjusting time range; the pixel value adjusting time period is divided according to the illumination difference of different time periods in the pixel value adjusting time range;
the adjustment coefficient determining module is used for adjusting different pixel value adjustment coefficients corresponding to time periods according to preset different pixel values and determining a current pixel value adjustment coefficient corresponding to the shooting time;
the pixel value adjusting module is used for adjusting the pixel value of the face image to be recognized according to the current pixel value adjusting coefficient to obtain an adjusted face image to be recognized;
the result acquisition module is used for carrying out face recognition on the adjusted face image to be recognized to obtain a face recognition result;
a pixel value adjusting coefficient presetting module; the pixel value adjustment coefficient presetting module comprises: the device comprises a first obtaining submodule, a second obtaining submodule, a first calculating submodule, a second calculating submodule and an adjusting coefficient determining submodule;
the first acquisition sub-module is used for acquiring registered face images of a plurality of registered users contained in a registered set;
the second obtaining submodule is used for obtaining a plurality of test sets corresponding to each preset different pixel value adjusting time period; the test set corresponding to each different pixel value adjustment time period comprises: a plurality of test face images shot in a preset pixel value adjusting time period; the testing face image is a face image of a registered user;
the first calculating submodule is used for calculating the mean value of the contrast of the registered set and/or the mean value of the brightness of the registered set of the plurality of registered face images;
the second calculating submodule is used for calculating the test set contrast mean value and/or the test set brightness mean value of a plurality of test face images shot in the preset pixel value adjusting time period aiming at each test set corresponding to different pixel value adjusting time periods;
and the adjustment coefficient determining submodule is used for determining a contrast adjustment coefficient and/or a brightness adjustment coefficient corresponding to the pixel value adjustment time period based on the registration set contrast mean value, the test set contrast mean value, the registration set brightness mean value, the test set brightness mean value and the pixel condition required by correctly identifying the face in the pixel value adjustment time period, wherein the pixel condition is that the similarity between the test set face image and the registration set face image is highest.
11. The apparatus of claim 10,
the image acquisition module is specifically used for acquiring a currently shot face image to be recognized;
the shooting time obtaining module is specifically used for obtaining the current shooting time.
12. The apparatus of claim 10, wherein the pixel value adjustment factor comprises: a contrast adjustment coefficient and/or a brightness adjustment coefficient; the different pixel value adjustment coefficients corresponding to the preset different pixel value adjustment time periods include: different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to different pixel value adjustment time periods;
the adjustment coefficient determining module is specifically configured to determine a current contrast adjustment coefficient and/or a current brightness adjustment coefficient corresponding to the shooting time according to different contrast adjustment coefficients and/or brightness adjustment coefficients corresponding to preset different pixel values adjustment time periods.
13. The apparatus according to claim 10, wherein the adjustment factor determining sub-module is configured to use a ratio of the registered set contrast mean and the test set contrast mean as an initial contrast adjustment factor; taking the ratio of the registered set brightness mean value to the test set brightness mean value as an initial brightness adjustment coefficient; and adjusting the initial contrast adjustment coefficient and/or the initial brightness adjustment coefficient by adopting a mode search optimization method under the condition that the similarity between the face image of the test set and the face image of the registration set is the highest as a pixel, and determining a final contrast adjustment coefficient and/or a final brightness adjustment coefficient.
14. The apparatus of claim 10, wherein the pixel value adjustment coefficient presetting module further comprises: a first face image transformation submodule;
the first facial image transformation submodule is used for converting a plurality of registered facial images in the registered set and test facial images in the test set into an RGB format; according to preset standard facial feature information, performing facial feature coordinate similarity transformation on a registered facial image and a tested facial image in RGB format respectively; respectively cutting the converted registered face image and the converted tested face image into a standard format registered face image and a standard format tested face image with preset sizes;
the first calculating submodule is specifically used for calculating the registered set contrast mean value and/or the registered set brightness mean value of the plurality of registered face images for the registered face images in the standard format;
the second calculating submodule is specifically configured to calculate a test set contrast average value and/or a test set brightness average value of a plurality of test face images captured in the preset pixel value adjustment time period for the standard format test face image for each test set corresponding to each different pixel value adjustment time period.
15. The apparatus of claim 12, wherein the pixel value adjustment module comprises: the RGB value obtaining sub-module, the third calculating sub-module and the pixel value adjusting sub-module;
the RGB value obtaining submodule is used for converting the face image to be recognized into an RGB format and obtaining the RGB value of each pixel point in the face image to be recognized;
the third computing sub-module is used for computing the RGB mean value of the pixel points in the face image to be recognized;
and the pixel value adjusting submodule is used for adjusting the pixel value of the face image to be recognized in the RGB format based on the RGB value and the RGB mean value of each pixel point in the face image to be recognized according to the current contrast adjusting coefficient and/or the current brightness adjusting coefficient to obtain the adjusted face image to be recognized.
16. The apparatus of claim 15, wherein the pixel value adjustment submodule is specifically configured to:
if the current pixel value adjustment coefficient only contains the current contrast adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr
Gn=(Go-Mg)*αg+Mg
Bn=(Bo-Mb)*αb+Mb
if the current pixel value adjustment coefficient only contains the current brightness adjustment coefficient, obtaining the adjusted face image to be recognized by adopting the following formula:
Rn=Ro-Mr+Mr*βr
Gn=Go-Mg+Mg*βg
Bn=Bo-Mb+Mb*βb
if the current pixel value adjustment coefficient comprises a current contrast adjustment coefficient and a current brightness adjustment coefficient, obtaining an adjusted face image to be recognized by adopting the following formula:
Rn=(Ro-Mr)*αr+Mr*βr
Gn=(Go-Mg)*αg+Mg*βg
Bn=(Bo-Mb)*αb+Mb*βb
wherein R isnThe value of the R component of each pixel point in the adjusted face image to be recognized is obtained; roThe value of the R component of each pixel point in the face image to be recognized is obtained; gnIs the adjusted waitingIdentifying the value of the G component of each pixel point in the face image; goThe value of the G component of each pixel point in the face image to be recognized is obtained; b isnThe value of the B component of each pixel point in the adjusted face image to be recognized is obtained; b isoThe value of the B component of each pixel point in the face image to be recognized is obtained; mrThe average value of R components of pixel points in the face image to be recognized is obtained; mgThe average value of G components of pixel points in the face image to be recognized is obtained; mbThe average value of B components of pixel points in the face image to be recognized is obtained; alpha is alpharA current contrast adjustment coefficient for the R component; alpha is alphagA current contrast adjustment coefficient for the G component; alpha is alphabAdjusting the coefficient for the current contrast of the B component; beta is arA current luminance adjustment coefficient for the R component; beta is agA current brightness adjustment coefficient for the G component; beta is abAnd adjusting the coefficient for the current brightness of the B component.
17. The apparatus of claim 15, wherein the pixel value adjustment module further comprises: a second face image transformation submodule;
the second facial image transformation submodule is used for carrying out facial coordinate similarity transformation on the facial image to be recognized in the RGB format according to preset standard facial feature information; cutting the transformed face image to be recognized into a standard format face image to be recognized with a preset size;
the third computation submodule is specifically configured to compute an RGB mean value of a pixel point in a to-be-recognized face image in a standard format.
18. The apparatus according to claim 10, wherein the result obtaining module is specifically configured to perform similarity calculation between the adjusted face image to be recognized and face images of registered users in a preset registration set to obtain a plurality of first similarity values; carrying out similarity calculation on the adjusted face image to be recognized and the face images of all registered users in a preset registration set to obtain a plurality of second similarity values; and taking the registered user corresponding to the highest similarity value in the plurality of first similarity values and the plurality of second similarity values as an identification result.
19. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method of any one of claims 1 to 9 when executing a program stored in a memory.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811589438.2A CN109711328B (en) | 2018-12-25 | 2018-12-25 | Face recognition method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811589438.2A CN109711328B (en) | 2018-12-25 | 2018-12-25 | Face recognition method and device and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109711328A CN109711328A (en) | 2019-05-03 |
CN109711328B true CN109711328B (en) | 2021-07-30 |
Family
ID=66257403
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811589438.2A Active CN109711328B (en) | 2018-12-25 | 2018-12-25 | Face recognition method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109711328B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114549932A (en) * | 2022-02-21 | 2022-05-27 | 平安科技(深圳)有限公司 | Data enhancement processing method, device, computer equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102223546A (en) * | 2011-06-07 | 2011-10-19 | 中兴通讯股份有限公司 | Method and device for regulating brightness of video image |
CN202771437U (en) * | 2012-02-06 | 2013-03-06 | 北京鑫光智信软件技术有限公司 | Multi-modal identity authentication device based on biological characteristics of finger part |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4169185B2 (en) * | 2002-02-25 | 2008-10-22 | 富士通株式会社 | Image linking method, program, and apparatus |
US7254268B2 (en) * | 2002-04-11 | 2007-08-07 | Arcsoft, Inc. | Object extraction |
WO2004106856A1 (en) * | 2003-05-29 | 2004-12-09 | Olympus Corporation | Device and method of supporting stereo camera, device and method of detecting calibration, and stereo camera system |
CN102013006B (en) * | 2009-09-07 | 2013-03-13 | 泉州市铁通电子设备有限公司 | Method for automatically detecting and identifying face on the basis of backlight environment |
CN103841337B (en) * | 2012-11-23 | 2017-04-05 | 北京百度网讯科技有限公司 | The method and apparatus of BLC |
US9095285B2 (en) * | 2013-04-11 | 2015-08-04 | Yaroslav Ryabov | Portable biometric identification device using a dorsal hand vein pattern |
CN103500339B (en) * | 2013-09-11 | 2017-07-21 | 北京工业大学 | A kind of illumination face recognition method for combining single scale Retinex algorithm and normalization Structural descriptors |
CN104994306B (en) * | 2015-06-29 | 2019-05-03 | 厦门美图之家科技有限公司 | A kind of image capture method and photographic device based on face's brightness adjust automatically exposure |
CN106068048B (en) * | 2016-05-25 | 2018-05-22 | 中国地质大学(武汉) | A kind of light adaptive regulation method and system based on face brightness identification |
CN106056064B (en) * | 2016-05-26 | 2019-10-11 | 汉王科技股份有限公司 | A kind of face identification method and face identification device |
CN106412534B (en) * | 2016-10-27 | 2018-09-11 | 成都西纬科技有限公司 | A kind of brightness of image adjusting method and device |
CN108197546B (en) * | 2017-12-26 | 2020-12-11 | 深圳市友信长丰科技有限公司 | Illumination processing method and device in face recognition, computer equipment and storage medium |
-
2018
- 2018-12-25 CN CN201811589438.2A patent/CN109711328B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102223546A (en) * | 2011-06-07 | 2011-10-19 | 中兴通讯股份有限公司 | Method and device for regulating brightness of video image |
CN202771437U (en) * | 2012-02-06 | 2013-03-06 | 北京鑫光智信软件技术有限公司 | Multi-modal identity authentication device based on biological characteristics of finger part |
Also Published As
Publication number | Publication date |
---|---|
CN109711328A (en) | 2019-05-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110378235B (en) | Fuzzy face image recognition method and device and terminal equipment | |
US8792722B2 (en) | Hand gesture detection | |
WO2020253127A1 (en) | Facial feature extraction model training method and apparatus, facial feature extraction method and apparatus, device, and storage medium | |
CN107944020A (en) | Facial image lookup method and device, computer installation and storage medium | |
WO2019085064A1 (en) | Medical claim denial determination method, device, terminal apparatus, and storage medium | |
US20120027263A1 (en) | Hand gesture detection | |
CN109871845B (en) | Certificate image extraction method and terminal equipment | |
CN110363747B (en) | Intelligent abnormal cell judging method, device and computer readable storage medium | |
CN110956615B (en) | Image quality evaluation model training method and device, electronic equipment and storage medium | |
CN110245573B (en) | Sign-in method and device based on face recognition and terminal equipment | |
CN108399405A (en) | Business license recognition methods and device | |
WO2020253508A1 (en) | Abnormal cell detection method and apparatus, and computer readable storage medium | |
US20200320342A1 (en) | Method and apparatus for training an object identification neural network, and computer device | |
CN109116129B (en) | Terminal detection method, detection device, system and storage medium | |
CN113792827B (en) | Target object recognition method, electronic device, and computer-readable storage medium | |
CN111199186A (en) | Image quality scoring model training method, device, equipment and storage medium | |
CN111210402A (en) | Face image quality scoring method and device, computer equipment and storage medium | |
CN112507897A (en) | Cross-modal face recognition method, device, equipment and storage medium | |
CN111368867A (en) | Archive classification method and system and computer readable storage medium | |
CN113627361B (en) | Training method and device for face recognition model and computer program product | |
CN113158773B (en) | Training method and training device for living body detection model | |
US20150058579A1 (en) | Systems and methods for memory utilization for object detection | |
CN109711328B (en) | Face recognition method and device and electronic equipment | |
CN113283388A (en) | Training method, device and equipment of living human face detection model and storage medium | |
CN111899239A (en) | Image processing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |