Face recognition method, device, computer equipment and storage medium
By extracting and matching feature vectors in face recognition technology, face recognition matching is directly performed, which solves the problems of cumbersome and low-efficiency face recognition processes in the existing technology, and achieves an efficient face recognition process.
Patent Information
- Application Number
- CN201810934470.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-08-16
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2038-08-16
AI Technical Summary
The implementation process of existing face recognition technology is cumbersome and requires comprehensive verification of multiple images or pre-training of complex neural network models, resulting in high computer resource consumption and low recognition efficiency.
By extracting the similarity between the feature vector of the image to be recognized and the benchmark feature vector, the user ID corresponding to the benchmark feature vector with the highest feature similarity is obtained, further extracting the target feature vector, and calculating the similarity between the target feature vector and the custom feature vector. , perform matching directly to avoid comprehensive verification of multiple frames of images and pre-training of neural network models.
It simplifies the face recognition process, improves recognition efficiency, and reduces computer resource consumption while ensuring security.
Smart Images

Figure CN109241868B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image processing, and more specifically, relates to a face recognition method, device, computer equipment and storage medium. Background Art
[0002] Face recognition technology is a biometric recognition technology that has achieved rapid development in recent years. At present, face recognition technology has been widely used in criminal investigation, banking system, customs inspection, civil affairs department, work and rest attendance and other fields. However, the general face recognition process requires the input of multiple pictures for comprehensive verification, or requires pre-training of complex neural network models to achieve it. The implementation process is relatively cumbersome, the recognition mechanism requires too many computer resources, and the recognition efficiency is not high. Summary of the invention
[0003] The embodiments of the present invention provide a face recognition method, apparatus, computer equipment and storage medium to solve the problem of complicated implementation process of face recognition.
[0004] A face recognition method, comprising:
[0005] Acquire an image to be identified, and extract a feature vector to be identified based on the image to be identified;
[0006] Obtaining feature similarity between the feature vector to be identified and each reference feature vector;
[0007] The user ID corresponding to the benchmark feature vector with the highest feature similarity is used as the target user ID;
[0008] Acquire a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area;
[0009] The vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier is calculated, and a recognition result is obtained according to the vector similarity.
[0010] A face recognition device, comprising:
[0011] A feature vector extraction module is used to obtain an image to be identified and extract a feature vector to be identified based on the image to be identified;
[0012] A feature similarity acquisition module, used to acquire the feature similarity between the feature vector to be identified and each reference feature vector;
[0013] A user identification acquisition module, used to use the user identification corresponding to the reference feature vector with the highest feature similarity as the target user identification;
[0014] A target feature vector extraction module, used to obtain a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area;
[0015] The recognition result acquisition module is used to calculate the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier, and obtain the recognition result according to the vector similarity.
[0016] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned face recognition method when executing the computer program.
[0017] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned face recognition method are implemented.
[0018] The above-mentioned face recognition method, device, computer equipment and storage medium obtain the image to be recognized, extract the feature vector to be recognized according to the image to be recognized; then obtain the feature similarity between the feature vector to be recognized and each benchmark feature vector, and use the user ID corresponding to the benchmark feature vector with the highest feature similarity as the target user ID; then obtain the target area in the image to be recognized according to the target user ID, and extract the target feature vector according to the target area; finally calculate the vector similarity between the target feature vector and the custom feature vector corresponding to the target user ID, and obtain the recognition result according to the vector similarity. Different recognition information is configured for each user through the user-defined feature vector, and matching can be performed directly in the face recognition process, without the need for comprehensive verification through multiple frames of images, and without the need for pre-training of complex neural network models to achieve, while ensuring the security of the face recognition process, it also improves the recognition efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0020] Figure 1 is a schematic diagram of an application environment of a face recognition method according to an embodiment of the present invention;
[0021] Figure 2 is a flow chart of a face recognition method in one embodiment of the present invention;
[0022] Figure 3is another flow chart of a face recognition method according to an embodiment of the present invention;
[0023] Figure 4 is another flow chart of a face recognition method according to an embodiment of the present invention;
[0024] Figure 5 is a principle block diagram of a face recognition device in one embodiment of the present invention;
[0025] Figure 6 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] The face recognition method provided in this application can be applied in Figure 1 In an application environment, the client communicates with the server through a network, the server obtains the image to be identified through the client, and extracts the feature vector to be identified according to the image to be identified; then the feature similarity between the feature vector to be identified and each benchmark feature vector is obtained, and the user identifier corresponding to the benchmark feature vector with the highest feature similarity is used as the target user identifier; then the target area of the image to be identified is obtained according to the target user identifier, and the target feature vector is extracted according to the target area; finally, the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier is calculated, and the recognition result is obtained according to the vector similarity and returned to the client. Among them, the client can be but not limited to various personal computers, laptops, smart phones, tablets and portable wearable devices. The server can be implemented with an independent server or a server cluster consisting of multiple servers.
[0028] In one embodiment, if Figure 2 As shown, a face recognition method is provided, which is applied in Figure 1 The server in the example is used as an example to illustrate the following steps:
[0029] S10: Acquire an image to be identified, and extract a feature vector to be identified based on the image to be identified.
[0030] Among them, the image to be identified refers to the detection image for face recognition. Optionally, the server obtains the image to be identified through the image acquisition device of the client. For example, the user stands in the acquisition area of the image acquisition device to acquire the image, and the user sends the acquired image to the server to obtain the image to be identified. A feature vector refers to a vector used to characterize the characteristics of image information. It can characterize image information with simple data to avoid subsequent repeated extraction operations. There are many types of feature vectors, such as: HOG (Histogra mof Oriented Gradient) feature vector, LBP (Local Binary Patterns) feature vector or PCA (Principal Component Analysis) feature vector, etc.
[0031] Preferably, in this embodiment, the HOG feature vector of the image to be identified can be extracted as the feature vector to be identified. Since the HOG feature vector of the image to be identified is described by the gradient of the local information of the image to be identified, extracting the HOG feature vector of the image to be identified as the feature vector to be identified can avoid the influence of factors such as geometric deformation and light changes on face recognition.
[0032] Specifically, the extraction of HOG feature vectors can be achieved through the following steps:
[0033] (1) The collected image to be identified is converted into grayscale image and gamma normalized.
[0034] (2) The image to be identified after being processed in step (1) is divided into a number of pixel units, where each 4 adjacent units constitute an interval.
[0035] (3) Count the histogram of each pixel in each unit according to the gradient direction.
[0036] (4) Calculate the histogram of each unit and obtain the characteristics of the unit.
[0037] (5) Finally, the features of each unit in all intervals are connected in series to obtain the HOG feature, that is, the HOG feature vector.
[0038] S20: Obtain feature similarity between the feature vector to be identified and each reference feature vector.
[0039] The reference feature vector is a feature vector corresponding to a pre-extracted reference face image. The reference face images are pre-collected face images of different users, and the reference feature vectors of each user are extracted to represent different users. Since the reference feature vectors correspond one-to-one to the users in the database of the server, by calculating the feature similarity between the feature vector to be identified and each reference feature vector, it can be determined which reference face image the image to be identified is closest to.
[0040] Specifically, the process of extracting the reference feature vector may be: collecting a preset number of face images of a user, then extracting the feature vector of each face image, and calculating the mean of these feature vectors, and using the obtained mean as the reference feature vector of the user. It should be understood that the feature vector to be identified corresponds to the reference feature vector. For example, if the reference feature vector is a HOG feature vector, the feature vector to be identified is also a HOG feature vector.
[0041] Optionally, the feature similarity may be obtained by using a similarity calculation algorithm, such as a Euclidean distance algorithm, a Manhattan distance algorithm, a Minkowski distance algorithm, or a cosine similarity algorithm.
[0042] In one embodiment, the Euclidean distance algorithm is used to calculate the feature similarity between the feature vector to be identified and the reference feature vector:
[0043]
[0044] Among them, U is the feature vector to be identified, V is the reference feature vector, sim(U,V) EDG is the feature similarity between U and V.
[0045] By calculating the feature similarity between the feature vector to be identified and the reference feature vector through the Euclidean algorithm, an accurate data basis can be provided for subsequent similarity judgment.
[0046] S30: taking the user identifier corresponding to the reference feature vector with the highest feature similarity as the target user identifier.
[0047] Specifically, after obtaining the feature similarity between the feature vector to be identified and each benchmark feature vector in step S20, the user identifier corresponding to the benchmark feature vector with the highest feature similarity is used as the target user identifier, that is, it is determined which user identifier corresponds to the target face in the image to be identified.
[0048] It is understandable that the user in the image to be identified may not exist in the server's database. In order to optimize the face recognition process and ensure user information security, in one embodiment, before step S30, if the maximum value of the feature similarity is less than the preset similarity threshold, the recognition result of failed recognition is output.
[0049] The preset similarity threshold value is preset by the server and is the minimum feature similarity value between the feature vector to be identified and the reference feature vector when corresponding to the user identification.
[0050] Specifically, the feature similarity of the image to be identified is calculated with each benchmark feature vector. If the maximum value of the feature similarity between the feature vector of the image to be identified and all the benchmark feature vectors is less than the preset similarity threshold, it means that the target face in the identified image is not close to any user in the database, indicating that the target face may not be in the database. In this way, the recognition result of recognition failure is output. Optionally, when the recognition failure result is output, the face recognition process is stopped, and the user is denied to log in to ensure the security of user information.
[0051] Optionally, in order to avoid the maximum feature similarity being less than the similarity threshold due to erroneous operations or the like in the process of acquiring the image to be identified, a process can be set up to allow the user to re-capture the image and calculate if the recognition fails. If the preset number of times is exceeded, the recognition result of the recognition failure is output, the face recognition process is stopped, and the user is denied to log in, thereby ensuring the user's information security.
[0052] In this embodiment, if the maximum value of the feature similarity between the feature vector of the image to be identified and the reference feature vector is less than the similarity threshold, a recognition result of recognition failure is output to prevent the user from being maliciously logged in and ensure the user's information security.
[0053] In one embodiment, steps S10-S30 may also be implemented by a neural network (NN) model or a support vector machine (SVM). Specifically, after acquiring the image to be identified, the image to be identified is directly input into a pre-trained neural network model or support vector machine to obtain a recognition result. The recognition result is the correspondence between the image to be identified and the user identifier, so the user identifier corresponding to the recognition result can be used as the target user identifier.
[0054] S40: Acquire a target region in the image to be identified according to the target user identifier, and extract a target feature vector according to the target region.
[0055] The target area is a user-defined area. During the user data collection (database establishment), the user can define a target area and set a corresponding action for the target area. After the target user identifier is determined in step S30, the target area in the image to be identified is obtained according to the target user identifier, and finally the target feature vector of the target area is extracted to determine whether the action of the target area is consistent with the corresponding action defined by the user.
[0056] Specifically, a facial feature point detection algorithm may be used to locate target key points in the image to be identified, then a target region is acquired based on the target key points, and finally a target feature vector is extracted based on the target region.
[0057] For example, if the target area set by the user is the left eye, and the corresponding action of the left eye is set to close the eyes, the server will obtain the left eye area in the image to be identified according to the target user identifier corresponding to the user, and extract the feature vector of the left eye area to determine whether the action of the target area is consistent with the corresponding action set by the user.
[0058] S50: Calculate the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier, and obtain a recognition result according to the vector similarity.
[0059] Among them, the custom feature vector refers to the feature vector obtained by the user according to the image customized, which can be used as the basis for user face recognition. For example, if the user customizes the image of the left eye as closed, the feature vector obtained on this image is the custom feature vector. After extracting the target feature vector, the vector similarity between the target feature vector and the custom feature vector is calculated. The specific calculation method is similar to step S30 and will not be repeated here. After obtaining the vector similarity, different recognition results can be output according to the value of the vector similarity.
[0060] In one embodiment, the recognition result can be judged and output based on the benchmark threshold, that is, in step S50, the recognition result is obtained based on the vector similarity, which can specifically include: if the vector similarity is greater than or equal to the benchmark threshold, then the recognition result of successful matching is output; if the vector similarity is less than the benchmark threshold, then the recognition result of failed matching is output.
[0061] Specifically, a reference threshold can be set in advance, and then different recognition results are output according to the magnitude relationship between the vector similarity and the reference threshold. If the vector similarity is greater than or equal to the reference threshold, it is considered that the target feature vector and the custom feature vector are matched, and a recognition result of successful matching is output; if the vector similarity is less than the reference threshold, it is considered that the target feature vector and the custom feature vector are not matched, and a recognition result of failed matching is output.
[0062] exist Figure 2 In the corresponding embodiment, by acquiring the image to be identified, extracting the feature vector to be identified according to the image to be identified; then obtaining the feature similarity between the feature vector to be identified and each benchmark feature vector, taking the user ID corresponding to the benchmark feature vector with the highest feature similarity as the target user ID; then obtaining the target area in the image to be identified according to the target user ID, and extracting the target feature vector according to the target area; finally calculating the vector similarity between the target feature vector and the custom feature vector corresponding to the target user ID, and obtaining the recognition result according to the vector similarity. By configuring different recognition information for each user through the user-defined feature vector, matching can be performed directly in the face recognition process, without the need for comprehensive verification through multiple frames of images, and without the need for pre-training of complex neural network models to achieve, while ensuring the security of the face recognition process, it also improves the recognition efficiency.
[0063] In one embodiment, if Figure 3 As shown, before step S40, that is, before the step of obtaining the target area in the image to be identified according to the target user identifier and extracting the target feature vector according to the target area, the face recognition method provided by the embodiment of the present invention further includes the following steps:
[0064] S61: Obtain a custom configuration request, wherein the custom configuration request includes login information.
[0065] The custom configuration request is a request initiated by the user to configure his / her own authentication information. The login information refers to the information entered by the user for identity authentication, and optionally, the login information includes a user account and a user password.
[0066] Specifically, the server obtains the custom configuration request through the client, and when the custom configuration request is obtained, sends a login verification to the user through the client, so that the user enters login information on the client for verification.
[0067] S62: If the login information is verified, a list of areas to be selected is sent.
[0068] Specifically, the server can query the login password corresponding to the user account in the database according to the user account, and then verify whether the user password is consistent with the login password. If the two are consistent, the verification is passed, and a list of candidate areas is sent to the user for the user to select. The list of candidate areas refers to a table that lists the candidate areas, and the candidate areas refer to the currently supported areas for the user to select. For example, the candidate areas can be the eye area, the mouth area, or other parts of the body.
[0069] Optionally, the area to be selected is the entire facial area. Correspondingly, in the subsequent user customization process, it can be defined by different emotions, such as happiness, sadness, grief, fear, anger, surprise, disgust and calmness; and then the corresponding emotion recognition model is used to identify the corresponding area of the image to be identified to obtain the corresponding judgment result.
[0070] S63: obtaining user selection information based on the list of areas to be selected and collecting a predetermined number of configuration images, and obtaining a target area in each configuration image according to the user selection information.
[0071] The user selection information refers to the selection information made by the user according to the list of areas to be selected, that is, the target area selected by the user.
[0072] Specifically, the user selection information based on the list of areas to be selected is obtained, a predetermined number of configuration images are collected, and the target area in each configuration image is obtained based on the user selection information. The predetermined number can be set according to actual conditions and is not specifically limited in the embodiment of the present invention.
[0073] For example, the user selects the eye area as the target area through the list of candidate areas, and the client obtains a predetermined number of face images of the user as configuration images, and then collects the eye area in each configuration image.
[0074] S64: extracting a feature vector of a target region in each configuration image and calculating a mean value of the feature vector of the target region to obtain a custom feature vector.
[0075] Specifically, the feature vectors of the target area in each configuration image obtained according to step S63 are extracted, and then the mean of the feature vectors of these target areas is calculated, and the obtained mean is used as the custom feature vector. The method of extracting vectors and calculating the mean of vectors is the same as that in the above embodiment, and will not be repeated here. By extracting the feature vectors of the target area in each configuration image and calculating the mean of the feature vectors of these target areas, the action of the user-defined configuration can be converted into a custom feature vector.
[0076] exist Figure 3In the corresponding embodiment, by obtaining a custom configuration request, the login information in the custom configuration request is verified. If the login information is verified, a list of areas to be selected is sent to the user; then the user selection information is obtained based on the list of areas to be selected and a predetermined number of configuration images are collected, and the target area in each configuration image is obtained according to the user selection information; finally, the feature vector of the target area in each configuration image is extracted and the mean of the feature vector of the target area is calculated to obtain a custom feature vector. By setting the user's custom feature vector, different feature vectors can be configured for each user, thereby providing support for face recognition. In addition, by using the custom feature vector, the face can be subsequently recognized based on the similarity between the target feature vector and the custom feature vector, which can improve the efficiency of face recognition for the user.
[0077] In one embodiment, if Figure 4 As shown, after step S50, that is, after the step of calculating the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier and obtaining the recognition result according to the vector similarity, the face recognition method provided by the embodiment of the present invention further includes the following steps:
[0078] S71: If the recognition result is a match failure, count the number of match failures of the target user identifier within a preset time, and determine whether the number of match failures within the preset time reaches a threshold.
[0079] Specifically, a number threshold is set and the number of match failures of the target user identifier within a preset time is counted. When the target user identifier fails to match within the preset time, the number of match failures of the target user identifier is increased by 1 accordingly, and it is determined whether the number of match failures of the target user identifier within the preset time reaches the number threshold. The preset time is a pre-set time period, and the time period can be 12 hours, 24 hours, or 48 hours, etc.
[0080] S72: If the number of matching failures within a preset time reaches a threshold, the matching ends and a prompt message is sent according to the target user identifier.
[0081] Specifically, if the number of matching failures of the target user identifier reaches a threshold within a preset time, indicating that the number of matching failures is already large, the matching process is stopped, and a prompt message is sent to the corresponding user based on the target user identifier, prompting the user that there may be a risk of malicious account verification so that the user can change the configuration or perform other operations.
[0082] S73: If the number of matching failures within the preset time does not reach the number threshold, an image acquisition request is sent to obtain a new image to be identified.
[0083] Specifically, if the number of failed matches of the target user identification does not reach the threshold within a preset time, in order to reduce the error in the image acquisition or matching process, the server sends an image acquisition request to the user end, so that the user end re-acquires the image to obtain a new image to be identified.
[0084] S74: extracting a new feature vector to be identified of the new image to be identified, and calculating the feature similarity between the new feature vector to be identified and the reference feature vector corresponding to the target user identifier.
[0085] Specifically, after obtaining a new image to be identified, a new feature vector to be identified of the new image to be identified is extracted, and the feature similarity between the new feature vector to be identified and the reference feature vector corresponding to the target user identifier is calculated, wherein the specific extraction and calculation process of the new feature vector to be identified is the same as steps S20 and S30, and will not be repeated here.
[0086] S75: If the feature similarity is greater than or equal to the similarity threshold, return to the step of extracting the target area in the image to be identified according to the target user identifier, and extracting the target feature vector according to the target area.
[0087] Specifically, if the feature similarity is greater than or equal to the similarity threshold, it indicates that the corresponding user exists in the database, but due to image acquisition reasons, the input target area is incomplete or inaccurate, resulting in the previous matching failure; therefore, return to execute step S40, that is, extract the target area in the image to be identified according to the target user identifier, and extract the target feature vector according to the target area, and continue to execute the subsequent steps.
[0088] S76: If the feature similarity is less than the similarity threshold, return to the step of counting the number of failed matches of the target user identifier within a preset time, and determining whether the number of failed matches of the target user identifier within the preset time reaches the number threshold.
[0089] Specifically, if the feature similarity is less than the similarity threshold, it indicates that the user may not exist in the database. However, it is also possible that the new image to be identified is incomplete or inaccurate due to image acquisition, resulting in the similarity between the new feature vector to be identified and the benchmark feature vector being lower than the similarity threshold. Therefore, the process returns to step S71, that is, counting the number of failed matches of the target user identifier within a preset time, determining whether the number of failed matches of the target user identifier within the preset time reaches the number threshold, and continuing to execute subsequent steps.
[0090] exist Figure 4In the corresponding embodiment, by counting the number of matching failures of the target user identifier within a preset time, it is determined whether the number of matching failures within the preset time reaches a number threshold. If the number threshold is reached, the matching is terminated, and a prompt message is sent according to the target user identifier to prompt the user that there may be a risk of malicious account verification; if the number threshold is not reached, an image acquisition request is sent to acquire a new image to be identified, and a new feature vector to be identified is extracted, and the feature similarity between the new feature vector to be identified and the reference feature vector corresponding to the target user identifier is calculated; if the similarity is greater than or equal to the similarity threshold, the steps of extracting the target area and extracting the target feature vector are returned to execute; if the similarity is less than the similarity threshold, the steps of counting the number of matching failures are returned to execute, and subsequent operations are performed as needed to improve the integrity of face recognition, ensure user information security and improve user experience.
[0091] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0092] In one embodiment, a face recognition device is provided, which corresponds one-to-one to the face recognition method in the above embodiment. Figure 5 As shown, the face recognition device includes a feature vector extraction module 10, a feature similarity acquisition module 20, a user identification acquisition module 30, a target feature vector extraction module 40 and a recognition result acquisition module 50. The functional modules are described in detail as follows:
[0093] The feature vector extraction module 10 is used to obtain the image to be identified and extract the feature vector to be identified according to the image to be identified.
[0094] The feature similarity acquisition module 20 is used to acquire the feature similarity between the feature vector to be identified and each reference feature vector.
[0095] Furthermore, the feature similarity acquisition module 20 uses the Euclidean distance algorithm to calculate the feature similarity between the feature vector to be identified and the reference feature vector:
[0096]
[0097] Among them, U is the feature vector to be identified, V is the reference feature vector, sim(U,V) EDG is the feature similarity between U and V.
[0098] The user identification acquisition module 30 is used to use the user identification corresponding to the reference feature vector with the highest feature similarity as the target user identification.
[0099] Optionally, if the maximum value of the feature similarity is less than a preset similarity threshold, the user identification acquisition module 30 outputs a recognition result of recognition failure.
[0100] The target feature vector extraction module 40 is used to obtain a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area.
[0101] The recognition result acquisition module 50 is used to calculate the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier, and obtain the recognition result according to the vector similarity.
[0102] Furthermore, the recognition result acquisition module 50 is also used to output a recognition result of successful matching if the vector similarity is greater than or equal to a reference threshold; and to output a recognition result of failed matching if the vector similarity is less than the reference threshold.
[0103] Furthermore, the face recognition device provided by the embodiment of the present invention also includes a user-defined module. Optionally, the user-defined module includes a configuration request acquisition unit, a candidate area sending unit, a target area acquisition unit and a user-defined feature vector acquisition unit.
[0104] The configuration request obtaining unit is used to obtain a custom configuration request, wherein the custom configuration request includes login information.
[0105] The unit for sending the area to be selected is used to send the list of areas to be selected if the login information is verified.
[0106] The target area acquisition unit is used to acquire user selection information based on the list of areas to be selected and collect a predetermined number of configuration images, and acquire the target area in each configuration image according to the user selection information.
[0107] The custom feature vector acquisition unit is used to extract the feature vector of the target area in each configuration image and calculate the mean value of the feature vector of the target area to obtain the custom feature vector.
[0108] Furthermore, the face recognition device provided by the embodiment of the present invention also includes a re-verification module. Optionally, the re-verification module includes: a matching times counting unit, a matching stop unit, an image re-acquisition unit, a similarity recalculation unit, a first return execution unit and a second return execution unit.
[0109] The matching number counting unit is used to count the matching failure times of the target user identification within a preset time if the recognition result is a matching failure, and to determine whether the matching failure times within the preset time have reached a times threshold.
[0110] The stop matching unit is used to terminate the matching if the number of matching failures reaches a threshold within a preset time, and send a prompt message according to the target user identifier.
[0111] The image re-acquisition unit is used to send an image acquisition request and acquire a new image to be identified if the number of matching failures within a preset time does not reach a number threshold.
[0112] The similarity recalculation unit is used to extract a new feature vector to be identified of a new image to be identified, and calculate the feature similarity between the new feature vector to be identified and a reference feature vector corresponding to the target user identifier.
[0113] The first return execution unit is used for returning to execute, if the feature similarity is greater than or equal to a similarity threshold, obtaining a target area in the image to be identified according to the target user identifier, and extracting a target feature vector according to the target area.
[0114] The second return execution unit is used to return to execute statistics of the number of matching failures of the target user identifier within a preset time if the feature similarity is less than the similarity threshold, and determine whether the number of matching failures of the target user identifier within the preset time reaches the number threshold.
[0115] For the specific definition of the face recognition device, please refer to the definition of the face recognition method above, which will not be repeated here. Each module in the above face recognition device can be implemented in whole or in part by software, hardware and their combination. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0116] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store feature similarity algorithms, baseline feature vectors, user identifiers and custom feature vectors, etc. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a face recognition method is implemented.
[0117] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0118] Acquire an image to be identified, and extract a feature vector to be identified according to the image to be identified;
[0119] Obtaining feature similarity between the feature vector to be identified and each reference feature vector;
[0120] The user ID corresponding to the benchmark feature vector with the highest feature similarity is used as the target user ID;
[0121] Acquire a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area;
[0122] The vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier is calculated, and the recognition result is obtained according to the vector similarity.
[0123] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0124] Acquire an image to be identified, and extract a feature vector to be identified according to the image to be identified;
[0125] Obtaining feature similarity between the feature vector to be identified and each reference feature vector;
[0126] The user ID corresponding to the benchmark feature vector with the highest feature similarity is used as the target user ID;
[0127] Acquire a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area;
[0128] The vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier is calculated, and the recognition result is obtained according to the vector similarity.
[0129] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0130] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0131] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A face recognition method, characterized in that: include: Acquire an image to be identified, and extract a feature vector to be identified based on the image to be identified; Obtaining feature similarity between the feature vector to be identified and each reference feature vector; The user ID corresponding to the benchmark feature vector with the highest feature similarity is used as the target user ID; Acquire a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area; Calculating the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier, and obtaining a recognition result according to the vector similarity; Before the step of acquiring a target area in the image to be recognized according to the target user identifier and extracting a target feature vector according to the target area, the face recognition method further includes: Obtaining a custom configuration request, wherein the custom configuration request includes login information; If the login information is verified, a list of areas to be selected is sent; Based on the list of areas to be selected, user selection information is obtained and a predetermined number of configuration images are collected, and a target area in each configuration image is obtained according to the user selection information; The feature vector of the target area in each configuration image is extracted and the mean value of the feature vector of the target area is calculated to obtain a custom feature vector.
2. The face recognition method according to claim 1, characterized in that: The obtaining of the recognition result according to the vector similarity includes: If the vector similarity is greater than or equal to the reference threshold, outputting a successful matching recognition result; If the vector similarity is less than the reference threshold, a recognition result indicating a failed match is output.
3. The face recognition method according to claim 2, characterized in that: After calculating the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier and obtaining the recognition result according to the vector similarity, the face recognition method further includes: If the recognition result is a match failure, then counting the number of match failures of the target user identifier within a preset time, and determining whether the number of match failures within the preset time reaches a number threshold; If the number of matching failures reaches a threshold within a preset time, the matching ends and a prompt message is sent according to the target user identifier; If the number of matching failures within the preset time does not reach the number threshold, an image acquisition request is sent to obtain a new image to be identified; Extracting a new feature vector to be identified of the new image to be identified, and calculating a feature similarity between the new feature vector to be identified and a reference feature vector corresponding to the target user identifier; If the feature similarity is greater than or equal to the similarity threshold, returning to the step of acquiring the target area in the image to be identified according to the target user identifier, and extracting the target feature vector according to the target area; If the feature similarity is less than the similarity threshold, the step of returning to the step of counting the number of matching failures of the target user identifier within the preset time and determining whether the number of matching failures within the preset time reaches the number threshold is executed.
4. The face recognition method according to claim 1, characterized in that: The obtaining of the feature similarity between the feature vector to be identified and each reference feature vector includes: The feature similarity between the feature vector to be identified and the reference feature vector is calculated using the Euclidean distance algorithm: Among them, U is the feature vector to be identified, V is the reference feature vector, is the feature similarity between U and V.
5. The face recognition method according to claim 1, characterized in that: Before the step of using the user identifier corresponding to the reference feature vector with the highest feature similarity as the target user identifier, the face recognition method further includes: If the maximum value of the feature similarity is less than the preset similarity threshold, a recognition result indicating recognition failure is output.
6. A face recognition device, characterized in that: include: A feature vector extraction module is used to obtain an image to be identified and extract a feature vector to be identified based on the image to be identified; A feature similarity acquisition module, used to acquire the feature similarity between the feature vector to be identified and each reference feature vector; A user identification acquisition module, used to use the user identification corresponding to the reference feature vector with the highest feature similarity as the target user identification; A target feature vector extraction module, used to obtain a target area in the image to be identified according to the target user identifier, and extract a target feature vector according to the target area; A recognition result acquisition module, used to calculate the vector similarity between the target feature vector and the custom feature vector corresponding to the target user identifier, and obtain the recognition result according to the vector similarity; The face recognition device further includes a user-defined module, which includes a configuration request acquisition unit, a to-be-selected area sending unit, a target area acquisition unit, and a user-defined feature vector acquisition unit; The configuration request acquisition unit is used to acquire a custom configuration request, wherein the custom configuration request includes login information; The to-be-selected area sending unit is configured to send a to-be-selected area list if the login information verification passes; The target area acquisition unit is used to acquire user selection information based on the list of areas to be selected and collect a predetermined number of configuration images, and acquire the target area in each configuration image according to the user selection information; The custom feature vector acquisition unit is used to extract the feature vector of the target area in each configuration image and calculate the mean value of the feature vector of the target area to obtain the custom feature vector.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the face recognition method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the face recognition method according to any one of claims 1 to 5 are implemented.
