Face detection method, device, equipment and medium based on artificial intelligence

Through the combination of depth images and RGB images, the depth value and gradient histogram matching technology is used to solve the problem of low face detection accuracy in the existing technology and improve the safety and accuracy of the face detection system.

CN113688768BActive Publication Date: 2024-10-25CHINA PING AN LIFE INSURANCE CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202111017172.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-31
Publication Date
2024-10-25
Estimated Expiration
2041-08-31

AI Technical Summary

Technical Problem

Existing face detection methods have low detection accuracy, resulting in poor security of the face detection system and the inability to effectively distinguish between real faces and flat photos.

Method used

By obtaining the depth image and RGB image of the face to be detected, the depth value is used for preliminary detection to determine whether it is a flat image; if it is not a flat image, multiple RGB images are obtained for further detection, combined with gradient histogram matching, to improve detection accuracy degree and efficiency.

Benefits of technology

It significantly improves the detection accuracy and efficiency of face detection, enhances the security of the face detection system, and can effectively distinguish real faces and flat photos.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113688768B_ABST
    Figure CN113688768B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of artificial intelligence technology, and provides a method, device, equipment and medium for face detection based on artificial intelligence, including: obtaining a first depth image and a first RGB image of a face to be detected; detecting a first face area in the first RGB image; obtaining a depth value corresponding to a second face area in the first depth image; performing a first face detection according to the depth value corresponding to the second face area to obtain an initial detection result; if the initial detection result indicates that the first RGB image is not a flat photo, obtaining an image set; performing a second face detection according to the image set to obtain a final detection result. Through the above method, the detection accuracy of the face detection method can be effectively improved, thereby improving the security of the face detection system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence technology, and in particular, relates to an artificial intelligence-based face detection method, device, equipment and medium. Background Art

[0002] In recent years, artificial intelligence technology has made rapid progress and its applications have become more and more extensive. Face detection is an important application of artificial intelligence technology and is widely used in fields such as face attendance and identity verification.

[0003] Existing face detection methods usually identify collected face images, but cannot identify whether the collected face images are images of real faces captured by the camera. In an application scenario, user A places a face photo of user B in front of the camera, and the camera captures the face image of user B. After verification through face detection, user A can log in to user B's account. It can be seen that the detection accuracy of existing face detection methods is low, resulting in poor security of face detection systems. Summary of the invention

[0004] The embodiments of the present application provide a face detection method, device, equipment and medium based on artificial intelligence, which can effectively improve the detection accuracy of the face detection method and thereby improve the security of the face detection system.

[0005] In a first aspect, an embodiment of the present application provides a face detection method based on artificial intelligence, comprising:

[0006] Acquire a first depth image and a first RGB image of a face to be detected;

[0007] Detecting a first face region in the first RGB image;

[0008] Obtaining a depth value corresponding to a second face region in the first depth image, where the second face region is an image region corresponding to the first face region;

[0009] Performing a first face detection according to the depth value corresponding to the second face area to obtain an initial detection result;

[0010] If the initial detection result indicates that the first RGB image is not a planar photo, obtaining an image set, wherein the image set includes a plurality of second RGB images of the face to be detected taken within a preset time;

[0011] A second face detection is performed based on the image set to obtain a final detection result.

[0012] In the embodiment of the present application, a preliminary detection is first performed based on the depth value of the face area, that is, whether it is a plane image is determined based on the change in the depth value of the face area; if it is not a plane image, further detection is performed based on multiple RGB images. Through two detections, the detection accuracy of face detection is effectively improved. In addition, through preliminary detection, plane images can be excluded in advance, and no subsequent further detection is required, which effectively improves the efficiency of face detection.

[0013] In a possible implementation manner of the first aspect, obtaining a depth value corresponding to the second face region in the first depth image includes:

[0014] Mapping the first face region to the first depth image to obtain an image region in the first depth image corresponding to the first face region;

[0015] Determine an image area corresponding to the first face area in the first depth image as the second face area;

[0016] Obtain a depth value corresponding to the second face region.

[0017] In a possible implementation manner of the first aspect, mapping the first face region to the first depth image to obtain an image region in the first depth image corresponding to the first face region includes:

[0018] Obtaining a mapping coefficient between the first depth image and the first RGB image;

[0019] Mapping each pixel point in the first face region to the first depth image according to the mapping coefficient to obtain a mapping point of each pixel point in the first face region in the first depth image;

[0020] The obtained region formed by the mapping points is determined as an image region in the first depth image corresponding to the first face region.

[0021] In a possible implementation manner of the first aspect, performing a first face detection according to the depth value corresponding to the second face region to obtain an initial detection result includes:

[0022] dividing the second face region into a plurality of organ regions according to the depth value corresponding to the second face region;

[0023] If there are any two organ regions that meet a preset condition, the initial detection result indicates that the first RGB image is a planar image, wherein the preset condition is that the difference in depth values ​​between the two organ regions is within a preset range;

[0024] If there are no two organ regions that meet the preset condition, the initial detection result indicates that the first RGB image is not a planar image.

[0025] In a possible implementation manner of the first aspect, performing a second face detection according to the image set to obtain a final detection result includes:

[0026] Dividing the second RGB image in the image set into a plurality of sub-regions;

[0027] Counting the gradient histogram of each sub-region in the second RGB image;

[0028] determining whether the second RGB image matches a preset reference image according to a gradient histogram of each of the sub-regions in the second RGB image;

[0029] If the second RGB image matches the reference image, determining the second RGB image as the target image;

[0030] The final detection result is determined according to the number of the target images in the image set.

[0031] In a possible implementation manner of the first aspect, determining whether the second RGB image matches a preset reference image according to a gradient histogram of each sub-region in the second RGB image includes:

[0032] If the gradient histogram of the first sub-region and the second sub-region Figure 1 if the first sub-region is the target sub-region, the first sub-region is determined as a target sub-region, wherein the first sub-region is any sub-region in the second RGB image, and the second sub-region is a sub-region in the reference image corresponding to the first sub-region;

[0033] Counting the number of the target sub-regions in the second RGB image;

[0034] If the ratio of the number of the target sub-regions in the second RGB image to the total number of sub-regions in the second RGB image is greater than a preset ratio, it is determined that the second RGB image matches the reference image.

[0035] In a possible implementation manner of the first aspect, determining the final detection result according to the number of the target images in the image set includes:

[0036] If the ratio of the number of the target images in the image set to the total number of the second RGB images in the image set is greater than a preset ratio, the final detection result indicates that the detection is passed;

[0037] If the ratio of the number of the target images in the image set to the total number of the second RGB images in the image set is less than or equal to a preset ratio, the final detection result indicates that the detection has failed.

[0038] In a possible implementation manner of the first aspect, before obtaining the depth value corresponding to the second face area in the first depth image, the method further includes:

[0039] Acquire a second depth image and a third RGB image of the target object;

[0040] Counting the gradient images of the second depth image and the third RGB image respectively;

[0041] Searching for a fourth sub-region matching the third sub-region, wherein the third sub-region is any sub-region in the gradient map of the second depth image, and the fourth region is a sub-region in the gradient map of the third RGB image;

[0042] The mapping coefficient is calculated according to the center point of the third sub-region and the center point of the fourth sub-region.

[0043] In a second aspect, an embodiment of the present application provides a face detection device based on artificial intelligence, comprising:

[0044] A first acquisition unit, used to acquire a first depth image and a first RGB image of a face to be detected;

[0045] A region detection unit, configured to detect a first face region in the first RGB image;

[0046] a depth acquisition unit, configured to acquire a depth value corresponding to a second face region in the first depth image, where the second face region is an image region corresponding to the first face region;

[0047] an initial detection unit, configured to perform a first face detection according to the depth value corresponding to the second face area, and obtain an initial detection result;

[0048] A second acquisition unit is configured to acquire an image set if the initial detection result indicates that the first RGB image is not a flat photo, wherein the image set includes a plurality of second RGB images of the face to be detected taken within a preset time;

[0049] The final detection unit is used to perform a second face detection based on the image set to obtain a final detection result.

[0050] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the artificial intelligence-based face detection method as described in any one of the first aspects above is implemented.

[0051] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and wherein when the computer program is executed by a processor, the artificial intelligence-based face detection method as described in any one of the above-mentioned first aspects is implemented.

[0052] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the artificial intelligence-based face detection method described in any one of the first aspects above.

[0053] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0055] Figure 1 It is a flowchart of a face detection method based on artificial intelligence provided by an embodiment of the present application;

[0056] Figure 2 is a flowchart of an image calibration method provided in an embodiment of the present application;

[0057] Figure 3 is a structural block diagram of an artificial intelligence-based face detection device provided in an embodiment of the present application;

[0058] Figure 4 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0060] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0061] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting" depending on the context.

[0062] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0063] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.

[0064] See also Figure 1 , is a flow chart of a face detection method based on artificial intelligence provided in an embodiment of the present application. As an example but not a limitation, the method may include the following steps:

[0065] S101, obtaining a first depth image and a first RGB image of a face to be detected.

[0066] In practical applications, a 3D camera can be used to obtain depth images and RGB images. A 3D camera includes a depth camera and an RGB camera. The depth camera and RGB camera need to be calibrated in advance. For specific calibration steps, see Figure 2 The description in the embodiments will not be repeated here.

[0067] S102: Detect a first face region in a first RGB image.

[0068] The embodiments of the present application can acquire, detect and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0069] Optionally, the face area can be detected by machine learning / deep learning methods in artificial intelligence technology. For example, a neural network model can be used for detection (such as RetinaFace convolutional network), and a face detection method based on key points can also be used for detection, etc. The face detection method is not specifically limited in the embodiments of the present application.

[0070] S103: Obtain a depth value corresponding to a second face region in the first depth image.

[0071] The second face region is an image region corresponding to the first face region.

[0072] In the embodiment of the present application, the first depth image may be mapped to the first RGB image, or the first RGB image may be mapped to the first depth image. The details are described in the following embodiments.

[0073] In one embodiment, S103 may include the following steps:

[0074] The first depth image is divided into multiple image areas; each image area is mapped into the first RGB image to obtain multiple mapping areas in the first RGB image; the mapping area to which the first face area belongs is determined, and the image area in the first depth image corresponding to the mapping area is determined as the second face area; and the depth value corresponding to the second face area is obtained.

[0075] In another embodiment, S103 may further include the following steps:

[0076] The first face area is mapped to the first depth image to obtain an image area in the first depth image corresponding to the first face area; the image area in the first depth image corresponding to the first face area is determined as the second face area; and a depth value corresponding to the second face area is obtained.

[0077] Optionally, an implementation manner of mapping the first face area into the first depth image may include:

[0078] Obtain a mapping coefficient between the first depth image and the first RGB image; map each pixel in the first face area to the first depth image according to the mapping coefficient, and obtain a mapping point of each pixel in the first face area in the first depth image; determine an area composed of the obtained mapping points as an image area in the first depth image corresponding to the first face area.

[0079] The mapping coefficients may include a scale coefficient and a translation coefficient. For example, assuming that the coordinates of the pixel point A in the face area in the first RGB image are (x A ,y A ), the scale factor is scale, the translation factor is trans, then the coordinates of the mapping point A' that matches A in the first depth image are

[0080] use Figure 2 The calibration method in the embodiment can obtain the mapping coefficient between the depth image and the RGB image, that is, the position of the pixel corresponding to A in the RGB image can be obtained according to the position of the pixel A in the depth image.

[0081] S104, performing a first face detection according to the depth value corresponding to the second face area to obtain an initial detection result.

[0082] In one embodiment, S104 may include the following steps:

[0083] Determine whether the depth value difference between every two adjacent pixels in the second face area of ​​the first depth image is within a preset range; if it is within the preset range, the initial detection result indicates that the first RGB image is a planar image; if it is not within the preset range, the initial detection result indicates that the first RGB image is not a planar image.

[0084] Since a human face includes multiple organs, the depth values ​​of different organs may differ to a certain extent. Therefore, in order to further improve the accuracy of detection. In another embodiment, S104 may include the following steps:

[0085] The second face area is divided into multiple organ areas according to the depth value corresponding to the second face area; if there are any two organ areas that meet the preset conditions, the initial detection result indicates that the first RGB image is a plane image; if there are no two organ areas that meet the preset conditions, the initial detection result indicates that the first RGB image is not a plane image.

[0086] The preset condition is that the difference in depth value between the two organ regions is within a preset range.

[0087] For example, relative to the depth camera, the depth value of the nose is smaller than the depth value of the cheek, and the depth value of the depression of the eye is larger than the depth value of the cheek. The second face area in the first depth image can be segmented according to the depth value to obtain an organ area corresponding to the nose, an organ area corresponding to the eye, and an organ area corresponding to the cheek.

[0088] Existing image segmentation methods may be used to implement region segmentation processing, such as clustering algorithms, neural network algorithms, edge detection algorithms, etc., which are not specifically limited here.

[0089] If the depth camera captures a flat image, then the organs in the face area are in the same plane, so the change in the depth value in the face area captured by the depth camera is not obvious; if the depth camera captures a real face, then the organs in the face area are in different planes, so the change in the depth value in the face area captured by the depth camera is more obvious. Through the above method, it can be determined whether the change in the depth value in the face area is smooth, and then according to the change in the depth value in the face area, it can be determined whether the camera captures a real face or a flat photo.

[0090] S105: If the initial detection result indicates that the first RGB image is not a flat photo, an image set is obtained.

[0091] If the initial detection result indicates that the first RGB image is a flat photo, the final detection result indicates that the detection fails. If the initial detection result indicates that the first RGB image is not a flat photo, a second face detection may be further performed for the accuracy of the detection.

[0092] In the embodiment of the present application, the image set includes a plurality of RGB images captured by a camera at a certain shooting frequency when the face to be detected performs a series of facial movements facing the camera.

[0093] For example, in an application scenario, if the initial detection result indicates that the first RGB image is not a planar image, the terminal device issues a preset instruction, which is used to instruct the user to make corresponding facial movements. For example, the terminal device prompts the user to nod, open the mouth, blink, etc. through a display device, or the terminal device prompts the user to say a sentence through voice, etc. While the user is performing the above facial movements, the RGB camera captures a facial image of the user every 1 second. Assuming that a total of 10 facial images are captured, these 10 facial images are taken as an image set.

[0094] S106, performing a second face detection based on the image set to obtain a final detection result.

[0095] In one embodiment, S106 may include the following steps:

[0096] The gradient histograms of the reference image and each second RGB image in the image set are counted respectively; for any second RGB image, if the gradient histogram of the reference image is inconsistent with the gradient histogram of the current second RGB image, the current second RGB image is determined as the target image; the number of target images in the image set is counted; and the final detection result is determined according to the number of target images.

[0097] The reference image may be any image in the image set, or may be the first RGB image acquired in S101.

[0098] Since the gradient histograms of different regions of the face may be different, in order to further improve the accuracy of detection, in another embodiment, S106 may include the following steps:

[0099] The second RGB image in the image set is divided into a plurality of sub-regions; a gradient histogram of each sub-region in the second RGB image is counted; whether the second RGB image matches a preset reference image is determined according to the gradient histogram of each sub-region in the second RGB image; if the second RGB image matches the reference image, the second RGB image is determined as a target image; and a final detection result is determined according to the number of target images in the image set.

[0100] The sub-region division rule of the reference image is the same as the sub-region division rule of the second RGB image. For example, the reference image can be divided into nine-square grids, and correspondingly, the second RGB image is also divided into nine-square grids according to the same division rule.

[0101] Optionally, one implementation of determining whether the second RGB image matches the reference image may be:

[0102] If the gradient histogram of the first sub-region and the second sub-region Figure 1 If the first sub-region is the same as the reference image, the first sub-region is determined as the target sub-region; the number of target sub-regions in the second RGB image is counted; if the ratio of the number of target sub-regions in the second RGB image to the total number of sub-regions in the second RGB image is greater than a preset ratio, it is determined that the second RGB image matches the reference image.

[0103] The first sub-region is any sub-region in the second RGB image, and the second sub-region is a sub-region in the reference image corresponding to the first sub-region.

[0104] Optionally, an implementation method of determining the final detection result according to the number of target images may be:

[0105] If the ratio of the number of target images in the image set to the total number of second RGB images in the image set is greater than the preset ratio, the final detection result indicates that the detection is passed; if the ratio of the number of target images in the image set to the total number of second RGB images in the image set is less than or equal to the preset ratio, the final detection result indicates that the detection is not passed.

[0106] Optionally, another implementation method of determining the final detection result according to the number of target images may be:

[0107] If the number of target images in the image set is greater than the number of non-target images in the image set, the final detection result indicates that the detection passed; if the number of target images in the image set is less than or equal to the number of non-target images in the image set, the final detection result indicates that the detection failed.

[0108] See also Figure 2 , is a flow chart of the image calibration method provided in the embodiment of the present application. In the embodiment of the present application, it is necessary to pre-calibrate the depth image and the RGB image, that is, to determine the mapping coefficient between the depth image and the RGB image. Figure 2 As shown, the calibration method may include the following steps:

[0109] S201, acquiring a second depth image and a third RGB image of a target object.

[0110] The target object can be any photographed object. In order to improve the accuracy of calibration, face detection is performed in the embodiment of the present application, and the target object can be a face.

[0111] In an application scenario, calibration may be performed in advance, and the calibration coefficients obtained after calibration are stored in the terminal device. When it is necessary to execute S103, the terminal device obtains the pre-stored calibration coefficients.

[0112] In another application scenario, after S101, calibration may be performed based on the first depth image and the first RGB image, that is, the first depth image is used as the second depth image, and the first RGB image is used as the third RGB image.

[0113] S202: Count the gradient images of the second depth image and the third RGB image respectively.

[0114] The gradient map in the embodiment of the present application may be a gradient histogram.

[0115] S203: Search for a fourth sub-region matching the third sub-region.

[0116] The third sub-region is any sub-region in the gradient map of the second depth image, and the fourth region is a sub-region in the gradient map of the third RGB image.

[0117] In the embodiment of the present application, the second depth image and the third RGB image may be pre-divided into a plurality of regions, respectively. For example, the second depth image may be divided into four third regions ROIA1, ROIA2, ROIA3, and ROIA4, and the fourth region ROIB1 matching ROIA1, the fourth region ROIB2 matching ROIA2, the fourth region ROIB3 matching ROIA3, and the fourth region ROIB4 matching ROIA4 may be searched in sequence.

[0118] Optionally, a template matching method with normalized correlation coefficients may be used for region matching.

[0119] Template matching and correlation coefficient method are classic methods for target tracking, which have many advantages: simple and accurate, widely applicable, good noise resistance, and fast calculation speed. The so-called template matching method refers to finding the position of the target template in a frame of an image. The place that is most similar to the template is the target. Just compare all sub-regions of the entire image with the target template and find the sub-region that is most similar to the target template. It is the location of the target. The way to measure the similarity between the sub-region and the target template is to calculate the correlation coefficient between the two.

[0120] In an embodiment of the present application, if a third area matching the fourth area is searched in the second depth image, then the fourth area can be regarded as a target template; if a fourth area matching the third area is searched in the third RGB image, then the third area can be regarded as a target template.

[0121] The correlation coefficient (r) is a mathematical distance that can be used to measure the similarity between two vectors. It originates from the cosine theorem: cos(A) = (a 2 +c 2 -b 2 ) / 2bc. If the angle between two vectors is 0 degrees (r=1), they are completely similar. If the angle is 90 degrees (r=0), they are completely dissimilar. If the angle is 180 degrees (r=-1), they are completely opposite. Write the cosine theorem in vector form: cos(A)=<b,c> / (|b|*|c|), where the numerator represents the inner product of two vectors and the denominator represents the modulus multiplication of two vectors. That is: cos(A) = (b1c1+b2c2+…b n c n ) / sqrt[(b1 2 +b2 2 +…+b n 2 )(c1 2 +c2 2 +…+c n 2 )].

[0122] In practical applications, the more commonly used is the mean correlation coefficient, which is based on the above formula and subtracts the mean of each vector from the numerator and denominator:

[0123]

[0124] In this way, the similar parts of the two vectors are subtracted and their correlation is amplified.

[0125] Assuming the target template is a 10×10 image, it can be regarded as a 100-dimensional vector, where each dimension is the grayscale value of a pixel. Then compare this vector with each sub-region in the image, find the sub-region with the largest correlation coefficient, and the location of the target is found.

[0126] According to the above method, it takes several seconds to find a 30×30 target in a 600×800 image, which is far from meeting the real-time requirements. There are many places where the above formula can be simplified and accelerated. The original formula is transformed into:

[0127]

[0128] The sum of xi and the left half of the denominator are constants and do not need to be calculated every time. The left side of the numerator, yi, and the right side of the denominator can be accelerated by the integral image method. Through the above transformation, the algorithm can be accelerated and the calibration efficiency can be effectively improved.

[0129] When searching, you can use a line-by-line traversal search to calculate each sub-area in the image. In fact, the target often only appears in a very small area, and there is no need to calculate in many places. Therefore, when searching, if the correlation coefficient of the current position is less than a certain threshold or the position is far away from the target center of the previous frame, the search step size can be increased, otherwise the search step size can be reduced. Another search method is to use the target center of the previous frame as the starting point and search for the target using the gradient descent method. There is one thing to note about this method. If the target has a large motion amplitude, it is necessary to use the image pyramid method to search. Both of the above methods can further accelerate the algorithm and achieve further improvement in calibration efficiency.

[0130] The template size is often determined by experience. Templates that closely follow the target outline or contain too much background are not good. The former is too small and too sensitive to changes in the target, which can easily lose the target. The latter is just the opposite. When the target changes, the algorithm does not respond. Generally speaking, the proportion of the target in the template is preferably 30% to 50%.

[0131] S204: Calculate a mapping coefficient according to the center point of the third sub-region and the center point of the fourth sub-region.

[0132] Optionally, an implementation of S204 is:

[0133] Two groups of corresponding areas are obtained, each group of corresponding areas includes a third sub-area and a fourth area corresponding to the third sub-area; and mapping coefficients are calculated according to the center point of the third sub-area and the center point of the fourth sub-area in each group of corresponding areas.

[0134] Specifically, the coordinates of the center point of the third sub-region in the first group of corresponding regions are P11, and the coordinates of the center point of the fourth sub-region are P01; the coordinates of the center point of the third sub-region in the second group of corresponding regions are P12, and the coordinates of the center point of the fourth sub-region are P02. The scale coefficient is: scale = (P02-P01) / (P12-P11), and the translation coefficient is: trans = P01-P11×scale.

[0135] In one embodiment, in order to improve the accuracy of the calibration result, cross validation may be performed. Specifically, after S203, the calibration method may further include:

[0136] Search for a fifth sub-region that matches the fourth sub-region, wherein the fifth sub-region is a region in the gradient map of the second depth image. Calculate the position difference between the center position of the third sub-region and the center position of the fifth sub-region. If the ratio of the number of position differences that meet the preset requirements to the total number of the third sub-regions is greater than the preset ratio, the mapping coefficient between the second depth image and the third RGB image is calculated based on the third sub-region and the fourth sub-region. If the ratio of the number of position differences that meet the preset requirements to the total number of the third sub-regions is less than or equal to the preset ratio, the range of the third sub-region is expanded, and S203 is re-executed to search for a fourth sub-region that matches the expanded third sub-region until the calculated position difference meets the preset requirements, and then the mapping coefficient between the second depth image and the third RGB image is calculated based on the current third sub-region and the fourth sub-region.

[0137] The preset requirement may be that the number of pixels separated is less than a preset value. Exemplarily, the second depth image is divided into four regions ROIA1, ROIA2, ROIA3, and ROIA4. First, according to S203, the fourth sub-region ROIB1 matching ROIA1, the fourth sub-region ROIB2 matching ROIA2, the fourth sub-region ROIB3 matching ROIA3, and the fourth sub-region ROIB4 matching ROIA4 are searched in sequence. Then, the fifth sub-region matching the fourth sub-region ROIB1 is searched in sequence as ROIA1, the fifth sub-region matching the fourth sub-region ROIB2 is searched as ROIA2, the fifth sub-region matching the fourth sub-region ROIB3 is searched as ROIA3, and the fifth sub-region matching the fourth sub-region ROIB4 is searched in sequence as ROIA3. Among them, the third sub-region and the fifth sub-region matching the fourth sub-region ROIB1 are both ROIA1, and the calculated position difference of the center position is 0 (the preset value is 5), which meets the preset requirements; the third sub-region matching the fourth sub-region ROIB4 is ROIA4, and the fifth sub-region is ROIA3, and the number of pixels between the calculated center positions is 10 (the preset value is 5), that is, it does not meet the preset requirements. From the above, it can be seen that there are 3 position differences that meet the preset requirements, and 1 position difference does not meet the preset requirements, that is, the ratio of the number of position differences that meet the preset requirements 3 to the total number of the third sub-regions 4 is 0.75. Assuming the preset ratio is 0.5, then 0.75>0.5, then the mapping coefficient between the second depth image and the second RGB image is calculated based on the third sub-region and the fourth sub-region. Assuming the preset ratio is 0.8, then 0.75<0.8, then expand the range of the third sub-region (that is, re-dividing the second depth image into regions, and the range of the divided third sub-region is larger than the original range of the third sub-region), and then recalculate the position difference.

[0138] It should be understood that the size of the serial numbers of the steps in the above embodiments does not 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 embodiments of the present application.

[0139] Corresponding to the artificial intelligence-based face detection method described in the above embodiment, Figure 3 This is a structural block diagram of an artificial intelligence-based face detection device provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0140] Reference Figure 3 , the device comprises:

[0141] The first acquisition unit 31 is used to acquire a first depth image and a first RGB image of a face to be detected.

[0142] The region detection unit 32 is configured to detect a first face region in the first RGB image.

[0143] The depth acquisition unit 33 is configured to acquire a depth value corresponding to a second face region in the first depth image, where the second face region is an image region corresponding to the first face region.

[0144] The initial detection unit 34 is used to perform a first face detection according to the depth value corresponding to the second face area to obtain an initial detection result.

[0145] The second acquisition unit 35 is configured to acquire an image set if the initial detection result indicates that the first RGB image is not a flat photo, wherein the image set includes a plurality of second RGB images of the face to be detected taken within a preset time.

[0146] The final detection unit 36 ​​is used to perform a second face detection based on the image set to obtain a final detection result.

[0147] Optionally, the depth acquisition unit 33 is further used for:

[0148] Mapping the first face area to the first depth image to obtain an image area in the first depth image corresponding to the first face area; determining the image area in the first depth image corresponding to the first face area as the second face area; and obtaining a depth value corresponding to the second face area.

[0149] Optionally, the depth acquisition unit 33 is further used for:

[0150] Acquire a mapping coefficient between the first depth image and the first RGB image; map each pixel in the first face area to the first depth image according to the mapping coefficient, and obtain a mapping point of each pixel in the first face area in the first depth image; and determine an area composed of the obtained mapping points as an image area in the first depth image corresponding to the first face area.

[0151] Optionally, the initial detection unit 34 is further used for:

[0152] The second face area is divided into multiple organ areas according to the depth value corresponding to the second face area; if there are any two organ areas that meet the preset conditions, the initial detection result indicates that the first RGB image is a planar image, wherein the preset condition is that the difference in depth values ​​between the two organ areas is within a preset range; if there are no two organ areas that meet the preset conditions, the initial detection result indicates that the first RGB image is not a planar image.

[0153] Optionally, the final detection unit 36 ​​is further used for:

[0154] The second RGB image in the image set is divided into a plurality of sub-regions; a gradient histogram of each sub-region in the second RGB image is counted; whether the second RGB image matches a preset reference image is determined according to the gradient histogram of each sub-region in the second RGB image; if the second RGB image matches the reference image, the second RGB image is determined as a target image; and a final detection result is determined according to the number of the target images in the image set.

[0155] Optionally, the final detection unit 36 ​​is further used for:

[0156] If the gradient histogram of the first sub-region and the second sub-region Figure 1 if the first sub-region is consistent with the first sub-region in the second RGB image, the first sub-region is determined as a target sub-region, wherein the first sub-region is any sub-region in the second RGB image, and the second sub-region is a sub-region in the reference image corresponding to the first sub-region; the number of the target sub-regions in the second RGB image is counted; if the ratio of the number of the target sub-regions in the second RGB image to the total number of sub-regions in the second RGB image is greater than a preset ratio, it is determined that the second RGB image and the reference image match.

[0157] Optionally, the final detection unit 36 ​​is further used for:

[0158] If the ratio of the number of target images in the image set to the total number of second RGB images in the image set is greater than a preset ratio, the final detection result indicates that the detection is passed; if the ratio of the number of target images in the image set to the total number of second RGB images in the image set is less than or equal to the preset ratio, the final detection result indicates that the detection is not passed.

[0159] Optionally, the device further comprises:

[0160] The calibration unit 37 is used to obtain a second depth image and a third RGB image of the target object; respectively count the gradient maps of the second depth image and the third RGB image; search for a fourth sub-region matching the third sub-region, wherein the third sub-region is any sub-region in the gradient map of the second depth image, and the fourth region is a sub-region in the gradient map of the third RGB image; and calculate the mapping coefficient according to the center point of the third sub-region and the center point of the fourth sub-region.

[0161] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0162] in addition, Figure 3 The device shown may be a software unit, a hardware unit, or a combination of software and hardware, which is built into an existing terminal device, or may be integrated into the terminal device as an independent accessory, or may exist as an independent terminal device.

[0163] The technicians in the relevant field 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 for illustration. In practical applications, the above-mentioned function allocation can be 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. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0164] Figure 4 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Figure 4 As shown, the terminal device 4 of this embodiment includes: at least one processor 40 ( Figure 4 Only one is shown in the figure) a processor, a memory 41, and a computer program 42 stored in the memory 41 and executable on the at least one processor 40, wherein the processor 40 implements the steps of any of the above-mentioned method embodiments when executing the computer program 42.

[0165] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 4 It is only an example of the terminal device 4 and does not constitute a limitation on the terminal device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.

[0166] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0167] In some embodiments, the memory 41 may be an internal storage unit of the terminal device 4, such as a hard disk or memory of the terminal device 4. In other embodiments, the memory 41 may also be an external storage device of the terminal device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the terminal device 4. The memory 41 is used to store an operating system, an application program, a boot loader, data, and other programs, such as the program code of the computer program. The memory 41 may also be used to temporarily store data that has been output or is to be output.

[0168] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0169] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0170] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0171] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0172] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0173] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0174] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0175] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person 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 application, and should all be included in the protection scope of the present application.

Claims

1. A face detection method based on artificial intelligence, characterized in that: include: Acquire a first depth image and a first RGB image of a face to be detected; Detecting a first face region in the first RGB image; Obtaining a depth value corresponding to a second face region in the first depth image, where the second face region is an image region corresponding to the first face region; Performing a first face detection according to the depth value corresponding to the second face area to obtain an initial detection result; If the initial detection result indicates that the first RGB image is not a flat photo, an image set is obtained, wherein the image set includes a plurality of second RGB images of the face to be detected taken within a preset time, and the second RGB images are face images with facial movements; Performing a second face detection based on the image set to obtain a final detection result; The performing a first face detection according to the depth value corresponding to the second face area to obtain an initial detection result includes: dividing the second face region into a plurality of organ regions according to the depth value corresponding to the second face region; If there are any two organ regions that meet a preset condition, the initial detection result indicates that the first RGB image is a planar image, wherein the preset condition is that the difference in depth values ​​between the two organ regions is within a preset range; If there are no two organ regions that meet the preset condition, the initial detection result indicates that the first RGB image is not a planar image; The performing a second face detection according to the image set to obtain a final detection result includes: Dividing the second RGB image in the image set into a plurality of sub-regions; Counting the gradient histogram of each sub-region in the second RGB image; determining whether the second RGB image matches a preset reference image according to a gradient histogram of each of the sub-regions in the second RGB image; If the second RGB image matches the reference image, determining the second RGB image as the target image; Determine a final detection result according to the number of the target images in the image set; The determining, according to the gradient histogram of each sub-region in the second RGB image, whether the second RGB image matches a preset reference image includes: If the gradient histograms of the first sub-region and the second sub-region are consistent, the first sub-region is determined as the target sub-region, wherein the first sub-region is any sub-region in the second RGB image, and the second sub-region is a sub-region in the reference image corresponding to the first sub-region; Counting the number of the target sub-regions in the second RGB image; If the ratio of the number of the target sub-regions in the second RGB image to the total number of sub-regions in the second RGB image is greater than a preset ratio, it is determined that the second RGB image matches the reference image.

2. The method according to claim 1, characterized in that The obtaining a depth value corresponding to the second face region in the first depth image includes: Mapping the first face region to the first depth image to obtain an image region in the first depth image corresponding to the first face region; Determine an image area corresponding to the first face area in the first depth image as the second face area; Obtain a depth value corresponding to the second face region.

3. The method according to claim 2, characterized in that Mapping the first face region to the first depth image to obtain an image region in the first depth image corresponding to the first face region includes: Obtaining a mapping coefficient between the first depth image and the first RGB image; Mapping each pixel point in the first face region to the first depth image according to the mapping coefficient to obtain a mapping point of each pixel point in the first face region in the first depth image; The obtained region formed by the mapping points is determined as an image region in the first depth image corresponding to the first face region.

4. The method according to claim 1, characterized in that The determining the final detection result according to the number of the target images in the image set includes: If the ratio of the number of the target images in the image set to the total number of the second RGB images in the image set is greater than a preset ratio, the final detection result indicates that the detection is passed; If the ratio of the number of the target images in the image set to the total number of the second RGB images in the image set is less than or equal to a preset ratio, the final detection result indicates that the detection has failed.

5. The method according to claim 3, characterized in that Before obtaining the depth value corresponding to the second face area in the first depth image, the method further includes: Acquire a second depth image and a third RGB image of the target object; Counting the gradient images of the second depth image and the third RGB image respectively; Searching for a fourth sub-region matching the third sub-region, wherein the third sub-region is any sub-region in the gradient map of the second depth image, and the fourth sub-region is a sub-region in the gradient map of the third RGB image; The mapping coefficient is calculated according to the center point of the third sub-region and the center point of the fourth sub-region.

6. A face detection device based on artificial intelligence, characterized in that: The device comprises: A first acquisition unit, used to acquire a first depth image and a first RGB image of a face to be detected; A region detection unit, configured to detect a first face region in the first RGB image; a depth acquisition unit, configured to acquire a depth value corresponding to a second face region in the first depth image, where the second face region is an image region corresponding to the first face region; an initial detection unit, configured to perform a first face detection according to the depth value corresponding to the second face area, and obtain an initial detection result; a second acquisition unit, configured to acquire an image set if the initial detection result indicates that the first RGB image is not a flat photo, wherein the image set includes a plurality of second RGB images of the face to be detected taken within a preset time, and the second RGB images are face images with facial movements; A final detection unit, used to perform a second face detection based on the image set to obtain a final detection result; The initial detection unit is also used for: The second face region is divided into a plurality of organ regions according to the depth value corresponding to the second face region; if there are any two organ regions that meet a preset condition, the initial detection result indicates that the first RGB image is a planar image, wherein the preset condition is that the difference in depth value between the two organ regions is within a preset range; if there are no two organ regions that meet the preset condition, the initial detection result indicates that the first RGB image is not a planar image; The final detection unit is also used for: Dividing the second RGB image in the image set into a plurality of sub-regions; Counting the gradient histogram of each sub-region in the second RGB image; determining whether the second RGB image matches a preset reference image according to a gradient histogram of each of the sub-regions in the second RGB image; If the second RGB image matches the reference image, determining the second RGB image as the target image; Determine a final detection result according to the number of the target images in the image set; The determining, according to the gradient histogram of each sub-region in the second RGB image, whether the second RGB image matches a preset reference image includes: If the gradient histograms of the first sub-region and the second sub-region are consistent, the first sub-region is determined as the target sub-region, wherein the first sub-region is any sub-region in the second RGB image, and the second sub-region is a sub-region in the reference image corresponding to the first sub-region; Counting the number of the target sub-regions in the second RGB image; If the ratio of the number of the target sub-regions in the second RGB image to the total number of sub-regions in the second RGB image is greater than a preset ratio, it is determined that the second RGB image matches the reference image.

7. A terminal 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 method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Face identification method and system based on in-vivo detection

    CN107832677A

  • Face-in-vivo detection method, device, equipment and storage medium

    CN109034102A

  • Silent living body detection method and device, computer equipment and storage medium

    CN110298230A

  • 3D face living body detection method and device, computer equipment and storage medium

    CN110909693A

  • Face anti-counterfeiting detection method and device and multi-view camera

    CN111046703A