Disclosure of Invention
The embodiment of the application aims to provide an identity authentication method, an identity authentication device, identity authentication equipment and a storage medium based on face recognition, so as to solve the problem of identity authentication failure caused by difficulty in recognition of an identity card image.
In order to solve the above technical problem, an embodiment of the present application provides an identity authentication method based on face recognition, which adopts the following technical scheme:
acquiring an identity card image to be verified and a first face image to be verified;
extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to a preset template by using the key information;
retrieving a preset face reference image library according to the identity card file to obtain a face reference image of the identity card image to be verified;
and calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value.
Further, before the step of extracting key information of the to-be-verified identity card image, where the key information at least includes one of a user name, an identity card number, or a face feature, the step of generating an identity card file according to a preset template with the key information further includes:
inputting the identity card image to be verified into a pre-trained neural network model, and obtaining an image recognition result output by the neural network model in response to the identity card image to be verified, wherein the image recognition result is an identity card image or a non-identity card image;
and when the image recognition result is a non-identity card image, returning an identity card image verification failure message.
Further, the step of extracting key information of the to-be-verified identity card image, where the key information at least includes one of a user name, an identity card number, or a face feature, and the step of generating an identity card file from the key information according to a preset template includes:
inputting the identity card image to be verified into a preset OCR-based character recognition model, and obtaining character information output by the OCR-based character recognition model in response to the identity card image to be verified;
and generating an identity card file according to the text information according to a preset template.
Further, the step of extracting key information of the to-be-verified identity card image, where the key information at least includes one of a user name, an identity card number, or a face feature, and the step of generating an identity card file from the key information according to a preset template includes:
inputting the identity card image to be verified into a preset image feature extraction model, and obtaining the human face feature output by the image feature extraction model in response to the identity card image to be verified;
and generating an identity card file according to the face features according to a preset template.
Further, the step of retrieving a preset face reference image library according to the identification card file to obtain the face reference image of the identification card image to be verified includes:
reading the face features in the identity card file, and respectively calculating the feature similarity between the face features and each face image in the face reference image library;
and comparing the feature similarities with a preset second threshold value, and determining that the face image corresponding to the maximum value of the feature similarities larger than or equal to the second threshold value is a face reference image of the identity card image to be verified.
Further, each face reference image in the preset face reference image library includes N sub-images, the similarity between the first face image to be verified and the face reference image is calculated, and when the similarity is greater than or equal to a preset first threshold, the step of passing identity verification includes:
and respectively calculating the similarity between the first face image to be verified and the N sub-images, and passing identity verification when one of the similarity between the face image to be verified and the N images is greater than or equal to a set first threshold value.
Further, when the similarity between the first face image to be verified and the face reference image is calculated and the similarity is greater than or equal to a preset first threshold, the step of passing identity verification includes:
when the similarity is smaller than the first threshold value, acquiring a second face image to be verified;
and calculating a second similarity of the second face image to be verified and the face reference image, passing the identity verification when the second similarity is greater than or equal to a preset first threshold, and otherwise, returning an identity verification failure message.
In order to solve the above technical problem, an embodiment of the present application further provides an identity authentication device based on face recognition, which adopts the following technical scheme:
the system comprises an acquisition module, a verification module and a verification module, wherein the acquisition module is used for acquiring an identity card image to be verified and a first face image to be verified;
the generating module is used for extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or a face feature, and the key information is used for generating an identity card file according to a preset template;
the retrieval module is used for retrieving a preset face reference image library according to the identity card file and acquiring a face reference image of the identity card image to be verified;
and the processing module is used for calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value.
Further, the identity authentication device based on face recognition further comprises:
the first identification submodule is used for inputting the identity card image to be verified into a pre-trained neural network model and obtaining an image identification result output by the neural network model in response to the identity card image to be verified, wherein the image identification result is an identity card image or a non-identity card image;
and the first processing submodule is used for returning an identity card image verification failure message when the image recognition result is a non-identity card image, and otherwise, turning to the generation module.
Further, the generating module includes:
the second recognition submodule is used for inputting the identity card image to be verified into a preset OCR-based character recognition model and obtaining character information output by the OCR-based character recognition model in response to the identity card image to be verified;
and the first generating submodule is used for generating the identity card file by the text information according to a preset template.
Further, the generating module further comprises:
the first extraction submodule is used for inputting the identity card image to be verified into a preset image feature extraction model and obtaining the human face features output by the image feature extraction model in response to the identity card image to be verified;
and the second generation submodule is used for generating the identity card file by the face features according to a preset template.
Further, the retrieval module comprises:
the first calculation submodule is used for reading the face features in the identity card file and respectively calculating the feature similarity between the face features and each face image in the face reference image library;
and the first processing submodule is used for comparing the feature similarities with a preset second threshold value and determining that the face image corresponding to the maximum value of the feature similarities, which is greater than or equal to the second threshold value, is the face reference image of the identity card image to be verified.
Further, each of the face reference images in the preset face reference image library includes N sub-images, and the processing module includes:
and the second processing submodule is used for respectively calculating the similarity between the first face image to be verified and the N sub-images, and when one of the similarity between the face image to be verified and the N images is greater than or equal to a set first threshold value, passing the identity verification.
Further, the processing module further includes:
the first obtaining submodule is used for obtaining a second face image to be verified when the similarity is smaller than the first threshold;
and the third processing submodule is used for calculating a second similarity between the second face image to be verified and the face reference image, and when the second similarity is greater than or equal to a preset first threshold value, the identity verification is passed, otherwise, an identity verification failure message is returned.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:
a computer device comprises a memory and a processor, wherein the memory stores computer readable instructions, and the processor realizes the steps of the identity authentication method based on face recognition when executing the computer readable instructions
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:
a computer readable storage medium, having computer readable instructions stored thereon, which when executed by a processor, implement the steps of the above-mentioned identity authentication method based on face recognition.
Compared with the prior art, the embodiment of the application mainly has the following beneficial effects: obtaining an identity card image to be verified and a first face image to be verified; extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to a preset template by using the key information; retrieving a preset face reference image library according to the identity card file to obtain a face reference image of the identity card image to be verified; and calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value. The face reference image can be retrieved only by requiring partial information of the identity card photo to be available, such as one of a user name, a card number or face image characteristics, the requirement on the identity card image is low, the probability of identity authentication failure caused by the fact that the identity card is old or the image shooting is not satisfactory is reduced, and the efficiency of services needing identity authentication is improved.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
As shown in fig. 1, thesystem architecture 100 may includeterminal devices 101, 102, 103, anetwork 104, and aserver 105. Thenetwork 104 serves as a medium for providing communication links between theterminal devices 101, 102, 103 and theserver 105.Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use theterminal devices 101, 102, 103 to interact with theserver 105 via thenetwork 104 to receive or send messages or the like. Theterminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
Theterminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
Theserver 105 may be a server providing various services, such as a background server providing support for pages displayed on theterminal devices 101, 102, 103.
It should be noted that the identity authentication method based on face recognition provided by the embodiments of the present application generally consists ofServiceDevice/terminal equipmentThe authentication device based on face recognition is generally arranged to perform, correspondingly, face recognitionServer/terminal deviceIn (1).
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continuing reference to FIG. 2, a flow diagram of one embodiment of a method of face recognition based authentication in accordance with the present application is shown. The identity authentication method based on face recognition comprises the following steps:
step S201, an identity card image to be verified and a first face image to be verified are obtained.
In the embodiment, an electronic device (for example, the electronic device shown in fig. 1) on which an identity authentication method based on face recognition is operatedServer/terminal device) The authentication request may be received through a wired connection or a wireless connection. It should be noted that the wireless connection means may include, but is not limited to, a 3G/4G connection, a WiFi connection, a bluetooth connection, a WiMAX connection, a Zigbee connection, a uwb (ultra wideband) connection, and other wireless connection means now known or developed in the future.
The method comprises the steps of shooting an identity card image to be verified and a first face image to be verified through electronic equipment with a camera. The identity card image to be verified can also be a file stored in the electronic storage device, and the identity card image to be verified is obtained by reading the file in which the identity card image to be verified is stored.
Step S202, extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to the key information according to a preset template.
In this embodiment, the key information of the identification card image to be verified at least includes one of a user name, an identification card number, and a face image feature. The method comprises the steps of extracting key information from an identity card image to be verified, generating an identity card file according to a preset template, wherein the preset template at least comprises fields of a user name, an identity card number and a face image characteristic, writing the extracted key information into the corresponding fields, digitizing the original identity card image to be verified through the steps, only keeping the key information, only requiring that one of the user name, the identity card number and the face image can be identified, and having low requirements on the original identity card image to be verified.
Step S203, retrieving a preset human face reference image library according to the identity card file, and acquiring a human face reference image of the identity card image to be verified.
In this embodiment, in the preset face reference image library, the metadata of each image at least includes one of a user name and an identification number. Each image is taken as a human face reference image of a certain user, is usually collected during identity card transaction and is stored in a database.
And searching the face reference image library by using the information recorded in the identity card file to obtain a face reference image corresponding to the identity card image to be verified.
And step S204, calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value.
In this embodiment, the similarity between the first face image to be verified and the face reference image is calculated by calculating the distance between the feature vectors of the first face image and the face reference image.
Firstly, feature vectors are extracted from the two vectors, a direction gradient histogram-based method can be used for extracting the feature vectors, and then the Euclidean distance between the two feature vectors is calculated, namely:
and x and y are respectively the characteristic vectors of the first face image to be verified and the face reference image.
And comparing the calculated distance between the characteristic vectors with a preset first threshold value, and when the distance is greater than or equal to the first threshold value, considering that the identity card image to be verified and the first face image to be verified belong to the same user, namely the identity card is consistent, and passing the identity verification.
The method comprises the steps of obtaining an identity card image to be verified and a first face image to be verified; extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to a preset template by using the key information; retrieving a preset face reference image library according to the identity card file to obtain a face reference image of the identity card image to be verified; and calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value. The face reference image can be retrieved only by requiring partial information of the identity card photo to be available, such as one of a user name, a card number or face image characteristics, the requirement on the identity card image is low, the probability of identity authentication failure caused by the fact that the identity card is old or the image shooting is not satisfactory is reduced, and the efficiency of services needing identity authentication is improved.
In some optional implementation manners of this embodiment, after step S201 and before step S202, the electronic device may further perform the following steps:
inputting the identity card image to be verified into a pre-trained neural network model, and obtaining an image recognition result output by the neural network model in response to the identity card image to be verified, wherein the image recognition result is an identity card image or a non-identity card image;
and when the image identification result is a non-identity card image, returning an identity card image verification failure message, otherwise, continuing to the step S202.
In the embodiment, the pre-trained neural network model is used for identifying the identity card image to be verified and judging whether the identity card image is the identity card image.
The neural network can adopt a convolution neural network model, the training process of the neural network model comprises the steps of preparing training samples, wherein the training samples comprise identity card images and non-identity card images, marking whether each sample is an identity card image or not, inputting the training samples into the neural network model, adjusting parameters of each node of the neural network, enabling the prediction result of the neural network to be consistent with the marked result, and finishing training.
According to the embodiment, whether the acquired identity card image to be verified is the identity card image or not is judged, the verification process is ended in advance when the acquired identity card image to be verified is judged to be the non-identity card image, and the verification efficiency is improved.
In some optional implementations of this embodiment, step S202 includes:
inputting the identity card image to be verified into a preset OCR-based character recognition model, and obtaining character information output by the OCR-based character recognition model in response to the identity card image to be verified;
and generating an identity card file according to the text information according to a preset template.
In the above embodiment, the character information in the identification card image to be verified, such as the user name, the identification card number, the address and other character information, is recognized through the character recognition model based on the OCR.
OCR (Optical Character Recognition) refers to a process in which an electronic device (e.g., a scanner or a digital camera) examines a Character printed on paper, determines its shape by detecting dark and light patterns, and then translates the shape into a computer text using a Character Recognition method. The process of recognizing the characters based on the OCR character recognition model comprises the following steps: graying an identity card image to be verified to obtain a grayscale image; binarization, namely converting a gray image into a black-and-white image, setting the gray value of a pixel point to be 255 (namely white) by setting a gray threshold value, and setting the gray value of the pixel point to be 0 (namely black) if the gray value of the pixel point is smaller than the set threshold value; and then, dividing the obtained black-and-white image to obtain an image block only containing one character, extracting the feature vector of the image block to match with a preset feature template library, and identifying the character, wherein the character string forms character information.
And writing the recognized text information into corresponding fields in a preset template according to the preset template to generate an identity card file.
The embodiment extracts the character information in the identity card image to be verified, and utilizes the character information to search the preset human face reference image library, so that the searching calculation amount is small.
Referring to fig. 3, in some alternative implementations of the present embodiment, step S202 includes:
step S301, inputting the identity card image to be verified into a preset image feature extraction model, and obtaining the human face feature output by the image feature extraction model in response to the identity card image to be verified;
step S302, generating an identity card file according to the human face features according to a preset template.
In the above embodiment, the preset image feature extraction model is used to extract the face features in the to-be-verified identification card image, the preset image feature extraction model may adopt an image feature extraction method based on a direction gradient histogram method, and the specific algorithm includes:
1) graying, namely, regarding an image as a three-dimensional image of x, y and z (gray level);
2) standardizing the color space of the input image by using a Gamma correction method; the method aims to adjust the contrast of the image, reduce the influence caused by local shadow and illumination change of the image and inhibit the interference of noise;
3) calculating the gradient of each pixel of the image, including the magnitude and the direction; mainly for capturing contour information while further attenuating the interference of illumination.
4) Dividing the image into small squares, e.g. 6 x 6 pixels/square;
5) counting the gradient histogram of each small square to form a descriptor of each small square;
6) and combining the feature descriptors of all the small blocks in a large square block to obtain the feature descriptor based on the histogram of oriented gradient of the large block.
7) And (4) connecting the feature description substrings based on the directional gradient histogram of all the large blocks in the image to obtain a feature vector based on the directional gradient histogram of the image.
And writing the facial features extracted by the image feature extraction model into a facial feature field in a template according to a preset template to generate an identity card file.
In the embodiment, the identity can be verified when the characters in the identity card image to be verified are not easy to identify by extracting the face features in the identity card image to be verified and searching the preset face reference image library through the face features.
In some optional implementation manners of this embodiment, if step S202 includes inputting the to-be-verified identity card image into a preset image feature extraction model, obtaining a face feature output by the image feature extraction model in response to the to-be-verified identity card image; and generating an identity card file according to the face features according to a preset template. Step S203 includes:
reading the face features in the identity card file, and respectively calculating the feature similarity between the face features and each face image in the face reference image library;
and comparing the feature similarities with a preset second threshold value, and determining that the face image corresponding to the maximum value of the feature similarities larger than or equal to the second threshold value is a face reference image of the identity card image to be verified.
In the above embodiment, the retrieval of the face reference image database is implemented by calculating the feature similarity between the face features and each face image in the face reference image database, and the face features are distributed to multiple computers for parallel computation by using a typical mapping-reduction (Map-Reduce) frame, so as to obtain the super-strong computing power. Outputting the similarity degree of the human face features and each human face image in the human face reference image library and corresponding personnel identity information; and then, comparing the recognition result with a preset second threshold value through a reduction process, then sequencing according to the similarity degree, and taking the image with the maximum similarity degree as a face reference image of the identity card image to be verified.
In the embodiment, the face reference image corresponding to the identity card image to be verified is obtained by calculating the feature similarity between the face features in the identity card image and the face images in the face reference image library, and when the text information of the identity card image to be verified is not easy to identify, the corresponding face reference image can be still retrieved for identity verification.
In some optional implementation manners of this embodiment, each of the face reference images in the preset face reference image library includes N sub-images, and step S204 further includes:
and respectively calculating the similarity between the first face image to be verified and the N sub-images, and passing identity verification when one of the similarity between the face image to be verified and the N images is greater than or equal to a set first threshold value.
In the above embodiment, the preset face reference image in the face reference image library includes multi-angle sub-images of a face of the same object, and when the similarity between the first face image to be verified and the face reference image is calculated, the similarity between the first face image to be verified and each sub-image is calculated, and as long as the similarity between the first face image to be verified and each sub-image is greater than or equal to the set first threshold, the identity verification is passed.
By comparing the similarity with the sub-images at different angles, the requirement of the authentication process on the face image shot by the user is low, and the fault tolerance of the authentication is improved.
In some optional implementations of this embodiment, step S204 includes:
when the similarity is smaller than the first threshold value, acquiring a second face image to be verified;
and calculating a second similarity of the second face image to be verified and the face reference image, passing the identity verification when the second similarity is greater than or equal to a preset first threshold, and otherwise, returning an identity verification failure message.
In the above embodiment, to further improve the fault tolerance, after the first face identification fails to perform the identity authentication, the second face image to be authenticated is obtained to perform the identity authentication again, the second similarity between the second face image to be authenticated and the face reference image is calculated, when the second similarity is greater than or equal to the preset first threshold, the identity authentication is passed, otherwise, an identity authentication failure message is returned. And the second face image is a face image shot by the same person for the second time.
It should be emphasized that, in order to further ensure the privacy and security of the user identity and the face feature information, the user identity and the face feature information may also be stored in a node of a block chain.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware associated with computer readable instructions, which can be stored in a computer readable storage medium, and when executed, the processes of the embodiments of the methods described above can be included. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 4, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an identity authentication apparatus based on face recognition, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 4, the identity authentication apparatus 400 for face recognition according to this embodiment includes: anacquisition module 401, ageneration module 402, aretrieval module 403 and aprocessing module 404. Wherein:
the obtainingmodule 401 is configured to obtain an identity card image to be verified and a first face image to be verified;
thegenerating module 402 is configured to extract key information of the to-be-verified identity card image, where the key information at least includes one of a user name, an identity card number, or a face feature, and generate an identity card file from the key information according to a preset template;
theretrieval module 403 is configured to retrieve a preset face reference image library according to the identification card file, and obtain a face reference image of the identification card image to be verified;
theprocessing module 404 is configured to calculate a similarity between the first face image to be verified and the face reference image, and pass identity verification when the similarity is greater than or equal to a preset first threshold.
In the embodiment, an identity card image to be verified and a first face image to be verified are obtained; extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to a preset template by using the key information; retrieving a preset face reference image library according to the identity card file to obtain a face reference image of the identity card image to be verified; and calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value. The face reference image can be retrieved only by requiring partial information of the identity card photo to be available, such as one of a user name, a card number or face image characteristics, the requirement on the identity card image is low, the probability of identity authentication failure caused by the fact that the identity card is old or the image shooting is not satisfactory is reduced, and the efficiency of services needing identity authentication is improved.
Further, the identity authentication device based on face recognition further comprises:
the first identification submodule is used for inputting the identity card image to be verified into a pre-trained neural network model and obtaining an image identification result output by the neural network model in response to the identity card image to be verified, wherein the image identification result is an identity card image or a non-identity card image;
the first processing sub-module is configured to return an authentication failure message of the identity card image when the image recognition result is a non-identity card image, and otherwise, go to thegenerating module 402.
Further, thegenerating module 402 includes:
the second recognition submodule is used for inputting the identity card image to be verified into a preset OCR-based character recognition model and obtaining character information output by the OCR-based character recognition model in response to the identity card image to be verified;
and the first generating submodule is used for generating the identity card file by the text information according to a preset template.
Further, thegenerating module 402 further includes:
the first extraction submodule is used for inputting the identity card image to be verified into a preset image feature extraction model and obtaining the human face features output by the image feature extraction model in response to the identity card image to be verified;
and the second generation submodule is used for generating the identity card file by the face features according to a preset template.
Further, the retrievingmodule 403 includes:
the first calculation submodule is used for reading the face features in the identity card file and respectively calculating the feature similarity between the face features and each face image in the face reference image library;
and the first processing submodule is used for comparing the feature similarities with a preset second threshold value and determining that the face image corresponding to the maximum value of the feature similarities, which is greater than or equal to the second threshold value, is the face reference image of the identity card image to be verified.
Further, each of the face reference images in the preset face reference image library includes N sub-images, and theprocessing module 404 includes:
and the second processing submodule is used for respectively calculating the similarity between the first face image to be verified and the N sub-images, and when one of the similarity between the face image to be verified and the N images is greater than or equal to a set first threshold value, passing the identity verification.
Further, theprocessing module 404 further includes:
the first obtaining submodule is used for obtaining a second face image to be verified when the similarity is smaller than the first threshold;
and the third processing submodule is used for calculating a second similarity between the second face image to be verified and the face reference image, and when the second similarity is greater than or equal to a preset first threshold value, the identity verification is passed, otherwise, an identity verification failure message is returned.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 5, fig. 5 is a block diagram of a basic structure of a computer device according to the present embodiment.
Thecomputer device 5 comprises amemory 51, aprocessor 52, anetwork interface 53 communicatively connected to each other via a system bus. It is noted that only acomputer device 5 having components 51-53 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
Thememory 51 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. The readable storage medium may be non-volatile or volatile. In some embodiments, thememory 51 may be an internal storage unit of thecomputer device 5, such as a hard disk or a memory of thecomputer device 5. In other embodiments, thememory 51 may also be an external storage device of thecomputer device 5, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on thecomputer device 5. Of course, thememory 51 may also comprise both an internal storage unit of thecomputer device 5 and an external storage device thereof. In this embodiment, thememory 51 is generally used for storing an operating system installed in thecomputer device 5 and various types of application software, such as computer readable instructions of an identity authentication method based on face recognition. Further, thememory 51 may also be used to temporarily store various types of data that have been output or are to be output.
Theprocessor 52 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. Theprocessor 52 is typically used to control the overall operation of thecomputer device 5. In this embodiment, theprocessor 52 is configured to execute computer readable instructions stored in thememory 51 or process data, for example, execute computer readable instructions of the identity authentication method based on face recognition.
Thenetwork interface 53 may comprise a wireless network interface or a wired network interface, and thenetwork interface 53 is generally used for establishing communication connections between thecomputer device 5 and other electronic devices.
Obtaining an identity card image to be verified and a first face image to be verified; extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to a preset template by using the key information; retrieving a preset face reference image library according to the identity card file to obtain a face reference image of the identity card image to be verified; and calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value. The face reference image can be retrieved only by requiring partial information of the identity card photo to be available, such as one of a user name, a card number or face image characteristics, the requirement on the identity card image is low, the probability of identity authentication failure caused by the fact that the identity card is old or the image shooting is not satisfactory is reduced, and the efficiency of services needing identity authentication is improved.
The present application further provides another embodiment, which is to provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, which can be executed by at least one processor, so as to cause the at least one processor to execute the steps of the identity authentication method based on face recognition as described above.
Obtaining an identity card image to be verified and a first face image to be verified; extracting key information of the identity card image to be verified, wherein the key information at least comprises one of a user name, an identity card number or human face characteristics, and generating an identity card file according to a preset template by using the key information; retrieving a preset face reference image library according to the identity card file to obtain a face reference image of the identity card image to be verified; and calculating the similarity between the first face image to be verified and the face reference image, and passing the identity verification when the similarity is greater than or equal to a preset first threshold value. The face reference image can be retrieved only by requiring partial information of the identity card photo to be available, such as one of a user name, a card number or face image characteristics, the requirement on the identity card image is low, the probability of identity authentication failure caused by the fact that the identity card is old or the image shooting is not satisfactory is reduced, and the efficiency of services needing identity authentication is improved.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.