Face anti-counterfeiting method and device, and storage medium
By combining a 2D monocular camera with a facial depth model and a 3D anti-counterfeiting model, the image depth factor is obtained and converted into a 3D spatial information image, which solves the problem that the 2D monocular camera requires the cooperation of the person being verified, and achieves efficient and accurate 2D and 3D facial anti-counterfeiting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU LANGO ELECTRONICS TECH CO LTD
- Filing Date
- 2023-06-15
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, using a 2D monocular camera for face verification requires the person being verified to cooperate with actions, and the hardware requirements are high, resulting in a poor user experience and low efficiency.
Images are acquired using a 2D monocular camera. A face depth model and a 3D anti-spoofing model are used to obtain the depth factor of the image and convert it into a 3D spatial information image. A neural network model is then used to determine whether the image is a flat or 3D fake face.
It reduces hardware requirements and improves the accuracy and efficiency of face anti-spoofing without requiring the cooperation of the person being verified, and can simultaneously recognize 2D and 3D face images.
Smart Images

Figure CN116798130B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image anti-counterfeiting, and more particularly to a face anti-counterfeiting method, device, and storage medium. Background Technology
[0002] Currently, facial recognition anti-counterfeiting primarily targets faces that are broadly categorized into 2D and 3D. Generally, 2D information can detect 3D fake faces, while 3D information can detect 2D fake faces. The common anti-counterfeiting strategies for facial recognition include the following:
[0003] 1. Deep learning methods based on 2D cameras: These methods utilize a large amount of 2D image data captured by 2D and 3D face cameras, employing traditional image algorithms (PCA, eigenfaces, elasticity maps, etc.) or deep learning methods. Currently, the mainstream approach across various industries is to use deep learning methods.
[0004] These methods all employ a combination of deep learning and multi-pose image processing for face spoofing prevention. Specifically, during face recognition, the person being verified is required to perform actions such as opening their mouth, tilting their head down, shaking their head, and blinking, relying on multi-frame facial poses for anti-spoofing. However, this method requires the cooperation of the person being verified, resulting in a generally poor user experience.
[0005] 2. A face anti-spoofing method based on binocular cameras uses a binocular vision scheme to generate point cloud information for 2D face anti-spoofing, and combines one of the binoculars for 3D face anti-spoofing. This method has high reliability, but binocular cameras are more expensive and take up more space in the device. Summary of the Invention
[0006] This invention provides a face anti-spoofing method, device, and storage medium, which can simultaneously perform anti-spoofing on 2D and 3D face images using only a 2D monocular camera, thus solving the problem that face anti-spoofing requires the cooperation of the person being verified when using a 2D monocular camera.
[0007] Firstly, this application provides a face anti-counterfeiting method.
[0008] Acquire the image to be detected by a 2D monocular camera;
[0009] By using a preset face depth model, the depth factor corresponding to each pixel coordinate point in the image to be detected is obtained;
[0010] Based on the depth factor and preset camera parameters, the image to be detected is converted into a 3D spatial information image;
[0011] Determine whether the converted 3D spatial information image is a flat fake face;
[0012] If the 3D spatial information image is not a planar fake face, then the image to be detected is determined to be a 3D fake face by using a preset 3D anti-counterfeiting model.
[0013] This approach achieves two-dimensional and three-dimensional anti-spoofing of images using only a 2D monocular camera by employing facial depth models and 3D anti-spoofing models. It reduces the hardware requirements for the camera without requiring the verification person to cooperate, thus accelerating facial verification efficiency and improving the accuracy of facial anti-spoofing.
[0014] Furthermore, the preset facial depth model is specifically as follows:
[0015] Obtain a set of 3D face images consisting of pixel coordinates and corresponding depth factors, and use it as the training set for the face depth model;
[0016] Set up a neural network model and train the neural network model using the training set;
[0017] Set the trained neural network model as a preset face depth model;
[0018] The face depth model can generate a corresponding depth factor after inputting the pixel coordinates of the image.
[0019] By using a neural network model to adaptively obtain the depth factor of the image to be detected, a suitable depth factor can be generated based on different images using a 2D monocular camera. This allows for more accurate subsequent conversion of the image to be detected into a 3D spatial information image.
[0020] Furthermore, the step of converting the image to be detected into a 3D spatial information image based on the depth factor and camera parameters specifically involves:
[0021] Obtain the pixel coordinates of the image to be detected and the camera intrinsic parameter matrix parameters from the camera parameters;
[0022] The point cloud coordinates of the 3D spatial information image are obtained by using the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates.
[0023] In this way, the image to be detected is converted into a 3D spatial information image by adaptively generating a depth factor. The point cloud coordinates of the 3D spatial information image are obtained by formula, which makes it simpler and more convenient to obtain 3D spatial information.
[0024] Furthermore, the step of obtaining the point cloud coordinates of the 3D spatial information image through the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates specifically involves:
[0025] The point cloud coordinates of the corresponding 3D spatial information image of the image to be detected are calculated using the following formula:
[0026]
[0027] In this context, the point cloud coordinates of the 3D spatial information image are (X, Y, Z), the pixel coordinates of the image to be detected are (u, v), the camera intrinsic parameter matrix parameters are (fx, fy, tx, ty), where fx and fy are the camera focal lengths, tx and ty are the principal point coordinates relative to the imaging plane, and the depth factor corresponding to the pixel coordinates of the image to be detected is p.
[0028] Furthermore, the determination of whether the converted 3D spatial information image is a planar fake face specifically involves:
[0029] Obtain the spatial coordinates of several feature points in the converted 3D spatial information image;
[0030] Determine whether the spatial coordinates of four or more feature points in the converted 3D spatial information image are in the same plane. If the spatial coordinates of four or more feature points are in the same plane, the image to be detected is confirmed to be a planar fake face; otherwise, the image to be detected is confirmed not to be a planar fake face.
[0031] By determining whether the spatial coordinates of all feature points in the converted 3D spatial information image lie on the same plane, it is possible to confirm whether the 3D spatial information image is a planar fake face. This allows for rapid identification of planar fake faces, thereby preventing planar images from masquerading as real faces and passing facial recognition.
[0032] Furthermore, determining whether the spatial coordinates of four or more feature points in the converted 3D spatial information image lie in the same plane specifically involves:
[0033] Select at least four feature points from all feature points, and obtain the volume of the polyhedron formed by the spatial coordinates of the at least four feature points;
[0034] If the volume of the polyhedron is greater than a preset threshold, then at least four additional feature points are selected to form another polyhedron and calculate its volume, until all feature points are selected or the volume of the polyhedron is less than the preset threshold.
[0035] If the volume of all polyhedra is less than a preset threshold, then the spatial coordinates of all feature points are determined to be on the same plane.
[0036] Otherwise, it is determined that the spatial coordinates of all feature points are not on the same plane.
[0037] Based on the theorem that three points determine a plane, at least four feature points are selected for coplanarity determination. When the selected feature points are coplanar, other feature points are selected for volume calculation until all feature points have been selected. This eliminates the possibility of missing feature points and ensures that all feature points in the 3D spatial information image are on the same plane.
[0038] Furthermore, obtaining the volume of the polyhedron formed by the spatial coordinates of the at least four feature points specifically involves:
[0039] The formula for calculating the volume V of the polyhedron formed by the spatial coordinates of the at least four feature points is as follows:
[0040]
[0041] Among them, at least four feature points are {A} i |(x i ,y i ,z i ),i=1~n},Ai is the i-th feature point, and n is the number of selected feature points.
[0042] Furthermore, the acquisition of a set of three-dimensional face images composed of pixel coordinates and corresponding depth factors, used as the training set for the face depth model, specifically involves:
[0043] Obtain the pixel coordinates and point cloud coordinates of the face image acquired by the data acquisition device;
[0044] The depth factor corresponding to each pixel of the face image is obtained using the following formula based on the radar camera's extrinsic parameters and intrinsic parameter matrix parameters:
[0045]
[0046]
[0047] Wherein, the depth factor corresponding to each pixel of the face image is p, the coordinates of the face image camera coordinate system are (m, n), the pixel coordinates of the face image are (u, v), the point cloud coordinates are (x, y, z), and the radar camera extrinsic parameters are (R... 3*3 cx cy cz), the camera intrinsic parameter matrix parameters are (fx,fy,tx,ty);
[0048] In the camera intrinsic parameter matrix, fx and fy represent the camera focal length, and tx and ty represent the principal point coordinates relative to the imaging plane; in the radar camera extrinsic parameter matrix, R... 3*3The rotation matrix is used to record the orientation of the world coordinate system's coordinate axes relative to the camera coordinate axes. cx, cy, and cz are translation vectors used to record the position of the origin in the camera coordinate system.
[0049] Set the training set of the face depth model to {Ft} j |(u j ,v j ,p j )}, where Ft j Let j be the j-th training sample in the training set.
[0050] The data acquisition equipment includes image acquisition equipment and radar camera.
[0051] In this way, pixel coordinates and point cloud coordinates of facial images are obtained through data acquisition devices. By combining 3D spatial information and 2D planar image information through calculation, an accurate training set for facial depth models can be obtained.
[0052] Secondly, this application provides a face anti-counterfeiting device, including: an image acquisition module, a depth factor acquisition module, an image conversion module, a planar fake face detection module, and a three-dimensional fake face detection module;
[0053] The image acquisition module is used to acquire the image to be detected captured by a 2D monocular camera;
[0054] The depth factor acquisition module is used to acquire the depth factor corresponding to each pixel coordinate point of the image to be detected by using a preset face depth model.
[0055] The image conversion module is used to convert the image to be detected into a 3D spatial information image according to the depth factor and preset camera parameters;
[0056] The planar fake face detection module is used to determine whether the converted 3D spatial information image is a planar fake face;
[0057] The 3D fake face detection module is used to determine whether the image to be detected is a 3D fake face if the 3D spatial information image is not a planar fake face, by using a preset 3D anti-counterfeiting model.
[0058] Thirdly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the face anti-spoofing method as described in the first aspect. Attached Figure Description
[0059] Figure 1 : A flowchart illustrating an embodiment of a face anti-counterfeiting method provided by the present invention;
[0060] Figure 2: A module structure diagram of one embodiment of a face anti-counterfeiting device provided by the present invention. Detailed Implementation
[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0062] Example 1
[0063] Please refer to Figure 1 This is a flowchart illustrating an embodiment of a face anti-counterfeiting method provided by the present invention, including steps S1 to S5, each step as follows:
[0064] Step S1: Acquire the image to be detected by a 2D monocular camera.
[0065] In this embodiment, the image to be detected acquired by the 2D monocular camera only contains pixel coordinate system coordinates and image information of each pixel coordinate point. The 2D monocular camera cannot directly acquire the depth factor or point cloud coordinate system coordinates of the image to be detected.
[0066] Step S2: Obtain the depth factor corresponding to each pixel coordinate point of the image to be detected using a preset face depth model.
[0067] Furthermore, the preset face depth model specifically involves: acquiring a set of three-dimensional face images composed of pixel coordinates and corresponding depth factors, which serves as the training set for the face depth model;
[0068] Set up a neural network model and train the neural network model using the training set;
[0069] Set the trained neural network model as a preset face depth model;
[0070] The face depth model can generate a corresponding depth factor after inputting the pixel coordinates of the image.
[0071] By using a neural network model to adaptively obtain the depth factor of the image to be detected, a suitable depth factor can be generated based on different images using a 2D monocular camera. This allows for more accurate subsequent conversion of the image to be detected into a 3D spatial information image.
[0072] The neural network model described in this application can be a convolutional neural network model, a Transformer model, or any other neural network model.
[0073] In this embodiment, a convolutional neural network model is used that is stacked 3 times in the width direction and stacked according to the number of feature points in the height direction.
[0074] Specifically, obtaining a set of 3D face images composed of pixel coordinates and corresponding depth factors as the training set for the face depth model involves:
[0075] Obtain the pixel coordinates and point cloud coordinates of the face image acquired by the data acquisition device;
[0076] The depth factor corresponding to each pixel of the face image is obtained using the following formula based on the radar camera's extrinsic parameters and intrinsic parameter matrix parameters:
[0077]
[0078]
[0079] Wherein, the depth factor corresponding to each pixel of the face image is p, the coordinates of the face image camera coordinate system are (m, n), the pixel coordinates of the face image are (u, v), the point cloud coordinates are (x, y, z), and the radar camera extrinsic parameters are (R... 3*3 cx cy cz), the camera intrinsic parameter matrix parameters are (fx,fy,tx,ty);
[0080] In the camera intrinsic parameter matrix, fx and fy represent the focal length, and tx and ty represent the principal point coordinates relative to the imaging plane; in the radar camera extrinsic parameter matrix, R... 3*3 The rotation matrix is used to record the orientation of the world coordinate system's coordinate axes relative to the camera coordinate axes. cx, cy, and cz are translation vectors used to record the position of the origin in the camera coordinate system.
[0081] Set the training set of the face depth model to {Ft} j |(u j ,v j ,p j )}, where Ft j Let j be the j-th training sample in the training set.
[0082] Furthermore, the data acquisition device described in this embodiment includes an image acquisition device and a radar camera.
[0083] In this way, pixel coordinates and point cloud coordinates of facial images are obtained through data acquisition devices. By combining 3D spatial information and 2D planar image information through calculation, an accurate training set for facial depth models can be obtained.
[0084] Step S3: Based on the depth factor and preset camera parameters, convert the image to be detected into a 3D spatial information image.
[0085] Furthermore, the step of converting the image to be detected into a 3D spatial information image based on the depth factor and camera parameters specifically involves:
[0086] Obtain the pixel coordinates of the image to be detected and the camera intrinsic parameter matrix parameters from the camera parameters;
[0087] The point cloud coordinates of the 3D spatial information image are obtained by using the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates.
[0088] Furthermore, the step of obtaining the point cloud coordinates of the 3D spatial information image through the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates specifically involves:
[0089] The point cloud coordinates of the corresponding 3D spatial information image of the image to be detected are calculated using the following formula:
[0090]
[0091] In this context, the point cloud coordinates of the 3D spatial information image are (X, Y, Z), the pixel coordinates of the image to be detected are (u, v), the camera intrinsic parameter matrix parameters are (fx, fy, tx, ty), where fx and fy are the camera focal lengths, tx and ty are the principal point coordinates relative to the imaging plane, and the depth factor corresponding to the pixel coordinates of the image to be detected is p.
[0092] Based on this idea, this application combines the fixed spatial morphological features of the face, and can learn from a large amount of data through deep learning methods. Finally, it uses a neural network model to fit the complex transformation relationship between the 2D monocular camera and the facial features to obtain the depth factor P. Combined with the known camera intrinsic parameters, it finally obtains the 3D spatial information image of the facial feature points.
[0093] Step S4: Determine whether the converted 3D spatial information image is a flat fake face.
[0094] Furthermore, the determination of whether the converted 3D spatial information image is a planar fake face specifically involves:
[0095] Obtain the spatial coordinates of several feature points in the converted 3D spatial information image;
[0096] Determine whether the spatial coordinates of four or more feature points in the converted 3D spatial information image are in the same plane. If the spatial coordinates of four or more feature points are in the same plane, the image to be detected is confirmed to be a planar fake face; otherwise, the image to be detected is confirmed not to be a planar fake face.
[0097] By determining whether the spatial coordinates of all feature points in the converted 3D spatial information image lie on the same plane, it is possible to confirm whether the 3D spatial information image is a planar fake face. This allows for rapid identification of planar fake faces, thereby preventing planar images from masquerading as real faces and passing facial recognition.
[0098] Furthermore, determining whether the spatial coordinates of four or more feature points in the converted 3D spatial information image lie in the same plane specifically involves:
[0099] Select at least four feature points from all feature points, and obtain the volume of the polyhedron formed by the spatial coordinates of the at least four feature points;
[0100] If the volume of the polyhedron is greater than a preset threshold, then at least four additional feature points are selected to form another polyhedron and calculate its volume, until all feature points are selected or the volume of the polyhedron is less than the preset threshold.
[0101] If the volume of all polyhedra is less than a preset threshold, then the spatial coordinates of all feature points are determined to be on the same plane.
[0102] Otherwise, it is determined that the spatial coordinates of all feature points are not on the same plane.
[0103] Based on the theorem that three points determine a plane, at least four feature points are selected for coplanarity determination. When the selected feature points are coplanar, other feature points are selected for volume calculation until all feature points have been selected. This eliminates the possibility of missing feature points and ensures that all feature points in the 3D spatial information image are on the same plane.
[0104] Furthermore, obtaining the volume of the polyhedron formed by the spatial coordinates of the at least four feature points specifically involves:
[0105] The formula for calculating the volume V of the polyhedron formed by the spatial coordinates of the at least four feature points is as follows:
[0106]
[0107] Among them, at least four feature points are {A} i |(x i ,y i ,z i),i=1~n},Ai is the i-th feature point, and n is the number of selected feature points.
[0108] In this embodiment, the spatial coordinates of five feature points in the converted 3D spatial information image are obtained. These five feature points are located at the left eye, right eye, bridge of the nose, left corner of the mouth, and right corner of the mouth of the human face in the 3D spatial information image. Any four points are selected from these five feature points, and the volume of the tetrahedron defined by these four points is calculated. The calculation method is as follows:
[0109]
[0110] The tetrahedron has a volume of V and four feature points {A}. i |(x i ,y i ,z i ),i=1~4},Ai is the i-th feature point.
[0111] If the tetrahedron volume V is less than a threshold, then the four feature points are coplanar. In this embodiment, the threshold is set to 0.5. The closer the tetrahedron volume V is to 0, the greater the coplanarity of the four feature points.
[0112] If the volume of all tetrahedrons is greater than the threshold, then it is determined that the spatial coordinates of all feature points are not on the same plane, and their 3D spatial information image is not a planar fake face.
[0113] Step S5: If the 3D spatial information image is not a planar fake face, then determine whether the image to be detected is a 3D fake face by using a preset 3D anti-counterfeiting model.
[0114] The three-dimensional anti-counterfeiting model described in this embodiment is specifically as follows:
[0115] Acquire 3D fake face image data as a training set for a 3D anti-counterfeiting model;
[0116] Set up a deep learning model and train the deep learning model using the training set of the three-dimensional anti-counterfeiting model;
[0117] The trained deep learning model is set as a 3D anti-counterfeiting model.
[0118] The acquisition of 3D fake face image data specifically involves: using a 2D monocular camera to collect image data of 3D fake faces and 3D real faces as positive and negative samples for training data of the 3D anti-counterfeiting model, thereby completing the training of the 3D anti-counterfeiting model.
[0119] This approach achieves two-dimensional and three-dimensional anti-spoofing of images using only a 2D monocular camera by employing facial depth models and 3D anti-spoofing models. It reduces the hardware requirements for the camera without requiring the verification person to cooperate, thus accelerating facial verification efficiency and improving the accuracy of facial anti-spoofing.
[0120] Furthermore, in this embodiment, the face depth model in step S2 and the three-dimensional anti-spoofing model in step S5 can be combined to achieve one-step detection of planar fake faces and three-dimensional fake faces.
[0121] Set up a new training set, which has the same structure as the training set for the face depth model.
[0122] The new training set needs to simultaneously collect real faces and 3D fake face models, and then label and distinguish the collected real faces and 3D fake faces. The face depth model is changed to a face anti-spoofing model, and the new training set is input into the face anti-spoofing model for training to obtain depth factors and results indicating whether it is a 3D fake face.
[0123] This embodiment, through a facial depth model and a 3D fake face model, converts a 2D image into a 3D spatial information image by acquiring a depth factor, achieving face recognition of both planar and 3D fake faces without requiring the cooperation of a verifier. This reduces the hardware requirements for the camera while accelerating the success rate of face verification and improving the accuracy of face anti-spoofing.
[0124] Example 2
[0125] Please refer to Figure 2 This is a module structure diagram of one embodiment of a face anti-counterfeiting device provided by the present invention.
[0126] A face anti-counterfeiting device includes: an image acquisition module 210, a depth factor acquisition module 220, an image conversion module 230, a planar fake face detection module 240, and a three-dimensional fake face detection module 250.
[0127] The image acquisition module 210 is used to acquire the image to be detected captured by a 2D monocular camera;
[0128] The depth factor acquisition module 220 is used to acquire the depth factor corresponding to each pixel coordinate point of the image to be detected by using a preset face depth model.
[0129] The image conversion module 230 is used to convert the image to be detected into a 3D spatial information image according to the depth factor and preset camera parameters;
[0130] The planar fake face detection module 240 is used to determine whether the converted 3D spatial information image is a planar fake face;
[0131] The 3D fake face detection module 250 is used to determine whether the image to be detected is a 3D fake face if the 3D spatial information image is not a planar fake face, by using a preset 3D anti-counterfeiting model.
[0132] Furthermore, the image conversion module 230 also includes a parameter acquisition unit 231 and a point cloud coordinate point acquisition unit 232;
[0133] The parameter acquisition unit 231 is used to acquire the pixel coordinates of the image to be detected and the camera intrinsic parameter matrix parameters in the camera parameters;
[0134] The point cloud coordinate acquisition unit 232 is used to obtain the point cloud coordinates of the 3D spatial information image through the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates.
[0135] The further point cloud coordinate acquisition unit 232 is used to obtain the point cloud coordinates of the 3D spatial information image through the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates, specifically:
[0136] The point cloud coordinates of the corresponding 3D spatial information image of the image to be detected are calculated using the following formula:
[0137]
[0138] In this context, the point cloud coordinates of the 3D spatial information image are (X, Y, Z), the pixel coordinates of the image to be detected are (u, v), the camera intrinsic parameter matrix parameters are (fx, fy, tx, ty), where fx and fy are the camera focal lengths, tx and ty are the principal point coordinates relative to the imaging plane, and the depth factor corresponding to the pixel coordinates of the image to be detected is p.
[0139] Furthermore, the planar fake face detection module 240 also includes a feature point acquisition unit 241 and a coplanar detection unit 242;
[0140] The feature point acquisition unit 241 is used to acquire the spatial coordinates of several feature points in the converted 3D spatial information image;
[0141] The coplanar detection unit 242 is used to determine whether the spatial coordinates of four or more feature points in the converted 3D spatial information image are in the same plane. If the spatial coordinates of four or more feature points are in the same plane, the image to be detected is confirmed to be a planar fake face; otherwise, the image to be detected is confirmed not to be a planar fake face.
[0142] Furthermore, the coplanarity detection unit 242 is used to determine whether the spatial coordinates of four or more feature points in the converted 3D spatial information image are on the same plane, specifically:
[0143] Select at least four feature points from all feature points, and obtain the volume of the polyhedron formed by the spatial coordinates of the at least four feature points;
[0144] If the volume of the polyhedron is greater than a preset threshold, then at least four additional feature points are selected to form another polyhedron and calculate its volume, until all feature points are selected or the volume of the polyhedron is less than the preset threshold.
[0145] If the volume of all polyhedra is less than the preset threshold, then it is determined that the spatial coordinates of four or more feature points are in the same plane.
[0146] Otherwise, it is determined that the spatial coordinates of all feature points are not on the same plane.
[0147] Furthermore, obtaining the volume of the polyhedron formed by the spatial coordinates of the at least four feature points specifically involves:
[0148] The formula for calculating the volume V of the polyhedron formed by the spatial coordinates of the at least four feature points is as follows:
[0149]
[0150] Among them, at least four feature points are {A} i |(x i ,y i ,z i ),i=1~n},Ai is the i-th feature point, and n is the number of selected feature points.
[0151] Furthermore, the preset face depth model includes a training set acquisition module, a neural network model setting module, and a depth factor calculation module:
[0152] The training set acquisition module is used to acquire a set of three-dimensional face images composed of pixel coordinates and corresponding depth factors, as the training set of the face depth model;
[0153] The neural network model setting module is used to set up the neural network model and train the neural network model using the training set.
[0154] Set the trained neural network model as a preset face depth model;
[0155] The depth factor calculation module is used by the face depth model to generate the corresponding depth factor after inputting the pixel coordinates of the image.
[0156] Furthermore, the training set acquisition module also includes a data acquisition unit, a coordinate calculation unit, and a training set setting unit:
[0157] The data acquisition unit is used to acquire the pixel coordinates and point cloud coordinates of the face image acquired by the data acquisition device;
[0158] The coordinate calculation unit is used to obtain the depth factor corresponding to each pixel of the face image according to the radar camera's extrinsic parameters and camera intrinsic parameter matrix parameters using the following formula:
[0159]
[0160]
[0161] Wherein, the depth factor corresponding to each pixel of the face image is p, the coordinates of the face image camera coordinate system are (m, n), the pixel coordinates of the face image are (u, v), the point cloud coordinates are (x, y, z), and the radar camera extrinsic parameters are (R... 3*3 cx cy cz), the camera intrinsic parameter matrix parameters are (fx,fy,tx,ty);
[0162] In the camera intrinsic parameter matrix, fx and fy represent the camera focal length, and tx and ty represent the principal point coordinates relative to the imaging plane. In the radar camera extrinsic parameter matrix, R... 3*3 The rotation matrix is used to record the orientation of the world coordinate system's coordinate axes relative to the camera coordinate axes. cx, cy, and cz are translation vectors used to record the position of the origin in the camera coordinate system.
[0163] The training set setting unit is used to set the training set of the face depth model as {Ft}. j |(u j ,v j ,p j )}, where Ft j Let j be the j-th training sample in the training set.
[0164] This embodiment achieves two-dimensional and three-dimensional anti-spoofing of images using only a 2D monocular camera by employing a facial depth model and a 3D anti-spoofing model. It reduces the hardware requirements for the camera without requiring the verification person to cooperate, thus accelerating facial verification efficiency and improving the accuracy of facial anti-spoofing.
[0165] Example 3
[0166] One embodiment of the present invention provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the face anti-spoofing method as described above.
[0167] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A face anti-counterfeiting method, characterized in that, Includes the following steps: Acquire the image to be detected by a 2D monocular camera; The image to be detected acquired by the 2D monocular camera only contains the pixel coordinate system coordinate points and the image information of each pixel coordinate point; By using a preset face depth model, the depth factor corresponding to each pixel coordinate point in the image to be detected is obtained; Based on the depth factor and preset camera parameters, the image to be detected is converted into a 3D spatial information image; Determine whether the converted 3D spatial information image is a flat fake face; If the 3D spatial information image is not a planar fake face, then the detection image information image is determined to be a 3D fake face by using a preset 3D anti-counterfeiting model; The preset facial depth model is specifically as follows: Obtain a set of 3D face images consisting of pixel coordinates and corresponding depth factors, and use it as the training set for the face depth model; Set up a neural network model and train the neural network model using the training set; Set the trained neural network model as a preset face depth model; The face depth model can generate a corresponding depth factor after inputting the pixel coordinates of the image; The acquisition of a set of 3D face images composed of pixel coordinates and corresponding depth factors, used as the training set for the face depth model, specifically involves: Obtain the pixel coordinates and point cloud coordinates of the face image acquired by the data acquisition device; The depth factor corresponding to each pixel of the face image is obtained using the following formula based on the radar camera's extrinsic parameters and intrinsic parameter matrix parameters: ; Wherein, the depth factor corresponding to each pixel of the face image is p, the coordinates of the face image camera coordinate system are (m, n), the pixel coordinates of the face image are (u, v), the point cloud coordinates are (x, y, z), and the radar camera extrinsic parameters are ( cx cy cz), the camera intrinsic parameter matrix parameters are (fx,fy,tx,ty); In the camera intrinsic parameter matrix, fx and fy represent the camera focal length, and tx and ty represent the principal point coordinates relative to the imaging plane. In the radar camera extrinsic parameters... The rotation matrix is used to record the orientation of the world coordinate system's coordinate axes relative to the camera coordinate axes. cx, cy, and cz are translation vectors used to record the position of the origin in the camera coordinate system. Set the training set for the face depth model as follows: ,in Let j be the j-th training sample in the training set.
2. The face anti-counterfeiting method according to claim 1, characterized in that, The step of converting the image to be detected into a 3D spatial information image based on the depth factor and camera parameters specifically involves: Obtain the pixel coordinates of the image to be detected and the camera intrinsic parameter matrix parameters from the camera parameters; The point cloud coordinates of the 3D spatial information image are obtained by using the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates.
3. The face anti-counterfeiting method according to claim 2, characterized in that, The process of obtaining the point cloud coordinates of the 3D spatial information image by using the pixel coordinates of the image to be detected, the camera intrinsic parameter matrix parameters, and the depth factor corresponding to the pixel coordinates is as follows: The point cloud coordinates of the corresponding 3D spatial information image of the image to be detected are calculated using the following formula: ; In this context, the point cloud coordinates of the 3D spatial information image are (X,Y,Z), the pixel coordinates of the image to be detected are (u,v), the camera intrinsic parameter matrix parameters are (fx,fy,tx,ty), where fx and fy are the camera focal lengths, tx and ty are the principal point coordinates relative to the imaging plane, and the depth factor corresponding to the pixel coordinates of the image to be detected is p.
4. The face anti-counterfeiting method according to claim 1, characterized in that, The determination of whether the converted 3D spatial information image is a planar fake face specifically involves: Obtain the spatial coordinates of several feature points in the converted 3D spatial information image; Determine whether the spatial coordinates of four or more feature points in the converted 3D spatial information image are in the same plane. If the spatial coordinates of four or more feature points are in the same plane, the image to be detected is confirmed to be a planar fake face; otherwise, the image to be detected is confirmed not to be a planar fake face.
5. The face anti-counterfeiting method according to claim 4, characterized in that, The determination of whether the spatial coordinates of four or more feature points in the converted 3D spatial information image are in the same plane specifically involves: Select at least four feature points from all feature points, and obtain the volume of the polyhedron formed by the spatial coordinates of the at least four feature points; If the volume of the polyhedron is greater than a preset threshold, then at least four additional feature points are selected to form another polyhedron and calculate its volume, until all feature points are selected or the volume of the polyhedron is less than the preset threshold. If the volume of all polyhedra is less than the preset threshold, then it is determined that the spatial coordinates of four or more feature points are in the same plane. Otherwise, it is determined that the spatial coordinates of all feature points are not on the same plane.
6. The face anti-counterfeiting method according to claim 5, characterized in that, The process of obtaining the volume of the polyhedron formed by the spatial coordinates of the at least four feature points specifically involves: Calculate the volume of the polyhedron formed by the spatial coordinates of the at least four feature points. The formula is: ; Among them, at least four feature points are A i Let be the i-th feature point, and n be the number of feature points selected.
7. A facial recognition anti-counterfeiting device, characterized in that, include: The device includes an image acquisition module, a depth factor acquisition module, an image conversion module, a planar fake face detection module, and a three-dimensional fake face detection module; the face anti-counterfeiting device is used to implement the face anti-counterfeiting method as described in any one of claims 1 to 6. The image acquisition module is used to acquire the image to be detected by a 2D monocular camera; The image to be detected acquired by the 2D monocular camera only contains the pixel coordinate system coordinate points and the image information of each pixel coordinate point; The depth factor acquisition module is used to acquire the depth factor corresponding to each pixel coordinate point of the image to be detected by using a preset face depth model. The image conversion module is used to convert the image to be detected into a 3D spatial information image according to the depth factor and preset camera parameters; The planar fake face detection module is used to determine whether the converted 3D spatial information image is a planar fake face; The 3D fake face detection module is used to determine whether the image to be detected is a 3D fake face if the 3D spatial information image is not a planar fake face, by using a preset 3D anti-counterfeiting model.
8. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the face anti-spoofing method as described in any one of claims 1 to 6.