Face recognition method and device, chip system, storage medium and program product
Patent Information
- Application Number
- CN202510580365.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而,在一些场景下,人脸检测算法可能会误将这些假人脸识别为真人脸,并对其进行美化处理,导致用户体验较差
[0076]应当理解的是,本申请的第二方面至第七方面与本申请的第一方面的技术方案相对应,各方面及对应的可行实施方式所取得的有益效果相似,不再赘述。
Smart Images

Figure CN123016490A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to face recognition methods, devices, chip systems, storage media and software products. Background Technology
[0002] To enhance the user's shooting experience, terminal devices typically employ face detection algorithms to accurately identify faces. These algorithms can quickly and accurately locate faces in images and identify facial feature points such as eyes, nose, and mouth. After face recognition, the terminal device can apply various beautification techniques. These techniques help users obtain clearer and more aesthetically pleasing photos, thereby improving the overall shooting experience.
[0003] However, in some scenarios, face detection algorithms may mistakenly identify these fake faces as real faces and beautify them, resulting in a poor user experience. Summary of the Invention
[0004] This application provides a face recognition method, apparatus, chip system, storage medium, and program product, applicable to the field of terminal technology. After the terminal device acquires image data and shooting distance, the terminal device can determine the face pixel area 1 in the image data based on the image data, and determine the face pixel area 2 based on the shooting distance. Based on the difference between face pixel area 1 and face pixel area 2, the face recognition result is determined, resulting in higher accuracy when the terminal device performs face recognition, which helps improve the user experience.
[0005] In a first aspect, embodiments of this application propose a face recognition method. The method includes: receiving a first operation that triggers image capture; based on the first operation, acquiring first image data and a first distance, the first distance being the distance between a terminal device and a target being captured; calculating a first face area based on the first image data; calculating a second face area based on the first distance; and obtaining a target result based on the first face area and the second face area, the target result indicating whether the face in the first image data is a real face.
[0006] The first operation can be understood as the user triggering the terminal device to take a picture. Receiving the first operation can be understood as the terminal device detecting the user's first input operation, thereby enabling the terminal device to respond to the operation and take an image.
[0007] The first operation could be, for example, when the terminal device displays... (as described below) Figure 1 When the user triggers an input operation on the camera control 104, such as clicking the camera control 104, the system receives the first operation, for example, when the terminal device displays the following. Figure 1When the interface (b) is in the middle, it responds to the input operation that triggers the camera control 104.
[0008] The first image data can be understood as image data or pixel data of multiple initial images acquired by the camera of the terminal device. The first distance can be understood as the distance between the terminal device (or camera) and the subject being photographed. Based on the first operation, acquiring the first image data and the first distance can be understood as the terminal device acquiring image data or pixel data of multiple initial images and the distance between the terminal device (or camera) and the subject being photographed, based on the user triggering the terminal device to take a picture.
[0009] The first image data can be, for example, the image data in S301 below. The first distance can be, for example, the shooting distance in S301 below. Based on the first operation, the first image data and the first distance are acquired, for example, in response to the user triggering the terminal device to take a picture, the terminal device acquires the image data and the shooting distance below.
[0010] The first face area can be understood as the face pixel area determined after face recognition based on the first image data. For example, the first face area can be the face pixel area 1 mentioned below.
[0011] The second face area can be understood as the area of the second face calculated based on the first distance. For example, the second face area could be the face pixel area of 2 as described below.
[0012] The target result can be understood as a judgment based on the area of the first face and the area of the second face to obtain the face recognition result. The target result includes two types of results: real faces and fake faces. Obtaining the target result based on the area of the first face and the area of the second face can be understood as judging the difference between the area of the first face and the area of the second face to obtain the face recognition result.
[0013] The target result can be, for example, the real / fake face detection result in S308 below. Based on the first face area and the second face area, the target result can be, for example, comparing face pixel area 1 with face pixel area 2 below to determine whether the face in the new image is a real face.
[0014] The face recognition method of this application involves a terminal device calculating a reasonable face area (second face area) by acquiring a first distance between itself and the target image, and comparing this second face area with the face area calculated from the first image data (first face area) to more accurately determine the authenticity of the face. By combining distance information for judgment, this method effectively reduces the misjudgment that may be caused by relying solely on image features, improves the accuracy of detection and the robustness of the face recognition method, especially in cases of low light or complex backgrounds, where distance information provides additional judgment criteria.
[0015] In one possible implementation, calculating the second face area includes: calculating the second face area based on a first distance and a calibration formula, the calibration formula being used to describe the face area at different shooting distances.
[0016] The calibration formula can be understood as a formula describing the change in face area at different shooting distances. Based on the first distance and the calibration formula, calculating the second face area can be understood as substituting the shooting distance into the calibration formula to calculate the second face area.
[0017] Based on the first distance and the calibration formula, the second face area can be calculated, for example, as the face pixel area 2 determined by the terminal device in S304 below based on the calibration formula.
[0018] In this way, by using distance information to calculate the face area, a reasonable estimate of the face area can be obtained.
[0019] In one possible implementation, calculating the area of a first face based on the first image data includes: performing face recognition on the first image data to determine a first portion of the image, the first portion of the image including part or all of the face in the first image data; and calculating the area of the first face based on the first portion of the image.
[0020] The first part of the image can be understood as the image corresponding to the face in the first image data. Performing face recognition on the first image data to determine the first part of the image can be understood as performing face recognition on the image data or pixel data of multiple initial images acquired by the camera of the terminal device to determine the image corresponding to the face in the first image data.
[0021] The first part of the image can be, for example, the new image in S302 below. Face recognition is performed on the first image data to determine the first part of the image, which can be, for example, face recognition is performed on each initial image of the image data below to generate a new image.
[0022] Calculating the area of the first face based on the first part of the image can be understood as calculating the pixel area of the face based on the image corresponding to the face in the first image data.
[0023] Based on the first part of the image, the area of the first face can be calculated, for example, the area of the face pixels in the new image can be calculated for the terminal device in S304 below.
[0024] In this way, by extracting a first portion of the image from the first image data and calculating the area of the first face, the size of the face can be preliminarily determined without the need for external information. This provides a foundation for subsequent face recognition.
[0025] In one possible implementation, determining the first part of the image includes: performing face recognition based on the first image data to determine a first region, the first region being the region selected by a face bounding box; expanding the first region to obtain a second region, the range covered by the second region being greater than or equal to the range covered by the first region; and cropping the image corresponding to the second region to obtain the first part of the image.
[0026] Here, the first region can be understood as the region corresponding to a face in the first image data. Determining the first region based on the first image data can be understood as performing face recognition on the first image data to identify the region corresponding to a face in the first image data.
[0027] The first region can be, for example, the face bounding box (the area where the face is located in the image data) in S301 below. Face recognition is performed based on the first image data, and the first region is determined, for example, the face bounding box obtained by the terminal device based on the image data in S301 below.
[0028] The second region can be understood as the region formed by expanding the first region outwards. Expanding the first region to obtain the second region can be understood as expanding the first region outwards to obtain the region formed by expanding the first region.
[0029] The second region can be, for example, the expanded face frame in S302 below. The first region is expanded to obtain the second region, for example, the expanded face frame obtained by the terminal device in S302 below.
[0030] Cropping the image corresponding to the second region to obtain the first part of the image can be understood as cropping the region formed after the outward expansion process to obtain the first part of the image. Cropping the image corresponding to the second region to obtain the first part of the image can be, for example, the image region corresponding to the cropped and expanded face frame in S302 below, to generate a new image.
[0031] In this way, by determining the first region through facial recognition, the location of the face can be accurately pinpointed. Furthermore, expanding the first region outwards can incorporate background information surrounding the face, which helps to perform facial recognition more effectively in complex environments.
[0032] In one possible implementation, obtaining the target result based on the first face area and the second face area includes: determining a first result based on the first face area and the second face area; determining the target result based on the first result, the second result, and / or the third result, wherein the second result is determined based on the first model to perform real and fake face recognition on the first image data, and the third result is determined based on facial key points in the first image data.
[0033] Here, the first result can be understood as the face recognition result determined by the first face area and the second face area. Determining the first result based on the first face area and the second face area can be understood as judging the difference between the first face area and the second face area to obtain the face recognition result.
[0034] The first result can be, for example, label 2 in S305 below. Based on the first face area and the second face area, the first result is determined, for example, by comparing the face pixel area 1 with the face pixel area 2 determined based on the calibration formula in S305 below, and outputting label 2 according to the comparison result.
[0035] The second result can be understood as the face recognition result determined by real vs. fake face recognition on the first image data. The third result can be understood as the face recognition result determined based on facial key points in the first image data. Based on the first result, and the second and / or the third result, determining the target result can be understood as determining the face recognition result based on the first face area and the second face area, as well as the face recognition result determined by real vs. fake face recognition on the first image data, and / or, determining the final face recognition result based on the face key points in the first image data.
[0036] The second result can be, for example, label 1 in S303 below. The third result can be, for example, label 3 in S307 below. Based on the first result, and the second and / or third result, the target result is determined, for example, by outputting the real and fake face detection result based on label 1, label 2 and label 3 in S308 below.
[0037] By combining multiple results, this face recognition method can more effectively reduce false positives and false negatives. Especially in complex environments, this multi-layered, multi-faceted mechanism can significantly improve the accuracy and robustness of face recognition.
[0038] In one possible implementation, the second result is determined by real and fake face recognition of the first part of the image based on the first model, and the third result is determined based on facial key points in the first part of the image, wherein the first part of the image includes some or all of the faces in the first image data.
[0039] In this way, by recognizing the first part of the image, unnecessary computational burden can be reduced, thereby improving the operating efficiency of the face recognition method.
[0040] In one possible implementation, the first image data is image data of multiple images, and the first part of the image includes a face region image in each of the multiple images; the face recognition method further includes: determining a first facial key point in a first face region image among the multiple face region images; determining a second facial key point in a second face region image among the multiple face region images; and determining a third result based on the first facial key point and the second facial key point.
[0041] Here, the first facial landmark can be understood as the coordinates of a facial landmark in the first face region image. The second facial landmark can be understood as the coordinates of a facial landmark in the second face region image. The first and second facial landmarks can be understood as different facial landmark coordinates. Based on the first and second facial landmarks, determining the third result can be understood as determining the face recognition result based on the facial landmark coordinates in the first and second face region images, and outputting the face recognition result determined based on the first and second facial landmarks.
[0042] The first and second facial landmarks can be, for example, the coordinates of facial landmarks in at least two images in S307 below. Based on the first and second facial landmarks, the third result is determined, for example, by judging whether the face has moved based on the coordinates of facial landmarks in at least two images from multiple new images in S307 below, and the label 3 is output according to the judgment result.
[0043] In this way, by analyzing the facial regions in multiple images, the face recognition method can obtain a more comprehensive data foundation, providing a more reliable basis for determining the third result, thereby improving the accuracy of the judgment.
[0044] In one possible implementation, a third result is determined based on a first facial landmark and a second facial landmark, including: determining the third result based on the difference between a first height and a second height, wherein the first height is the height of the first facial features determined based on the first facial landmark, and the second height is the height of the first facial features determined based on the second facial landmark.
[0045] Specifically, determining the third result based on the difference between the first and second heights can be understood as the difference between the heights of the facial features of the first face determined by the first and second facial key points, and outputting the face recognition result based on the first and second facial key points.
[0046] Based on the difference between the first and second heights, the third result can be determined, for example, by determining the eye's motion state based on the eye's key point coordinates 1 and 2, and then outputting the face recognition result.
[0047] In this way, by analyzing the differences in the height of key points, subtle changes in facial features can be identified more accurately, which helps to improve the accuracy of facial recognition.
[0048] In one possible implementation, determining the target result includes: when the third result is used to indicate that the face in the first image data is a real face, the target result is used to indicate that the face in the first image data is a real face.
[0049] In this way, by confirming the target result as a real face only when the third result indicates that it is a real face, the accuracy of recognition can be improved.
[0050] In one possible implementation, if the third result is used to indicate that the face in the first image data is a fake face, the target result is determined based on the first result and the second result.
[0051] In this way, even if the third result shows a fake face, it can still be further verified through other results, which enhances the robustness of the face recognition method in various situations and ensures the reliability of the judgment.
[0052] In one possible implementation, determining the target result based on the first result and the second result includes: when the first result indicates that the face in the first image data is a fake face, the target result indicates that the face in the first image data is a fake face; when the first result indicates that the face in the first image data is a real face, the target result is the same as the second result.
[0053] In this way, combining initial screening with further verification not only improves the accuracy and efficiency of facial recognition, but also optimizes resource utilization.
[0054] In one possible implementation, encoding the first part of the image to obtain a second label includes: inputting the first part of the image into a first model, and the first model outputting the second result.
[0055] Here, the first model can be understood as a model that encodes the first image. Inputting the first part of the image into the first model and having the first model output the second result can be understood as inputting the first part of the image into the model that encodes the first image and outputting the face recognition result.
[0056] The first model can be, for example, the real / fake face classification model described below. Inputting a first part of the image into the first model, the first model outputs a second result, for example, in S303 described below, inputting a new image into the real / fake face classification model, which then identifies the new image and outputs label 1.
[0057] In this way, by encoding images and generating labels, data processing efficiency and model accuracy are improved.
[0058] In one possible implementation, training samples are obtained, which include multiple real face images and multiple fake face images; face recognition is performed on the faces in the training samples to determine a third region, which is the region corresponding to the face; the third region is expanded to obtain a fourth region, the area covered by the fourth region being greater than or equal to the area covered by the third region; the image corresponding to the fourth region is cropped to obtain multiple second-part images; the multiple second-part images are input into an initial model, and the initial model outputs a prediction result, which is used to indicate whether the face in each of the multiple second images is a real face or a fake face; the initial model is adjusted based on the prediction result until a first model is obtained.
[0059] Here, training samples can be understood as input data used to train the first model. Training samples can be, for example, the dataset described in S401 below. Obtaining training samples can be, for example, obtaining the dataset described in S401 below.
[0060] The third region can be understood as the facial region determined by face recognition on the training samples. Face recognition on the faces in the training samples determines the third region, for example, as described below, by using a face detection algorithm... Figure 5 Face detection can be performed on the image shown in (a) to identify the face region.
[0061] The fourth region can be understood as the region formed by expanding the third region outwards. Expanding the third region to obtain the fourth region can be understood as expanding the third region outwards to obtain the region formed by expanding the third region.
[0062] Expanding the third region yields a fourth region, which can be represented as shown below. Figure 5 The face bounding box shown in (b) is expanded to include more background information (such as hair, ears, etc.). The expansion ratio can be, for example, 20%. The result of the expansion can be as follows: Figure 5 As shown in (c) in the figure.
[0063] Cropping the image corresponding to the fourth region yields multiple second-part images, for example, as described below. Figure 5 By cropping the face area covered by the expanded face frame shown in (c), we can obtain the following: Figure 5 The preprocessed data (i.e., preprocessed real and fake face images) is shown in (d) in the figure.
[0064] Inputting multiple second-part images into the initial model and outputting prediction results can be, for example, inputting multiple second-part images into an untrained real / fake face recognition model and outputting face recognition results.
[0065] The initial model is adjusted based on the prediction results until the first model is obtained. For example, the parameters of the real and fake face classification model can be adjusted based on the prediction results of the fake face classification model, as described below, to finally obtain the trained real and fake face classification model.
[0066] In this way, the above steps improve the accuracy of face recognition and the robustness of the model, enrich the training data, and optimize the model accuracy.
[0067] Secondly, embodiments of this application provide a face recognition device, which can be a terminal device, or a chip or chip system within a terminal device. The face recognition device may include a display unit and a processing unit. When the face recognition device is a terminal device, the display unit may be a display screen. The display unit is used to perform display steps to enable the terminal device to implement a face recognition method described in the first aspect or any possible implementation of the first aspect. When the face recognition device is a terminal device, the processing unit may be a processor. The face recognition device may further include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit to enable the terminal device to implement a face recognition method described in the first aspect or any possible implementation of the first aspect. When the face recognition device is a chip or chip system within a terminal device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit to enable the terminal device to implement a face recognition method described in the first aspect or any possible implementation of the first aspect. The storage unit can be a storage unit inside the chip (e.g., a register, cache, etc.) or a storage unit located outside the chip in the terminal device (e.g., a read-only memory, random access memory, etc.).
[0068] For example, a display unit is used to display the acquired image data.
[0069] The processing unit is used to perform face recognition on the first part of the image.
[0070] Thirdly, embodiments of this application provide a terminal device, including a processor and a memory, wherein the memory is used to store code instructions and the processor is used to run the code instructions to perform the method described in the first aspect or any possible implementation of the first aspect.
[0071] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program or instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0072] Fifthly, embodiments of this application provide a computer program product including a computer program, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0073] Sixthly, this application provides a chip or chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the methods described in the first aspect or any possible implementation thereof. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.
[0074] In one possible implementation, the chip or chip system described above in this application further includes at least one memory storing instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).
[0075] In a seventh aspect, this application provides yet another face recognition device, including a module for performing the method as described in any of the possible implementations of the first aspect.
[0076] It should be understood that the second to seventh aspects of this application correspond to the technical solutions of the first aspect of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be repeated here. Attached Figure Description
[0077] Figure 1 A schematic diagram illustrating the process of previewing and capturing images using a terminal device;
[0078] Figure 2 A schematic diagram of an image captured by a terminal device for identifying real and fake faces, as provided in an embodiment of this application.
[0079] Figure 3 A flowchart illustrating the face recognition method provided in this application embodiment;
[0080] Figure 4 A schematic diagram illustrating the training process of the real / fake face classification model provided in this application embodiment;
[0081] Figure 5 A schematic diagram illustrating the data preprocessing process provided in this application embodiment;
[0082] Figure 6 A schematic diagram illustrating the shooting distance between the subject and the terminal device during shooting, as provided in the embodiments of this application;
[0083] Figure 7 A schematic diagram of calibration images at different shooting distances provided in the embodiments of this application;
[0084] Figure 8 A schematic diagram of the calibration formula curve provided in the embodiments of this application;
[0085] Figure 9 A schematic diagram of a facial image based on facial key point coordinates provided in an embodiment of this application;
[0086] Figure 10 This application provides a schematic diagram illustrating the interaction between the software modules and hardware of a terminal device.
[0087] Figure 11 A schematic block diagram of the hardware architecture of a terminal device provided in an embodiment of this application;
[0088] Figure 12 This is a schematic block diagram of a face recognition device provided in an embodiment of this application. Detailed Implementation
[0089] To facilitate a clear description of the technical solutions in the embodiments of this application, some terms and technologies involved in the embodiments of this application will be briefly introduced below:
[0090] 1. Real people and real faces
[0091] In this embodiment of the application, "real person" can refer to a biological individual with living characteristics, particularly a human being, but it can also refer to an animal. A real person possesses biological characteristics such as metabolism, reaction ability, growth, and reproduction.
[0092] A real face refers to the face of a real person, which can express a wide range of emotions and has unique biometric features, such as iris and facial feature points. These features can be used to identify different faces and are often used in biometric technologies, such as facial recognition technology.
[0093] 2. Dummy people and fake faces
[0094] In this embodiment, a dummy can refer to an object lacking life characteristics and biological activity capabilities, particularly a humanoid object, but it can also refer to an animal-shaped object. In contrast to a real person, a dummy can also be understood as an object created to simulate a real person, such as a sculpture or model.
[0095] A fake face, also known as a non-realistic face, refers to a face sculpted or molded on a mannequin (such as a statue). The facial features of a fake face are typically static and cannot reproduce the dynamic expressions and subtle changes of a real face. While the design of a fake face may be based on artistic style, cultural background, or the image of a specific person, it lacks the complexity and dynamism of biometric features.
[0096] Examples of fake faces include, but are not limited to: 3D fake faces (such as the faces of Buddha statues, terracotta warriors, sculptures and bronze figures), 3D anthropomorphic faces (such as the faces of dolls, figurines, etc.), 2D fake faces (such as faces on printed paper, photographs, digital screens, etc.), and 2D anthropomorphic faces (such as the faces of illustrations, cartoon characters, etc.).
[0097] 3. Real vs. Fake Face Classification Model
[0098] A real / fake face classification model refers to a model, algorithm, or system that uses computer vision and machine learning techniques to distinguish between real and fake faces.
[0099] It should be understood that the real / fake face classification model can be a binary classification model (used to divide input data into two categories) or a multi-class classification model (used to divide input data into more than two categories). In the embodiments of this application, a binary classification model is used as an example to illustrate the training and usage process of the real / fake face classification model.
[0100] 4. Other terms
[0101] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and purpose. For example, "first chip" and "second chip" are used only to distinguish different chips and do not limit their order of execution. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.
[0102] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0103] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0104] 5. Terminal equipment
[0105] The terminal devices in this application embodiment may include handheld devices with facial recognition function, vehicle-mounted devices, etc. For example, some terminal devices include: mobile phones, tablets, PDAs, laptops, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to a wireless modem, in-vehicle devices, wearable devices, terminal devices in 5G networks, or future evolution of public land mobile communication networks. Terminal devices in a network (PLMN), etc., are not limited to this in the embodiments of this application.
[0106] By way of example and not limitation, in this embodiment, the terminal device can also be a wearable device. Wearable devices, also known as wearable smart devices, are a general term for devices that utilize wearable technology to intelligently design and develop everyday wearables, such as glasses, gloves, watches, clothing, and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothing or accessories. Wearable devices are not merely hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are feature-rich, large in size, and can achieve complete or partial functions without relying on a smartphone, such as smartwatches or smart glasses, as well as those that focus on a specific type of application function and require the use of other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.
[0107] Furthermore, in this embodiment of the application, the terminal device can also be a terminal device in an Internet of Things (IoT) system. IoT is an important component of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection.
[0108] The terminal device in this application embodiment may also be referred to as: electronic device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user equipment, etc.
[0109] In this embodiment, the terminal device or various network devices include a hardware layer, an operating system layer running on top of the hardware layer, and an application layer running on top of the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and main memory. The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux, Unix, Android, iOS, or Windows. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0110] With the rapid development of terminal technology, the photography capabilities of terminal devices have been significantly improved. Terminal devices can not only accurately identify faces using advanced face detection algorithms, but also transmit this detected facial information to subsequent processing modules. Through these modules, terminal devices can perform various beautification processes on faces, such as, but not limited to, portrait enhancement, beautification, makeup, auto exposure (AE), and auto focus (AF).
[0111] The application of face detection algorithms has significantly improved the imaging effect of the face area when the terminal device shoots portraits, thereby greatly enhancing the user's shooting experience.
[0112] For example, taking a mobile phone as an example, Figure 1 This is a schematic diagram illustrating the process of previewing and capturing images on a mobile phone.
[0113] like Figure 1 As shown in (a), this interface can be understood as the main interface displayed on the phone. This interface contains multiple icons or widgets, such as the camera app icon 101, etc.
[0114] When the terminal device displays Figure 1 When the interface shown in (a) is displayed, in response to the user's input operation on icon 101, such as clicking, the terminal device can display... Figure 1 The interface shown in (b) is a preview interface in portrait shooting mode. This interface can be understood as a preview window 105, a thumbnail control 103, and a camera control 104.
[0115] The preview window 105 displays a real-time preview image captured by the terminal device's camera. If the preview image includes a face, a face frame 102 can also be displayed on the face shown in the preview window 105.
[0116] The face bounding box 102 can be, for example, a rectangle (or other shapes), used to identify and highlight the face region when the image is captured. It is typically generated by a face detection algorithm to visually mark the location of detected faces.
[0117] The thumbnail control 103 includes a thumbnail of the captured image. In response to an input operation on the thumbnail control 103, such as clicking the thumbnail control 103, the terminal device can display the captured image. That is, the terminal device can display the latest captured frame image through the camera application.
[0118] The camera control 104 can be used to trigger the capture of an image.
[0119] When the terminal device displays Figure 1When the interface (b) is active, in response to an input operation that triggers the camera control 104, such as clicking the camera control 104, the terminal device can capture at least one image and display it. Figure 1 The interface (c) may include: a face frame 102, a thumbnail control 103, and a preview window 105.
[0120] It should be understood that Figure 1 (c) and Figure 1 The interface shown in (b) is similar. The differences include: Figure 1 In (c), the icon of the thumbnail control 103 is a thumbnail of the captured image obtained above.
[0121] Display on terminal device Figure 1 When the interface (c) is in progress, in response to an input operation on the thumbnail control 103, such as clicking the thumbnail control 103, the terminal device displays... Figure 1 The interface (d) in the image is the one that displays the captured image, which is image 106.
[0122] It should be understood that Figure 1 This is merely an example. In real-world applications, terminal devices can choose other shooting modes and launch camera applications in other ways. This application does not impose any specific limitations on these aspects.
[0123] The above describes the process by which a terminal device previews and captures images based on a face detection algorithm. Furthermore, in... Figure 1 During the shooting process shown, when the terminal device recognizes a face based on a face detection algorithm, the face can be beautified. For example, in... Figure 1 In the interfaces shown in (b) and (c), the face in the preview image displayed in preview window 105 can be a beautified face (not shown in the figure).
[0124] Furthermore, the images captured by the terminal device, such as Figure 1 The face in image 106 shown in (d) can also be a beautified face (not shown in the figure).
[0125] It should be understood that the above description is based on the example of a terminal device recognizing a face using a face detection algorithm (or face recognition algorithm). In actual application scenarios, terminal devices can also recognize faces based on other algorithms, models, or methods, and this application does not make any specific limitations on this.
[0126] However, in some scenarios, during the image capture process, terminal devices may misidentify artificial faces in terracotta warriors, Buddha statues, sculptures, and oil paintings as real faces, and perform unnecessary beautification processing, such as adding beauty filters or makeup (adding lipstick or enhancing eyebrows). This misidentification affects the realism and display effect of the image, resulting in a poor user shooting experience.
[0127] For example, such as Figure 2 As shown in (a), this image was captured when the terminal device correctly identified a real face and a dummy face. The subjects were a woman (a real person) and a dummy (such as a robot). In this case, the terminal device only enhanced the woman's face, as illustrated by adding lipstick and strengthening eyebrows. The dummy face, however, remained in its original state. This approach meets user expectations and maintains the naturalness and realism of the image.
[0128] However, as Figure 2 As shown in (b), this is an image captured when the terminal device incorrectly identifies a real face and a fake face. The terminal device incorrectly identifies a fake face as a real face, and therefore applies the same beautification processing to both the woman's and the fake face. This incorrect beautification applied to the fake face looks unnatural, resulting in a poor overall image quality.
[0129] In complex shooting environments or other environments where it is difficult to distinguish between real and fake faces, this misidentification phenomenon is more likely to occur, which in turn leads to the beautification of fake faces in the image, making the image unrealistic and affecting the user's shooting experience.
[0130] In view of this, embodiments of this application provide a face recognition method. A terminal device acquires image data and a shooting distance via a camera; determines the face pixel area 1 in the image data, and determines the face pixel area 2 based on the shooting distance, where the face pixel area 2 is a reasonable area; and determines the face detection result based on the difference between face pixel area 1 and face pixel area 2.
[0131] In this way, by obtaining the shooting distance, a reasonable face pixel area2 can be calculated. This calculation helps to determine whether the face pixel area1 in the image data meets expectations, thereby improving the accuracy of face recognition.
[0132] The following is combined Figures 3 to 9 The technical solutions of this application and how they solve the aforementioned technical problems are described in detail with specific embodiments. The following specific embodiments can be implemented independently or in combination with each other. Identical or similar concepts or processes may not be described again in some embodiments.
[0133] The embodiments shown in this application can be executed by a terminal device, a chip, chip system, or processor that supports the implementation of face recognition methods in the terminal device, or a logic module or software capable of implementing all or part of the functions of the terminal device. This application does not impose specific limitations in this regard.
[0134] The embodiments of this application are described below using a terminal device as the execution subject. The specific form and number of devices shown are merely examples and should not constitute any limitation on the implementation of the methods provided in this application.
[0135] Figure 3 This is a flowchart illustrating the face recognition method provided in an embodiment of this application. Figure 3 In the method 300 shown, facial images cropped from face bounding boxes can be combined with three different recognition methods to identify whether the faces in them are real faces.
[0136] Understandably, the process by which a terminal device generates the final human image (which can be a preview image or a captured human image) typically includes the following steps: image capture (camera acquiring image data), face recognition, image post-processing, special effects application, image storage (or image display), etc. Figure 3 The method 300 shown can be applied to the face recognition process. Based on the output of method 300, subsequent image post-processing, special effects (such as adding makeup effects) can be performed.
[0137] For example, combining Figure 1 Before displaying the preview image displayed in the preview window 105 or the captured image 106, the terminal device can identify whether the face in the image data collected by the camera is a real face according to method 300; and if the face is a real face, it can beautify the real face so that the beautified preview image or image 106 can be displayed.
[0138] Method 300 includes the following steps:
[0139] S301: The terminal device obtains the shooting distance and obtains the face frame based on the image data.
[0140] The shooting distance can be understood as the distance between the terminal device (or camera) and the subject being shot.
[0141] Alternatively, the terminal device can measure the phase difference of light using AF technology, or estimate the distance between the terminal device and the subject using laser ranging technology. Alternatively, the terminal device can also use a time-of-flight (ToF) sensor to emit infrared light and measure its return time to calculate the distance between the terminal device and the subject.
[0142] Image data can be understood as image data or pixel data of multiple initial images captured by the camera of a terminal device. The format of these multiple initial images can be raw data format, i.e., RAW format.
[0143] Obtaining face bounding boxes based on image data involves acquiring the face bounding box for each initial image. In other words, the terminal device acquires multiple initial images and performs face detection on each of these initial images to obtain the face bounding box.
[0144] A face bounding box can be understood as a marker used to identify and label the area where a face is located. For example, with... Figure 1 The face frame 102 is similar, but S301 is performed before the image is displayed, so obtaining the face frame is a step that is imperceptible to the user.
[0145] Obtaining a face bounding box can be understood as identifying the region where a face is located in image data.
[0146] For example, a terminal device can identify faces in image data using face detection algorithms and mark the area where the face is located using face bounding boxes. These algorithms scan image data, identify regions that match facial features, and draw rectangular boxes, i.e., face bounding boxes, on these regions. These features typically include the position and shape of features such as the eyes, nose, and mouth.
[0147] It should be understood that the face frame in this embodiment is a rectangle, but in actual application scenarios, the face frame can be replaced with other shapes, and this application does not make any specific limitations on this.
[0148] It should be noted that the process of the terminal device acquiring the face frame and shooting distance described above is for illustrative purposes only. In actual application scenarios, the terminal device can also acquire the face frame and shooting distance through other methods. This application embodiment does not specifically limit this.
[0149] S302. The terminal device expands the face frame and crops the image area corresponding to the expanded face frame to generate a new image.
[0150] Expanding the face bounding box can be understood as expanding or enlarging the detected face region (the face bounding box marker area) when processing image data. This allows more of the surrounding facial areas (such as hair, ears, and chin) to be included within the face bounding box, thus capturing more background information.
[0151] For example, the terminal device can expand the face frame (assuming the face frame width is W1 and the height is H1) by the following steps:
[0152] Determining the margin ratio: When determining the margin ratio, you need to choose an appropriate value, which is the margin added around the face frame. To provide sufficient background information while avoiding excessive background interference, a margin increase of 10% to 20% is usually chosen. Let's assume the chosen margin ratio is 10%.
[0153] Adjust the size of the face frame: Based on the determined expansion ratio, increase the width and height of the face frame respectively to generate the width and height of the expanded face frame.
[0154] The increased width is W2 = W1 × 10% × 2, and the increased height is H2 = H1 × 10% × 2. Here, ×2 indicates that margins need to be added around the face frame. The expanded face frame width is W = W1 + W2, and the expanded face frame width is W = W1 + 2 × W2.
[0155] Face bounding box check: Determine that the expanded face bounding box is still within the boundaries of the image data. Because expansion may cause the face bounding box to exceed the range of the image data (initial image), boundary checks and adjustments are required.
[0156] For example, if the expanded face bounding box remains within the boundaries of the image data, no adjustment is needed. If the expanded face bounding box extends beyond the boundaries of the image data, the expansion ratio can be readjusted (i.e., reduced) so that the expanded face bounding box remains within the boundaries of the image data.
[0157] After the terminal device expands the face frame, it crops the image area corresponding to the expanded face frame to generate a new image.
[0158] For example, the corresponding pixel data can be extracted from the image data based on the coordinates of the expanded face bounding box, a new image containing the expanded face region can be generated, and the image can be saved for further processing.
[0159] The number of new images is the same as the number of initial images. That is, for each of the initial images, a corresponding new image can be obtained by following the above process.
[0160] It should be noted that the fact that the number of new images is the same as the number of initial images is merely an example. In actual applications, the terminal device can also select a portion of the initial images and obtain new images through the above process, for example, selecting multiple images with higher resolution or better image quality. The specific implementation method is similar and will not be repeated here.
[0161] It should also be understood that S302 is an optional step. In practical applications, the image area marked with the face frame can also be directly cropped to obtain a new image.
[0162] Then, based on the new image, the terminal device can identify whether the face in it is a real face in three ways.
[0163] Method 1: Identification is performed using a real / fake face classification model (S303).
[0164] S303. Input a new image into the real / fake face classification model. The real / fake face classification model identifies the new image and outputs label 1. Label 1 is used to indicate whether the face in the new image is a real face.
[0165] For example, when the real / fake face classification model is a binary classification model, it can output two cases: whether the face in the new image is a real face or a fake face.
[0166] If the real / fake face classification model identifies that the number of real faces in a new image exceeds the number of fake faces, label 1 is used to indicate that the faces in the new image are real faces. If the real / fake face classification model identifies that the number of real faces in a new image does not exceed the number of fake faces, label 1 is used to indicate that the faces in the new image are fake faces.
[0167] It should be noted that the above-described real / fake face classification model for recognizing new images is for illustrative purposes only. In real-world applications, terminal devices can use other real / fake face classification models to recognize new images. This application does not impose specific limitations on this.
[0168] Method 2: Recognition is performed by comparing the face pixel area in the new image with the face pixel area determined based on the calibration formula (S304-S305).
[0169] S304. The terminal device calculates the face pixel area 1 in the new image and determines the face pixel area 2 based on the calibration formula.
[0170] For example, the terminal device can obtain the face pixel area of 1 by calculating the product of the width and height of the expanded face bounding box. See reference... Figure 5 As explained in the description, since the expanded face bounding box can include the complete face, the face pixel area 1 can be obtained based on the expanded face bounding box.
[0171] The face pixel area 2 determined based on the calibration formula can be understood as the face pixel area calculated by substituting the shooting distance into the calibration formula. The calibration formula is used to express the conversion relationship between shooting distance and face pixel area.
[0172] The calibration formula can be any formula, function, curve, or other form that can represent the conversion relationship between shooting distance and face pixel area, and can be preset in the terminal device.
[0173] S305. The terminal device compares the face pixel area 1 with the face pixel area 2 determined based on the calibration formula, and outputs label 2 according to the comparison result. Label 2 is used to indicate whether the face in the new image is a real face.
[0174] It's understandable that by calibrating the pixel area of a face at different shooting distances, a calibration formula can be obtained. The purpose of calibration is to establish the relationship between the pixel area of a face at different shooting distances and the distance (actual physical size), in order to calculate the pixel area of the face at different distances. The pixel area of a face can be understood as the number of pixels occupied by the face in an image. As the distance changes, the pixel area of the face in the image changes: the closer the distance, the more pixels the face occupies; the farther the distance, the fewer pixels the face occupies.
[0175] In other words, the face pixel area 2 determined based on the calibration formula is a reasonable face pixel area for capturing a real face at this shooting distance. Therefore, by comparing the face pixel area 1 and the face pixel area 2, it can be determined whether the face in the new image is a real face.
[0176] Since there are multiple new images, there are multiple face pixel areas of 1, and the two correspond one-to-one.
[0177] Since the shooting distance is a single value, the number of face pixel areas (2) is 1.
[0178] Based on multiple face pixel areas 1 and 2, a ratio of face pixel area 1 to face pixel area 2 for each face pixel area 1 can be obtained. There are multiple ratios in total, including the ratio of face pixel area 1 to face pixel area 2 for each face pixel area 1.
[0179] Optionally, for the plurality of ratios, when the number of first-type ratios is greater than the number of second-type ratios, label 2 is used to indicate that the face in the new image is a real face. When the number of first-type ratios is less than or equal to the number of second-type ratios, label 2 is used to indicate that the face in the new image is a fake face. The first-type ratio is the ratio among the plurality of ratios that falls within a preset range 1, and the second-type ratio is the ratio among the plurality of ratios that does not fall within the preset range 1. The ratios that fall within the preset range 1 can be: the ratio of face pixel area 1 to face pixel area 2 that is close to face pixel area 2, for example, close to 1, indicating that face pixel area 1 is a reasonable area.
[0180] Alternatively, label 2 indicates that the face in the new image is a real face when the number of first type ratios minus the number of second type ratios is greater than or equal to threshold 'a'. Label 2 indicates that the face in the new image is a fake face when the number of first type ratios minus the number of second type ratios is less than threshold 'a'. Threshold 'a' is a positive number.
[0181] It should be understood that, in addition to ratios, it is also possible to determine whether a face is real by the difference between the area of each face pixel 1 and the area of each face pixel 2. The specific implementation methods are similar and will not be described in detail here.
[0182] Method 3: Recognition based on facial key points (S306-S307).
[0183] S306. The terminal device determines the coordinates of facial key points in the new image.
[0184] For example, a terminal device can determine the coordinates of facial key points based on facial features (such as eyes, mouth, etc.) in each image of a new image.
[0185] S307. The terminal device determines whether the face is moving based on the coordinates of the facial key points in the new image, and outputs label 3 according to the judgment result. Label 3 is used to indicate whether the face in the new image is a real face.
[0186] The terminal device can determine whether a face is moving based on the coordinates of facial key points in at least two of multiple new images: facial movement is considered to have occurred when the ratio of the width of facial features in the two images is greater than or equal to a threshold of 2, and / or the ratio of their heights is greater than or equal to a threshold of 2. Facial features can be areas such as the eyes and mouth, determined based on the coordinates of facial key points. The threshold of 2 is a positive number greater than 1.
[0187] When the ratio of the width of facial features (such as eyes, mouth, etc.) in two images is less than a threshold of 2, and the ratio of their heights is also less than a threshold of 2, the face is considered to be motionless. The ratio of the width of facial features in two images is the ratio of the larger width to the smaller width. The ratio of their heights is the ratio of the larger height to the smaller height.
[0188] For example, assuming the terminal device selects the eyes as the facial feature, if the ratio of the eye height in the two images is greater than or equal to a threshold of 2, then the eyes are considered to be moving, i.e., the face is moving. If the ratio of the eye height in the two images is less than the threshold of 2, then the eyes are considered to be not moving, i.e., the face is not moving.
[0189] Furthermore, the height-to-width ratio represents the degree of change in facial features between two images. Therefore, the aforementioned ratio can, for example, be replaced by the absolute value of the difference.
[0190] Alternatively, if the ratio of the widths of facial features in two images (i.e., the ratio of the smaller width to the larger width) and the ratio of their heights (i.e., the ratio of the smaller height to the larger height) are both less than or equal to a threshold of 3, then facial movement is considered to exist. The threshold of 3 is a positive number less than 1.
[0191] When the ratio of the width of facial features (such as eyes, mouth, etc.) in the two images is greater than the threshold 3, and the ratio of their heights is also greater than the threshold 3, then the face is considered to be motionless.
[0192] It should be noted that the above process of determining facial movement based on eye movements is merely an example. In practical applications, terminal devices can determine facial movement based on other facial features, methods, or conditions. This application does not specifically limit this aspect.
[0193] When the terminal device determines that the face is moving based on the facial key point coordinates of the new image, label 3 is used to indicate that the face in the new image is a real face. When the terminal device determines that the face is not moving based on the facial key point coordinates of the new image, label 3 is used to indicate that the face in the new image is a fake face.
[0194] It should be noted that the execution of steps S303, 304-305, and S306-S307 does not strictly depend on the complete completion of the previous step. Specifically, steps S303 and 304-305 can be executed simultaneously or in parallel with steps S306-S307, or they can be performed with slight time intervals. This application does not impose specific limitations on this.
[0195] S308, the terminal device outputs the real and fake face detection results based on tag 1, tag 2 and tag 3.
[0196] In one possible implementation, if there are more labels among labels 1, 2, and 3 that indicate that the face in the new image is a real face, then the detection result is a real face; if there are more labels among labels 1, 2, and 3 that indicate that the face in the new image is a fake face, then the detection result is a fake face.
[0197] In another possible implementation, when label 3 indicates that the face in the new image is a real face, the output result is "real face". When label 3 indicates that the face in the new image is a fake face, the face detection result is determined by label 1 and label 2.
[0198] When label 2 indicates that the face in the new image is a fake face, the output result for face detection is "fake face". When label 2 indicates that the face in the new image is a real face, the face detection result is determined based on label 1, that is, the result indicated by label 1 is taken as the final result for face detection.
[0199] In this way, by combining information from multiple labels (label 1, label 2, label 3), facial features in an image can be evaluated more comprehensively. This multi-label decision-making mechanism can not only improve the accuracy and reliability of face recognition, but also enhance the robustness of the face recognition method, because different labels are judged based on different features or algorithms. Combining information from multiple labels can effectively reduce the risk of misjudgment by a single label.
[0200] It should be noted that the above-described terminal device outputs true / fake face detection results based on tags 1, 2, and 3 for illustrative purposes only. The terminal device may also output true / fake face detection results based on other judgment logic. This application embodiment does not specifically limit this.
[0201] Understandably, if the terminal device detects multiple faces (multiple facial regions) when acquiring face frames and shooting distances based on image data, it can execute S301 to S308 for each face (each facial region) separately to identify whether each face (each facial region) is a real face.
[0202] It should be noted that method 300 is merely an example. In actual application scenarios, terminal devices can determine whether a face is real or fake based on any one or two of methods 1, 2, and 3. The specific implementation methods are similar and will not be elaborated here for the sake of brevity.
[0203] The following is combined Figure 4 The training process of the real and fake face classification model is explained in detail.
[0204] S401. Obtain the dataset.
[0205] The dataset can be sourced from publicly available datasets and / or self-collected data. Self-collected data can be understood as real and fake face images acquired through cameras or other devices under different environments, lighting conditions, and angles, based on specific application requirements.
[0206] S402, Data Preprocessing.
[0207] Since the images acquired by S401 may contain a lot of irrelevant background information, preprocessing is required to improve the training effect of the real and fake face classification model.
[0208] For example, in combination Figure 5 The data preprocessing process is described in detail. For example... Figure 5 As shown in (a), this is an image from the dataset obtained by S401 that contains both real and fake faces.
[0209] By using face detection algorithms Figure 5Face detection is performed on the image shown in (a). Face regions can be identified, and the results of the face detection can be as follows: Figure 5 As shown in (b) above. In this case, the face frame is small and only covers the face.
[0210] right Figure 5 The face bounding box shown in (b) is expanded outwards to include more background information (such as hair, ears, etc.), for example, by 20%. The result of the expansion can be as follows: Figure 5 As shown in (c) in the figure, with Figure 5 Compared to (b) in the middle, Figure 5 The expanded face frame shown in (c) is larger and contains more background information.
[0211] right Figure 5 By cropping the face area covered by the expanded face frame shown in (c), we can obtain the following: Figure 5 The preprocessed data (i.e., preprocessed real and fake face images) is shown in (d) in the figure.
[0212] It should be noted that the above cropping process can also be performed directly after face recognition. Furthermore, besides... Figure 5 In addition to cropping the face region shown in (c), the size of the cropped image can also be adjusted to suit the input requirements of the real / fake face classification model. This application does not specifically limit this aspect.
[0213] S403, Model Selection.
[0214] Depending on the application scenario, an appropriate model structure can be selected to identify real and fake faces in the preprocessed data. For example, a binary classification model or a multi-class classification model can be selected as the real / fake face classification model for subsequent processing.
[0215] S404, Training of Real and Fake Face Classification Model.
[0216] The preprocessed data is used to train a real / fake face classification model. During training, the loss between the model's predictions and the labels (i.e., whether the input image is a real or fake face, indicating an accurate result) is calculated. The model's parameters are then adjusted based on this loss (calculated during training, indicating the degree of difference between the prediction and the label) to optimize accuracy. This process is repeated until the calculated loss meets the preset requirements.
[0217] After the above steps, a trained real / fake face classification model is finally obtained, which can be used for... Figure 3This refers to a face recognition method. Given any face image, the real / fake face classification model can output whether the image represents a real or fake face.
[0218] It should be understood that when acquiring a dataset, the ratio of real faces to fake faces should not exceed five times to avoid the real / fake face classification model biasing towards recognizing the category with the larger number of faces. In practical applications, the data ratio can be adjusted according to specific recognition needs. For example, if recognition focuses more on fake faces, the proportion of fake face data can be increased to improve the real / fake face classification model's ability to recognize fake faces.
[0219] The following is combined Figure 6 right Figure 3 This section details the method for obtaining the shooting distance. This method allows for the acquisition of shooting distance without relying on additional hardware. Figure 6 In the image, a dotted line with a double-headed arrow indicates the distance between the subject (the woman) and the terminal device.
[0220] S601, The terminal device acquires the region of interest (ROI) and the face bounding box region that are in focus.
[0221] In image processing and other fields, ROI refers to the part of an image that requires special attention. In portrait photography, ROI typically refers to the identified facial region. The face bounding box region is the rectangular area in an image marked with facial recognition technology, such as... Figure 6 The image region identified by the face bounding box.
[0222] It should be understood that when a terminal device takes a portrait, the terminal device can automatically recognize the face and generate the corresponding face frame, while providing ROI information during the focusing process.
[0223] S602. The terminal device determines whether the ROI is within the face frame area, that is, whether the focus is on the face frame.
[0224] This step determines whether the focus is aligned with the face bounding box, thus improving measurement accuracy. If the ROI is within the face bounding box area, it indicates that the focus is aligned with the face bounding box.
[0225] S603, terminal device obtains shooting distance.
[0226] When the focus is on the face frame, the device returns the AF distance and uses it as the shooting distance. When the focus is not on the face frame, the device re-acquires the shooting distance.
[0227] Here, AF distance refers to the distance between the subject and the terminal device, obtained through various methods, when the terminal device's camera is focused on a face. For example, when the terminal device is capturing a face, it can adjust the camera's position by driving a motor to find the optimal focus point. During this process, the terminal device can accurately record the motor position corresponding to the optimal focus point (this position represents the change relative to the camera's initial position), and then convert the motor position into AF distance based on a preset mapping relationship between motor position and AF distance.
[0228] Optionally, if the terminal device is equipped with a laser rangefinder, the laser distance can be acquired simultaneously. The accuracy of the distance information can be verified by comparing the AF distance and the laser distance. When the two distance information are close, the distance information is considered accurate, and either the AF distance or the laser distance can be returned as the final shooting distance. If the two distance information are inconsistent, the shooting distance needs to be acquired again.
[0229] The methods described above for obtaining shooting distance rely on focus information. However, on some terminal devices lacking focus information, a monocular depth estimation model can be used to obtain depth information of the face bounding box region. By inputting the image into the model, the shooting distance can be obtained, usually represented by color intensity, with darker colors indicating a closer shooting distance.
[0230] It should be noted that, in addition to the methods mentioned above for obtaining shooting distance, terminal devices can also use other methods to obtain shooting distance based on different business needs and device configurations.
[0231] The following is combined Figure 7 right Figure 3 The calibration process of the calibration formula in the document will be explained in detail.
[0232] Understandably, the pixel area of a real face in an image typically follows a certain distribution range. For example, when photographed at a distance of one meter, the pixel area of an adult's face is approximately 500*500 pixels, while that of a child's face might be around 300*300 pixels. In contrast, when photographed at the same distance, the pixel area of a fake face often appears abnormally large or small. Therefore, by comparing the pixel areas of real and fake faces, it is possible to effectively distinguish between them.
[0233] The specific calibration process is as follows:
[0234] First, photographs are taken of the calibration test subjects (including women, men, and children) standing at different distances to obtain calibration images. Multiple distances should be included in the photographs, such as 40cm, 60cm, 80cm, 100cm, and 120cm.
[0235] For example, such as Figure 7 Image (a) shows calibration image 1 obtained at a relatively close shooting distance (e.g., 40cm). Figure 7 As shown in (b), this is calibration image 2 obtained at a suitable shooting distance (e.g., 80cm). Figure 7 As shown in (c), this is the calibration image 3 obtained when the shooting distance is relatively far (e.g., 120cm).
[0236] Then, after acquiring multiple calibration images, a face detection algorithm can be used to calculate the face pixel area in each calibration image (similar to the method of calculating face pixel area).
[0237] Finally, a calibration formula was fitted based on the shooting distance and the pixel area of the real face.
[0238] By calibrating the pixel area of real faces at different distances, a calibration formula can be fitted:
[0239] y=f(x) formula (1)
[0240] Where x represents the shooting distance, and y represents the pixel area of the real face when the shooting distance is x.
[0241] When fitting the calibration formula, a suitable formula can be selected based on specific needs. For example, the formula y = Ae can be used. -kx +C (where A, k, and C are constants, and A≠0, k≠0) fits the shooting distance and the pixel area of the real face.
[0242] After fitting, the calibration formula can be obtained, and the curve of the calibration formula can be shown as follows: Figure 8 As shown. Thus, in practical applications, the expected face pixel area 2 can be calculated using a calibration formula based on the shooting distance. Then, by comparing the face pixel area 2 determined based on the calibration formula with the face pixel area 1 calculated by the terminal device, real and fake faces can be identified.
[0243] Optionally, different calibration formulas can be used for different groups of people. For example, following a similar approach, a calibration formula corresponding to female test subjects can be obtained; a calibration formula corresponding to male test subjects can be obtained, and so on. In this way, when determining the face pixel area based on the calibration formula and the shooting distance, the face pixel area can be calculated using the corresponding calibration formula for different groups of people, resulting in higher accuracy in determining the face pixel area.
[0244] The specific process of identifying real and fake faces by comparing the face pixel area 2 determined based on the calibration formula with the face pixel area 1 calculated by the terminal device is as follows:
[0245] S701, terminal equipment usage as follows Figure 6 The method shown obtains the face bounding box and shooting distance in the captured image (assuming the subject includes a real person 1 and a dummy 2).
[0246] S702, The terminal device calculates the face pixel area y corresponding to the face bounding box in the captured image. p Assuming the calculated pixel area y of real person 1's face. p1 =87545 pixels, the pixel area of the face of dummy 2 is y p2 = 22134 pixels.
[0247] S703, The terminal device substitutes the shooting distance x into the calibration formula y = Ae -kx In C (where A, k, and C are constants, and A≠0, k≠0), the face pixel area y corresponding to the shooting distance x is calculated. t Assuming a shooting distance of 150cm, the calculated pixel area of a real face is y. t = 88101 pixels.
[0248] S704. When the face pixel area 2 determined based on the calibration formula is close to the face pixel area 1 calculated by the terminal device, it is considered to be a real face; otherwise, it is a fake face.
[0249] For example, the terminal device can determine whether the face pixel area 2 determined based on the calibration formula is close to the face pixel area 1 calculated by the terminal device using the following method:
[0250] When y p With y t The ratio is in the interval If the pixel area of the face is close, it is considered a real face; otherwise, it is considered a fake face.
[0251] It should be noted that other factors can be considered when calibrating the pixel area of a real face. This application does not impose specific limitations on this.
[0252] For example, when a real face is facing the terminal device, the face pixel area is relatively large. However, when the real face is rotated at a certain angle relative to the terminal device, the face pixel area is relatively small. Therefore, the facial angle factor can be considered during the calibration process, and a calibration formula y = f(x,z) that includes the facial angle can be fitted, where z represents the facial angle.
[0253] The following is combined Figure 9 right Figure 3 The process by which a mid-terminal device determines whether there is facial movement based on the coordinates of key facial points is explained in detail.
[0254] In facial recognition, the presence or absence of facial movement can be used to distinguish between real and fake faces. Real faces may exhibit noticeable facial movements during the photographing process, such as opening and closing the eyes, opening and closing the mouth, etc. Fake faces (such as terracotta warriors, Buddha statues, images on printed paper or billboards) are usually static and do not show these facial changes. Therefore, facial movement can be used as a feature to identify real faces.
[0255] During the process of capturing portraits on a terminal device, facial motion detection algorithms can identify and analyze key information of facial features (such as eyes and mouth) in real time. This process can be understood as the terminal device acquiring a series of time-series images and analyzing them. Assuming a sampling frequency of 5, meaning one frame is sampled at fixed time intervals, the facial motion detection algorithm can acquire 5 frames within a time window.
[0256] During the above process, the facial features of the subject may change. For example, such as... Figure 9 As shown in (a), this is an image of the subject in its normal state; as Figure 9 As shown in (b), this is an image of the subject with their eyes closed; as Figure 9 As shown in (c), this is an image of the subject with their mouth open. By analyzing these three frames, the facial motion detection algorithm was able to identify changes in the subject's eyes (opening and closing) and mouth (opening and closing) throughout the entire shooting process. These feature changes indicate that the subject is a real person with a realistic face.
[0257] The specific basis for facial motion detection algorithms to analyze multi-frame images is to determine whether the facial feature motion based on key point coordinates reaches a preset threshold. When the facial feature motion exceeds the preset threshold, it is considered that the face has motion; otherwise, it is considered that the face has no motion. Assume that the eye motion threshold (i.e., the percentage change in eye height) is t1 = 1.75, and the mouth motion threshold (i.e., the percentage change in mouth height) is t2 = 1.5.
[0258] For example, suppose in such Figure 9 In the initial state shown in (a), the key point coordinate 1 of the eye is determined, and based on the key point coordinate 1, the height of the subject's eye is determined to be 1 cm. However, in the case of... Figure 9 In the image shown in (b), the key point coordinate 2 of the eye is determined, and based on the key point coordinate 2, the height of the subject's eye is determined to be 0.1 cm. The change in eye height is 10 times, which exceeds the set threshold t1, therefore it can be determined that the eye is in motion.
[0259] Similarly, regarding mouth movements, assuming in the following... Figure 9In the initial state shown in (a), the coordinates of the key point 3 of the mouth are determined, and the height of the mouth is determined to be 2 cm based on the coordinates of key point 3. In the case of... Figure 9 In the image shown in (c), the key point coordinate 4 of the mouth is determined, and based on the key point coordinate 4, it is determined that the height of the mouth has changed to 4 centimeters. At this time, the change ratio of the mouth height is 2 times, which exceeds the set threshold t2, so it can be determined that the mouth is in motion.
[0260] By determining facial movement based on key point coordinates, terminal devices can effectively identify real faces. This recognition method provides a data foundation for subsequent image enhancement and analysis.
[0261] It should be noted that, in addition to the eyes and mouth, other facial features (such as eyebrows and cheeks) can also be used to determine whether there is facial movement. In this way, the terminal device can be expanded to include more facial features as needed to improve the accuracy and robustness of facial recognition. This application does not specifically limit this aspect.
[0262] To better understand the terminal device in the embodiments of this application, the following is combined with... Figure 10 The interaction between the software modules and hardware of the terminal device in the embodiments of this application will be described in detail.
[0263] Figure 10 This is a schematic diagram of the architecture (including software system and some hardware) used in the embodiments of this application. Figure 10 As shown, the application architecture is divided into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the application architecture can be divided into five layers, from top to bottom: the application layer, the application framework (FWK) layer, the hardware abstraction layer (HAL), the kernel layer, and the hardware layer.
[0264] like Figure 10 As shown, the application layer can include applications such as camera, gallery, and system UI. The system UI is used to display the interface of the terminal device, such as displaying images captured by the terminal device.
[0265] like Figure 10 As shown, the application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer includes some predefined functions.
[0266] The application framework layer may include a camera access interface. This interface can handle requests from applications (such as camera apps) and forward them to the camera HAL. It can also be used to manage the camera's lifecycle and resource allocation. Furthermore, the camera access interface can be used to set parameters related to image capture, such as resolution, frame rate, focus mode, exposure compensation, white balance, and flash mode; these parameters may be specified by the application.
[0267] The HAL layer is a wrapper around Linux kernel drivers, providing interfaces to the upper layers and shielding them from the implementation details of the underlying hardware. The HAL layer includes a camera hardware abstraction module (such as the camera HAL) and a camera algorithm library.
[0268] The camera HAL (Host Allocation Array) can be used to translate commands or requests from the camera access interface into commands that the hardware (such as the camera) can understand. It can be used to interact with hardware (such as the camera). For example, the camera HAL can be used to set certain camera parameters, such as sensor initialization (e.g., camera operating mode), image processing parameters (e.g., noise reduction, sharpening, color correction), buffer management (e.g., setting buffer size and format), and camera frame synchronization.
[0269] The camera hardware abstraction module can include multiple camera devices, such as camera device 1, camera device 2, etc.
[0270] The camera algorithm library includes a post-processing algorithm module and a face recognition module.
[0271] A face recognition module can be used to analyze images captured by a camera to determine whether they contain human faces. If a face is detected, the module can further determine whether the face is real or fake. For example, this can be implemented within a face recognition module. Figure 3 The method 300 shown outputs the results of real and fake face detection.
[0272] The post-processing algorithm module can be used to perform various beautification processes on the real faces identified by the face recognition module, such as, but not limited to, beautification or makeup (adding lipstick or enhancing eyebrows, etc.). Through these different processing methods, image quality can be effectively improved.
[0273] The kernel layer is the layer between hardware and software. For example, the kernel layer can be used to drive hardware resources. The kernel layer can include multiple driver modules. Figure 10 As shown, the kernel layer includes camera device drivers, digital signal processor (DSP) drivers, and graphics processing unit (GPU) drivers, etc.
[0274] The hardware layer includes sensors, image signal processors, digital signal processors, and graphics processors. Sensors may include devices such as cameras. Image signal processors (ISPs) may include ISP modules.
[0275] Understandable. Figure 10 The diagram illustrates an example of software modules included in a terminal device. Each layer of the terminal device's software architecture may also include more or fewer software modules. For example, the application layer of the terminal device may also include other applications, such as messaging, alarm clock, weather, stopwatch, compass, timer, flashlight, calendar, Alipay, etc. This application does not specifically limit the scope of the application.
[0276] Figure 11 This is a schematic diagram of the structure of the terminal device 1100 provided in an embodiment of this application. Figure 11 As shown, the terminal device 1100 may include a processor 1110, an external memory interface 1120, an internal memory 1121, a universal serial bus (USB) interface 1130, a charging management module 1140, a power management module 1141, a battery 1142, an antenna 1, an antenna 2, a mobile communication module 1150, a wireless communication module 1160, an audio module 1170, a sensor module 1180, a button 1190, a motor 1191, an indicator 1192, a camera 1193, a display screen 1194, and a subscriber identification module (SIM) card interface 1195, etc.
[0277] The audio module 1170 may include a speaker, receiver, microphone, and headphone jack. The sensor module 1180 may include a pressure sensor, gyroscope sensor, barometric pressure sensor, magnetic sensor, accelerometer, distance sensor, proximity sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor, bone conduction sensor, etc.
[0278] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the terminal device 1100. In other embodiments of this application, the terminal device 1100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0279] Processor 1110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0280] In some examples, processor 1110 can be a system-on-chip (SOC) of terminal device 1100. In one possible implementation, processor 1110 can predict whether the image region (new image) corresponding to the expanded face bounding box is a real face based on a real / fake face classification model, and output a label to indicate whether it is a real or fake face.
[0281] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0282] The processor 1110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 1110 is a cache memory. This memory can store instructions or data that the processor 1110 has just used or that are used repeatedly. If the processor 1110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 1110, and thus improves the efficiency of the system.
[0283] In some embodiments, processor 1110 may include one or more interfaces.
[0284] The terminal device 1100 implements display functions through a GPU, a display screen 1194, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 1194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 1110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0285] The display screen 1194 is used to display images, videos, etc. The display screen 1194 includes a DDIC and a display panel. In some embodiments, the terminal device 1100 may include one or N display screens 1194, where N is a positive integer greater than 1.
[0286] Internal memory 1121 can be used to store computer executable program code, which includes instructions. Internal memory 1121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of terminal device 1100 (such as audio data, phonebook, etc.). Furthermore, internal memory 1121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 1110 executes various functional applications and data processing of terminal device 1100 by running instructions stored in internal memory 1121 and / or instructions stored in memory located in the processor.
[0287] It should be understood that Figure 11 The connection relationships between the modules shown are merely illustrative and do not constitute a limitation on the connection relationships between the modules of the terminal device 1100. Optionally, the modules of the terminal device 1100 may also adopt a combination of various connection methods described in the above embodiments.
[0288] Figure 12 This is a schematic block diagram of a face recognition device 1200 provided in an embodiment of this application. The device 1200 includes a processor 1201, a transceiver 1202, and a memory 1203. The processor 1201, transceiver 1202, and memory 1203 communicate with each other via internal interconnection. The memory 1203 stores instructions, and the processor 1201 executes the instructions stored in the memory 1203. The transceiver 1202 can be used to send signals to other devices (e.g., the processor 1201 or the touchscreen of a terminal device) and to receive signals from other devices (e.g., the memory 1203). For example, the transceiver 1202 reads instructions stored in the memory 1203 and sends the instructions to the processor 1201.
[0289] It should be understood that the device 1200 may specifically be the UE in the above embodiments, and may be used to execute the various steps and / or processes corresponding to the UE in the above method embodiments. Optionally, the memory 1203 may include read-only memory and random access memory, and provide instructions and data to the processor. A portion of the memory may also include non-volatile random access memory. For example, the memory may also store device type information. The processor 1201 may be used to execute instructions stored in the memory, and when the processor 1201 executes instructions stored in the memory, the processor 1201 is used to execute the various steps and / or processes in the above method embodiments.
[0290] It should be understood that, in the embodiments of this application, the processor may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0291] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or as a combination of hardware and software modules within the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor executes the instructions in the memory, combining them with its hardware to complete the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0292] The face recognition method provided in this application can be applied to terminal devices with communication functions. Terminal devices include electronic devices, and the specific form of these electronic devices can be referred to the above description, which will not be repeated here.
[0293] This application provides a terminal device, which includes a processor and a memory; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, causing the terminal device to perform the above-described method.
[0294] This application provides a chip. The chip includes a processor, which is used to call a computer program in memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those in the related embodiments described above, and will not be repeated here.
[0295] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, it implements the methods described above. The methods described in the above embodiments can be implemented wholly or partially by software, hardware, firmware, or any combination thereof. If implemented in software, the functionality can be stored as one or more instructions or code on or transmitted over the computer-readable medium. The computer-readable medium can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.
[0296] In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage or other magnetic storage devices, or any other medium targeted to carry or to store the required program code in the form of instructions or data structures, and accessible by a computer. Furthermore, any connection is appropriately referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disks and optical discs include optical discs, laser discs, optical discs, Digital Versatile Discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0297] This application provides a computer program product, which includes a computer program that, when run, causes a computer to perform the above-described method.
[0298] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing device, generate instructions for implementing the flowchart illustrations. Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0299] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.
Claims
1. A face recognition method, characterized in that, Applied to terminal devices, including: Receive a first operation, which triggers the capture of an image; Based on the first operation, first image data and a first distance are obtained, wherein the first distance is the distance between the terminal device and the target being photographed; Calculate the area of the first face based on the first image data; Calculate the area of the second face based on the first distance; Based on the first face area and the second face area, a target result is obtained, which is used to indicate whether the face in the first image data is a real face.
2. The method according to claim 1, characterized in that, The calculation of the area of the second face includes: Based on the first distance and the calibration formula, the second face area is calculated, wherein the calibration formula is used to describe the face area at different shooting distances.
3. The method according to claim 1 or 2, characterized in that, The step of calculating the area of the first face based on the first image data includes: Perform face recognition on the first image data to determine a first part of the image, wherein the first part of the image includes some or all of the faces in the first image data; Based on the first portion of the image, the area of the first face is calculated.
4. The method according to claim 3, characterized in that, Determining the first portion of the image includes: Face recognition is performed based on the first image data to determine a first region, which is the region selected by the face bounding box; The first region is expanded to obtain a second region, the area covered by the second region being greater than or equal to the area covered by the first region; The image corresponding to the second region is cropped to obtain the first part of the image.
5. The method according to any one of claims 1 to 4, characterized in that, The process of obtaining the target result based on the first face area and the second face area includes: Based on the first face area and the second face area, a first result is determined; Based on the first result, and the second and / or the third result, the target result is determined, wherein the second result is determined based on the first model to perform real and fake face recognition on the first image data, and the third result is determined based on the facial key points in the first image data.
6. The method according to claim 5, characterized in that, The second result is determined based on the first model to identify real and fake faces in the first part of the image. The third result is determined based on the facial key points in the first part of the image, where the first part of the image includes some or all of the faces in the first image data.
7. The method according to claim 6, characterized in that, The first image data consists of image data from multiple images, and the first portion of images includes a face region image from each of the multiple images; The method further includes: Identify the first facial key points in the first facial region image among multiple facial region images; Identify the key points of the second face in the second face region image among multiple face region images; The third result is determined based on the first facial landmark and the second facial landmark.
8. The method according to claim 7, characterized in that, The process of determining the third result based on the first facial landmark and the second facial landmark includes: The third result is determined based on the difference between the first height and the second height, wherein the first height is the height of the first facial features determined based on the first facial key points, and the second height is the height of the first facial features determined based on the second facial key points.
9. The method according to any one of claims 5 to 8, characterized in that, The determination of the target result includes: When the third result is used to indicate that the face in the first image data is a real face, the target result is used to indicate that the face in the first image data is a real face.
10. The method according to claim 9, characterized in that, The method further includes: If the third result indicates that the face in the first image data is a fake face, the target result is determined based on the first result and the second result.
11. The method according to claim 10, characterized in that, Determining the target result based on the first result and the second result includes: When the first result is used to indicate that the face in the first image data is a fake face, the target result is used to indicate that the face in the first image data is a fake face; When the first result is used to indicate that the face in the first image data is a real face, the target result is the same as the second result.
12. The method according to claim 5 or 11, characterized in that, The method further includes: The first part of the image is input into the first model, and the first model outputs the second result.
13. The method according to claim 12, characterized in that, The method further includes: Obtain training samples, which include multiple real face images and multiple fake face images; Face recognition is performed on the faces in the training samples to determine a third region, which is the region corresponding to the face; The third region is expanded to obtain a fourth region, the area covered by the fourth region being greater than or equal to the area covered by the third region; Cropping the image corresponding to the fourth region yields multiple second-part images; The initial model is input with the plurality of second-part images, and the initial model outputs a prediction result, which is used to indicate whether the face in each of the plurality of second images is a real face or a fake face. The initial model is adjusted based on the prediction results until the first model is obtained.
14. A terminal device, characterized in that, include: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the terminal device to perform the method as described in any one of claims 1-7.
15. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-13.
16. A chip system, characterized in that, It includes at least one processor and a communication interface, the communication interface and the at least one processor being interconnected via a line, the at least one processor being configured to run a computer program or instructions to perform the method as described in any one of claims 1-13.
17. A computer program product, characterized in that, Includes a computer program that, when run, causes a computer to perform the method as described in any one of claims 1-13.
