Method, device and computer equipment for modifying pictures based on face recognition

The face recognition technology is used to calculate the deflection angle of the face in the picture, and the 3D model is used to adjust the angle of the replacement picture, which solves the problem of uncoordinated replacement angles of side face pictures in the existing technology and achieves a more realistic image processing effect.

CN110163814BActive Publication Date: 2024-09-20PING AN TECH (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN201910305175.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-16
Publication Date
2024-09-20
Estimated Expiration
2039-04-16

AI Technical Summary

Technical Problem

When existing image processing software replaces side face pictures, it is difficult to coordinate the angles of the face and body, resulting in disharmony in the processed pictures.

Method used

Through face recognition technology, the deflection angle of the face in the picture is calculated, and the 3D model is called for projection, and the angle of the replacement picture is adjusted to make it consistent with the angle of the original picture to achieve angle coordination.

Benefits of technology

This ensures that the replaced pictures are more realistic, with coordinated angles, and improves the effect of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110163814B
    Figure CN110163814B
Patent Text Reader

Abstract

The present application discloses a method, device and computer equipment for modifying an image based on face recognition, wherein the method includes: extracting a face image in a video after receiving an instruction to modify an image from a user, wherein the instruction includes an object to be loaded on the face image; calculating the deflection angle of the face image, and calling a 3D model corresponding to the object in a database; projecting the 3D model according to the deflection angle to obtain a replacement image; and loading the replacement image on the face image. When replacing a face image, the present application replaces the angle of the pre-replaced face to the same deflection angle as the face in the video according to the deflection angle of the face in the image or video, so that the replaced image is more realistic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device and computer equipment for modifying an image based on face recognition. Background Art

[0002] There are many image processing software on the market, which can automatically identify the face of the person in the image to be processed, and then replace the other faces that the user needs to replace with the face in the image to be processed. However, when the face of the person in the image is sideways, the other facial information that the user needs to replace is straight, resulting in an inconsistent angle between the face and the body in the processed image. Summary of the invention

[0003] The main purpose of the present application is to provide a method, device and computer equipment for modifying pictures based on face recognition, which can modify pictures according to the deflection angle of the face in the picture.

[0004] In order to achieve the above-mentioned invention object, the present application proposes a method for modifying an image based on face recognition, comprising:

[0005] After receiving a command from a user to modify a picture, extracting a face image in the video, wherein the command includes an object to be loaded on the face image;

[0006] According to the formula: y=18.75x 2 -135x+116.25, calculate the deflection angle of the face image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the face image to the size of the corresponding right organ;

[0007] Projecting the 3D model according to the deflection angle to obtain a replacement image;

[0008] The replacement picture is loaded onto the face image.

[0009] Furthermore, the 3D model is a 3D face model, and the step of projecting the 3D model according to the deflection angle to obtain a replacement image includes:

[0010] After preprocessing the facial image, the facial image is input into a trained expression recognition model for recognition to obtain the expression of the facial image;

[0011] Obtaining a first feature point of the 3D face model and an adjustment matrix corresponding to the expression, wherein the correspondence between the expression and the adjustment matrix is ​​preset;

[0012] Multiplying the first feature point by the adjustment matrix to obtain the second feature point;

[0013] Mapping the second feature point onto the 3D face model, and controlling the 3D face model to simulate the expression;

[0014] After the 3D face model simulating the expression is rotated by the degree of the deflection angle, it is mapped on the back side of the 3D face model when it is not rotated for projection, so as to obtain a replacement image.

[0015] Furthermore, the 3D model is a 3D face model, and the step of projecting the 3D model according to the deflection angle to obtain a replacement image includes:

[0016] Inputting the facial image into a preset organ recognition model to obtain a first organ in the facial image;

[0017] The first organ and the second organ in a preset normal state are used to establish matrices with the same number of rows and columns according to the pigment difference, thereby obtaining a first matrix and a second matrix respectively;

[0018] Subtracting the second matrix from the first matrix to obtain a matrix difference;

[0019] Calculating the rank of the matrix difference;

[0020] Calling a preset correspondence between a rank and a facial action, and obtaining the facial action corresponding to the first organ according to the rank of the matrix difference;

[0021] Controlling various organs of the 3D face model to simulate the facial movements;

[0022] After the 3D face model simulating the facial action is rotated by the degree of the deflection angle, it is mapped on the back side of the 3D face model when it is not rotated for projection, so as to obtain a replacement image.

[0023] Furthermore, the step of loading the replacement picture onto the face image comprises:

[0024] Obtaining the size of the display screen in the terminal's attribute information and the proportion of the face image to the display screen in the playback interface;

[0025] Simulate loading the face image on a playback interface, and calculate the size of the face image on the playback interface;

[0026] Calculating the ratio between the size of the face image and a preset standard size;

[0027] Scaling the replacement image according to the ratio;

[0028] The scaled replacement image is loaded onto the face image.

[0029] Furthermore, after receiving the instruction to modify the picture from the user, the step of extracting the face image in the video includes:

[0030] After receiving the instruction to replace the face from the user, the frame image in the video is collected;

[0031] The frame image is input into a preset face recognition model, and the face image is output.

[0032] Furthermore, before the step of inputting the frame image into a preset face recognition model to output the face image, the step includes:

[0033] A plurality of pictures containing face images in a training set are input into a preset neural network model for training, and a neural network model for identifying faces in the pictures is obtained as the face recognition model.

[0034] Furthermore, after the step of loading the replacement picture onto the face image, the following steps are included:

[0035] Obtaining attribute information of the object;

[0036] Determining whether the attribute information is facial information;

[0037] If so, delete the face image.

[0038] The present application also provides a device for modifying an image based on face recognition, comprising:

[0039] An extraction module, configured to extract a face image in a video after receiving a command from a user to modify a picture, wherein the command includes an object to be loaded on the face image;

[0040] Calculate the angle module according to the formula: y=18.75x 2 -135x+116.25, calculate the deflection angle of the face image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the face image to the size of the corresponding right organ;

[0041] A projection module, used for projecting the 3D model according to the deflection angle to obtain a replacement image;

[0042] A loading module is used to load the replacement image onto the face image.

[0043] The present application also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.

[0044] The present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the above-mentioned methods are implemented.

[0045] The method, device and computer equipment for modifying images based on face recognition of the present application, when replacing a face image, replaces the angle of the pre-replaced face to the same deflection angle as the face in the video according to the deflection angle of the face in the image or video, so that the replaced image is more realistic. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is a flow chart of a method for modifying an image based on face recognition according to an embodiment of the present application;

[0047] Figure 2 This is a schematic block diagram of the structure of a device for modifying an image based on face recognition according to an embodiment of the present application;

[0048] Figure 3 This is a schematic block diagram of the structure of a projection module of an apparatus for modifying an image based on face recognition according to an embodiment of the present application;

[0049] Figure 4 This is a schematic block diagram of the structure of a projection module of an apparatus for modifying an image based on face recognition according to an embodiment of the present application;

[0050] Figure 5 This is a schematic block diagram of the structure of a loading module of a device for modifying an image based on face recognition according to an embodiment of the present application;

[0051] Figure 6 This is a schematic block diagram of the structure of a device for modifying an image based on face recognition according to an embodiment of the present application;

[0052] Figure 7 This is a schematic block diagram of the structure of a device for modifying an image based on face recognition according to an embodiment of the present application;

[0053] Figure 8 A schematic block diagram of the structure of a computer device according to an embodiment of the present application.

[0054] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0056] Reference Figure 1 The embodiment of the present application provides a method for modifying a picture based on face recognition, comprising the steps of:

[0057] S1. extracting a face image in a video after receiving a command from a user to modify a picture, wherein the command includes an object to be loaded on the face image;

[0058] S2. According to the formula: y=18.75x 2 -135x+116.25, calculate the deflection angle of the face image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the face image to the size of the corresponding right organ;

[0059] S3, projecting the 3D model according to the deflection angle to obtain a replacement image;

[0060] S4, loading the replacement picture onto the face image.

[0061] As described in step S1 above, the execution subject of this embodiment is applied to an image processing APP on a mobile phone, and the execution subject is the processor of the mobile phone. After the APP loads the video file, the processor receives the modified picture sent by the user, reads the video file, scans the video file to form an image, or directly extracts the frame picture in the video, and then extracts the face image in the video, and extracts the face image in the video in real time according to the video playback. The above-mentioned video files include video files that come with the mobile phone, video files played in the browser, dynamic pictures, video files generated by online video chat, etc. The step of the user issuing an instruction to modify the picture is to receive the instruction to modify the picture sent by the user on the APP interface, load multiple objects in the database to be loaded on the face image on the interface for user selection, and generate an instruction to modify the picture after receiving the object selected by the user. There are multiple objects stored in the database, and each object is displayed in the form of an image or text or a combination of the two, so that the user can quickly understand the specific information of the object and select the object the user wants. For example, there are ten objects in the database, and each object is a face avatar of an entertainment star. When the APP interface receives the instruction to modify the picture issued by the user, the ten objects are loaded on the interface at the same time, allowing the user to select one of the face images as the object loaded on the above face image; then the APP packages the object into the instruction to form the instruction to modify the picture issued by the user.

[0062] As described in step S2 above, after the processor extracts the face image in the video, the deflection angle of the face is calculated according to the face feature points. After the processor extracts the face image in the video, the deflection angle of the face image can be determined using the facial information. The deflection angle is the deflection angle set for the face image relative to the preset reference position. For example, if the preset reference position is the face image when the user is looking straight ahead, then when the face in the video turns left or right or looks up or down, its deflection angle is the rotation angle relative to the horizontal view. When the face image is deflected to different degrees, the collected facial features have different relative positions, and the size of some symmetrical facial features will change. For example, if a person deflects to the left, the left ear is farther away from the camera, and the corresponding left ear in the video is smaller than the right ear. Therefore, the deflection angle of the face image can be calculated using the relative positions of the facial features and the sizes of some symmetrical facial features. In a specific embodiment, after extracting the face image in the video, the two eyes in the face image are identified, and the width of the two eyes is calculated respectively, and then the deflection angle is calculated according to the ratio of the width of the two eyes. For example, in a captured image, the width of the left eye of a person is 3000, and the width of the right eye is 4000. The above width unit is the minimum size unit obtained after cutting in the image. Then the ratio of the left eye to the right eye is calculated to be 3:4, that is, the width of the left eye is 3 / 4 of the width of the right eye, and then output to the preset formula y=f(x) to calculate the deflection angle of left deflection. In the above formula, y represents the deflection angle of left deflection, and x represents the ratio of the left eye width to the right eye width 3 / 4. The y finally calculated is an angle between negative 90 degrees and positive 90 degrees, that is, the deflection angle of left deflection. If a negative value is obtained, it means the absolute value of the angle of right deflection. After a basic test in a fixed pixel, the specific formula is: y=18.75x 2 -135x+116.25.

[0063] At the same time, when the user issues an instruction to modify the picture, first select a loaded object to be loaded on the face image in the video. Among them, the user can select an object to be loaded in the database on the mobile phone. Multiple objects and 3D models corresponding to each object are stored in the database. When the user needs to replace the face image in the video or add a picture on the APP, select an object in the database in the APP. After the processor receives the instruction issued by the user, it calls out the 3D model corresponding to the object selected by the user according to the object in the instruction. The 3D model refers to the three-dimensional stereogram corresponding to the object of the face, animal head, glasses and hat pre-stored by the user waiting to be loaded on the face image, wherein the three-dimensional stereogram is a three-dimensional stereogram formed by the user after taking a 360-degree photo of an object or person in advance, or it can be downloaded from the Internet.

[0064] As described in step S3 above, after the processor calls out the 3D model, it obtains the calculated deflection angle, and then projects the 3D model from the deflection angle to obtain a two-dimensional image of the 3D model projected at the deflection angle, namely the replacement image.

[0065] As described in the above step S4, the processor then loads the replacement picture onto the face image in the video so that the replacement picture covers the face image, thereby achieving the purpose of replacing the face in the video.

[0066] In this embodiment, since the video is played continuously, after receiving the user's instruction, the deflection angle of the face image is calculated in real time, and the corresponding loaded replacement image is also loaded in real time.

[0067] In one embodiment, the 3D model is a 3D face model, and the step of projecting the 3D model according to the deflection angle to obtain a replacement image includes:

[0068] S31, after preprocessing the facial image, input it into a trained expression recognition model for recognition, so as to obtain the expression of the facial image;

[0069] S32, obtaining a first feature point of the 3D face model and an adjustment matrix corresponding to the expression, wherein the corresponding relationship between the expression and the adjustment matrix is ​​preset;

[0070] S33, multiplying the first feature point by the adjustment matrix to obtain the second feature point;

[0071] S34, mapping the second feature point onto the 3D face model, and controlling the 3D face model to simulate the expression;

[0072] S35. After rotating the 3D face model simulating the expression by the degree of the deflection angle, the model is mapped on the back side of the 3D face model when it is not rotated to obtain a replacement image.

[0073] In this embodiment, the 3D model refers to a 3D model of a human face. After the processor extracts the facial image in the video, the facial image is preprocessed. Preprocessing is the processing performed before the image is subjected to feature extraction, segmentation and matching. The main purpose of image preprocessing is to eliminate irrelevant information in the image, restore useful real information, enhance the detectability of relevant information and simplify data to the maximum extent, thereby improving the reliability of feature extraction, image segmentation, matching and recognition. The preprocessed facial image is then input into a trained training model for expression recognition to obtain the expression recognition result of the facial image sequence; wherein the input end to the output end of the training model is constructed in sequence by a convolutional neural network model, a long short-term memory recurrent neural network model, a first pooling layer and a logistic regression model, and the training model is trained by a set of continuous frame images with labeled expression categories. After obtaining the expression of the face image, the processor controls the face 3D model to simulate an expression consistent with the expression of the face image. The method of simulating the corresponding expression is: first obtain the first feature point of the face 3D model, then multiply the first feature point by the adjustment matrix corresponding to the expression, obtain the second feature point with the expression, and then map the second feature point on the face 3D model, and then obtain the face 3D model with the expression. Each expression corresponds to an adjustment matrix, and the feature matrix corresponding to each expression is obtained by the staff after a lot of calculations and debugging. In the further specific adjustment process, the processor first divides the various parts of the face 3D model into regions, such as face region, nose region, mouth region, eyebrow region, etc., and can continue to subdivide each region into multiple sub-regions, and then according to the expression type and the preset region adjustment type, first obtain the expression, obtain the region or sub-region corresponding to the expression, and then obtain the feature points of the region or sub-region corresponding to the expression, and then multiply the feature points by the region adjustment matrix corresponding to the expression to obtain the feature points with the expression, and then map the feature points with the expression to the corresponding region or sub-region to obtain the face 3D model with the above expression. The 3D face model is implemented to simulate the same expression as the above-mentioned face image. Then, according to the deflection angle of the above-mentioned image, the deflection angle is the y value calculated in the formula, and the replacement picture of the 3D face model with the above-mentioned expression is projected. For example, when the expression is recognized as a smile, in the correspondence between the expression type and the area adjustment method, it is found that the adjustment area corresponding to the smile expression type is the mouth area and the adjustment matrix corresponding to the mouth area, and then the mouth area in the above-mentioned 3D model is multiplied by the above-mentioned adjustment matrix to obtain a 3D face model with a smiling expression. Then the above-mentioned 3D face model with a smiling expression is rotated at the above-mentioned deflection angle, and then the rotated 3D face model with a smiling expression is projected on the plane behind the initial 3D face model from the direction directly facing the initial 3D face model, and finally a replacement picture with a smiling expression is obtained.Specifically, the 3D face model with the above expression is rotated by the angle of the y value calculated above with the symmetry axis of the 3D face model as the center, and then a camera is simulated to take a picture from the opposite side of the initial 3D face model (not rotated), and the obtained picture is the above replacement picture.

[0074] In one embodiment, the 3D model is a 3D face model, and the step of projecting the 3D model according to the deflection angle to obtain a replacement image includes:

[0075] S36, inputting the face image into a preset organ recognition model to obtain a first organ in the face image;

[0076] S37, establishing matrices with the same number of rows and columns for the first organ and the second organ in a preset normal state according to the pigment difference, to obtain a first matrix and a second matrix respectively;

[0077] S38, subtracting the second matrix from the first matrix to obtain a matrix difference;

[0078] S39, calculating the rank of the matrix difference;

[0079] S310, calling a preset correspondence relationship between a rank and a facial action, and obtaining the facial action corresponding to the first organ according to the rank of the matrix difference;

[0080] S311, controlling various organs of the 3D face model to simulate the facial action;

[0081] S312: After rotating the 3D face model simulating the facial action by the degree of the deflection angle, the model is projected on the back side of the 3D face model when it is not rotated, so as to obtain a replacement image.

[0082] In this embodiment, the face image extracted from the video is preprocessed and then input into a trained organ recognition model. The organ recognition model segments the face image, identifies the organs of the face, and defines the image area containing the organs in the face image as the first organ. The first organ includes multiple organs that can move on the face. Specifically, the first organ includes eyes, mouth, nose, eyebrows, and cheek muscles. Each first organ is compared with the state of the second organ in a preset normal state, and the action of each organ is judged according to the comparison result. The specific process of judging the action of the organ is to perform image analysis on the first organ and the corresponding second organ, respectively establish a matrix with the same number of rows and columns for the first organ and the second organ according to the pigment difference, then subtract the matrix of the second organ from the matrix of the first organ to obtain the matrix difference, and then calculate the rank of the matrix difference. According to the result of the rank, the facial action of the organ is judged in the corresponding relationship between the rank of the organ and the facial action. In addition, if the result of the rank is less than a certain value, it is judged that the organ is in a normal state, and the corresponding organ in the above-mentioned face 3D model does not need to simulate other facial actions. Then, the various organs of the 3D face model are identified, and the organs with facial movements in abnormal states are confirmed in the above-mentioned first organs. Then, the various organs of the 3D face model are multiplied by the action matrix of the facial movement corresponding to the organ to obtain the facial movements of the various organs of the face model, so that the 3D face model makes the same movement as the above-mentioned changed facial movement. Then, according to the deflection angle of the above-mentioned image, a two-dimensional image of the 3D face model with the same facial movement is projected, and then the two-dimensional image is loaded at the position of the face image in the video. The step of projecting the 3D face model with facial movement to obtain the replacement image is the same as the method of S35 above.

[0083] The above-mentioned organ recognition model is obtained through training based on a deep neural network model. The staff first collects multiple pictures containing human faces, and labels each organ on the face of each person in the picture, and then inputs the picture and each annotation into the deep neural network model for training to obtain the organ recognition model.

[0084] In one embodiment, the step of loading the replacement picture onto the face image includes:

[0085] S41, obtaining the size of the display screen and the proportion of the face image to the display screen in the playback interface from the attribute information of the terminal;

[0086] S42, simulating loading the face image on the play interface, and calculating the size of the face image on the play interface;

[0087] S43, calculating the ratio between the size of the face image and a preset standard size;

[0088] S44, scaling the replacement image according to the ratio;

[0089] S45, loading the scaled replacement image onto the face image.

[0090] In this embodiment, the processor calculates the size of the above-mentioned face image based on the video information. Specifically, the attribute information of the mobile phone where the APP is located is obtained to obtain the size of the display screen. Then, based on the ratio of the APP's playback interface to the display screen, the face image is simulated to be loaded on the playback interface, and then the size of the face image in the playback interface is calculated. Then the size is compared with the preset standard size to obtain the ratio between the two. The standard size is set manually. The setting process is to place a standard face at a specified distance from a specified camera and collect the size of the face. The 3D model corresponding to the object in the database is also captured by the specified camera at a specified distance. The ratio of the size of the face image to the standard size is calculated, and then the replacement image is also scaled according to the above ratio to match the size of the replacement image with the size of the face image. The size of the replacement image is close to the size of the face image, so that the replacement image is of appropriate size when loaded on the face image and looks more coordinated. Then the scaled replacement image is loaded on the face image.

[0091] In one embodiment, after receiving the instruction to modify the picture from the user, the step of extracting the face image in the video includes:

[0092] S11, after receiving the instruction of modifying the picture from the user, collecting the frame picture in the video;

[0093] S12: input the frame image into a preset face recognition model, and output the face image.

[0094] In this embodiment, after the processor receives the replacement or addition instruction issued by the user, it obtains the video played in the specified APP, then reads the detailed information of the video, captures the frame image played at the current moment of the video, and then inputs the frame image into the preset face recognition model, performs identification according to the face recognition model, and outputs a face image.

[0095] In one embodiment, before the step of inputting the frame image into a preset face recognition model to output the face image, the following steps are included:

[0096] S101. Input a plurality of pictures containing face images in a training set into a preset neural network model for training, and obtain a neural network model for identifying faces in the pictures as the face recognition model.

[0097] In this embodiment, the staff selects a plurality of pictures containing face images in advance to form a training set, and then inputs these pictures into a preset neural network model for training. The neural network model automatically calculates and optimizes the characteristic coefficients of the face images according to the trajectory formed by the grayscale in the face images, even if the neural network model can be used to identify whether there are face images in the pictures. When extracting the face images in the video later, the frame pictures are processed to obtain the grayscale of the pictures, and then the grayscale trajectory is calculated to determine whether the characteristic coefficients obtained by the training are included. If so, it is determined that there are face images in the video, and the face images are extracted according to the grayscale trajectory corresponding to the characteristic coefficients.

[0098] In one embodiment, after the step of loading the replacement image onto the face image, the following steps are included:

[0099] S5, obtaining attribute information of the object;

[0100] S6, determining whether the attribute information is facial information;

[0101] S7: If yes, delete the facial image.

[0102] In this embodiment, the objects are stored in the database, and the corresponding information of each object is also stored in the database. The attributes of each object include whether it is facial information. If it is facial information, the replacement image also corresponds to the facial information of the person. The facial information is irregular in shape, and the replacement image formed can rarely fully cover the above-mentioned facial image. Therefore, it is necessary to delete the facial image in the video to make the overall replaced video information more coordinated. The processor reads the attribute information of the object and determines whether the attribute information is facial information. If it is facial information, the facial image is deleted. In a specific embodiment, the attribute information of the object includes two categories: facial information and accessory information, wherein the facial information includes human face, dog face, and cat face, and the accessory information includes glasses, earrings, and hats. If it is determined that the object is not facial information, the replacement image is only loaded on the facial image to form the effect of wearing accessories for the characters in the video, giving users a better experience.

[0103] To sum up, the method of modifying pictures based on face recognition of the present application, when replacing a face picture, will replace the angle of the pre-replaced face with the same deflection angle as the face in the video according to the deflection angle of the face in the picture or video, so that the replaced picture is more realistic.

[0104] Reference Figure 2 In an embodiment of the present application, a device for modifying a picture based on face recognition is also provided, comprising:

[0105] Extraction module 1, for extracting a face image in a video after receiving a command for modifying a picture from a user, wherein the command includes an object to be loaded on the face image;

[0106] Calculate the angle module 2, used according to the formula: y = 18.75x 2 -135x+116.25, calculate the deflection angle of the face image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the face image to the size of the corresponding right organ;

[0107] A projection module 3 is used to project the 3D model according to the deflection angle to obtain a replacement image;

[0108] The loading module 4 is used to load the replacement picture onto the face image.

[0109] In this embodiment, the execution subject of this embodiment is applied to an image processing APP on a mobile phone, and the execution subject is the processor of the mobile phone. After the APP loads the video file, the extraction module 1 of the processor receives the modified picture sent by the user, reads the video file, scans the video file to form an image, or directly extracts the frame picture in the video, and then the extraction module 1 extracts the face image in the video, and extracts the face image in the video in real time according to the video playback. The above-mentioned video files include video files that come with the mobile phone, video files played in the browser, dynamic pictures, video files generated by online video chat, etc. The step of the user issuing an instruction to modify the picture is to receive the instruction to modify the picture sent by the user on the APP interface, load multiple objects in the database to be loaded on the face image on the interface for the user to select, and generate an instruction to modify the picture after receiving the object selected by the user. There are multiple objects stored in the database, and each object is displayed in the form of an image or text or a combination of the two, so that the user can quickly understand the specific information of the object and select the object the user wants. For example, there are ten objects in the database, and each object is a face avatar of an entertainment star. When the APP interface receives the instruction to modify the picture issued by the user, the ten objects are loaded on the interface at the same time, allowing the user to select one of the face images as the object loaded on the above face image; then the APP packages the object into the instruction to form the instruction to modify the picture issued by the user.

[0110] After the extraction module 1 extracts the face image in the video, the angle calculation module 2 calculates the deflection angle of the face according to the face feature points. After the extraction module 1 extracts the face image in the video, the angle calculation module 2 can determine the deflection angle of the face image using the facial features information. The deflection angle is the deflection angle set for the face image relative to the preset reference position. For example, the preset reference position is the face image when the user is looking straight ahead. When the face in the video turns left or right or looks up or down, its deflection angle is the rotation angle relative to the straight view. When the face image is deflected to different degrees, the collected facial features have different relative positions, and the size of some symmetrical facial features will change. For example, when a person deflects to the left, the left ear is farther away from the camera, and the corresponding left ear in the video is smaller than the right ear. Therefore, the deflection angle of the face image can be calculated using the relative positions of the facial features and the sizes of some symmetrical facial features. In a specific embodiment, after extracting the face image in the video, the two eyes in the face image are identified, and the width of the two eyes is calculated respectively, and then the deflection angle is calculated according to the ratio of the width of the two eyes. For example, in a captured image, the width of the left eye of a person is 3000, and the width of the right eye is 4000. The above width unit is the minimum size unit obtained after cutting in the image. Then the ratio of the left eye to the right eye is calculated to be 3:4, that is, the width of the left eye is 3 / 4 of the width of the right eye, and then output to the preset formula y=f(x) to calculate the deflection angle of left deflection. In the above formula, y represents the deflection angle of left deflection, and x represents the ratio of the left eye width to the right eye width 3 / 4. The y finally calculated is an angle between negative 90 degrees and positive 90 degrees, that is, the deflection angle of left deflection. If a negative value is obtained, it means the absolute value of the angle of right deflection. After a basic test in a fixed pixel, the specific formula is: y=18.75x 2 -135x+116.25.

[0111] At the same time, when the user issues an instruction to modify the picture, first select a loaded object to be loaded on the face image in the video. Among them, the user can select an object to be loaded in the database on the mobile phone. Multiple objects and 3D models corresponding to each object are stored in the database. When the user needs to replace the face image in the video or add a picture on the APP, select an object in the database in the APP. After the processor receives the instruction issued by the user, according to the object in the instruction, the angle calculation module 2 calls out the 3D model corresponding to the object selected by the user. The 3D model refers to the three-dimensional stereogram corresponding to the object of the face, animal head, glasses and hat pre-stored by the user waiting to be loaded on the face image, wherein the three-dimensional stereogram is a three-dimensional stereogram formed by the user after taking a 360-degree photo of an object or a person in advance, or it can be downloaded from the Internet.

[0112] After the angle calculation module 2 calls out the 3D model, it obtains the calculated deflection angle, and then the projection module 3 projects the 3D model from the deflection angle to obtain a two-dimensional image of the 3D model generated by the projection at the deflection angle, namely the replacement image.

[0113] The loading module 4 then loads the replacement picture onto the face image in the video, so that the replacement picture covers the face image, thereby achieving the purpose of replacing the face in the video.

[0114] In this embodiment, since the video is played continuously, after receiving the user's instruction, the deflection angle of the face image is calculated in real time, and the corresponding loaded replacement image is also loaded in real time.

[0115] Reference Figure 3 In one embodiment, the 3D model is a face 3D model, and the projection module 3 includes:

[0116] An expression acquisition unit 31 is used to pre-process the face image and then input it into a trained expression recognition model for recognition, so as to acquire the expression of the face image;

[0117] A feature point unit 32, used to obtain a first feature point of the 3D face model and an adjustment matrix corresponding to the expression, wherein the correspondence between the expression and the adjustment matrix is ​​preset;

[0118] A multiplication unit 33, configured to multiply the first feature point by the adjustment matrix to obtain the second feature point;

[0119] An expression simulation unit 34, used for mapping the second feature point onto the 3D face model, and controlling the 3D face model to simulate the expression;

[0120] The first projection unit 35 is used to rotate the 3D face model simulating the expression by the degree of the deflection angle, and then project it onto the back side of the 3D face model when it is not rotated, so as to obtain a replacement image.

[0121] In this embodiment, the 3D model refers to a 3D model of a human face. After the processor extracts the facial image in the video, the facial image is preprocessed. Preprocessing is the processing performed before the image is subjected to feature extraction, segmentation and matching. The main purpose of image preprocessing is to eliminate irrelevant information in the image, restore useful real information, enhance the detectability of relevant information and simplify data to the maximum extent, thereby improving the reliability of feature extraction, image segmentation, matching and recognition. Then, the expression acquisition unit 31 inputs the preprocessed facial image into the trained training model for expression recognition, and obtains the expression recognition result of the facial image sequence; wherein, the input end to the output end of the training model is constructed in sequence by a convolutional neural network model, a long short-term memory recurrent neural network model, a first pooling layer and a logistic regression model, and the training model is trained by a set of continuous frame images with labeled expression categories. After obtaining the expression of the face image, the simulation expression unit 34 controls the face 3D model to simulate the expression consistent with the expression of the face image. The method of simulating the corresponding expression is as follows: first, the feature point unit 32 obtains the first feature point of the face 3D model, and then the multiplication unit 33 multiplies the first feature point by the adjustment matrix corresponding to the expression to obtain the second feature point with the expression, and then the simulation expression unit 34 maps the second feature point on the face 3D model to obtain the face 3D model with the expression. Each expression corresponds to an adjustment matrix, and the feature matrix corresponding to each expression is obtained by the staff after a lot of calculations and debugging. In the further specific adjustment process, the processor first divides the various parts of the 3D face model into regions, such as the face region, nose region, mouth region, eyebrow region, etc., and can further subdivide each region into multiple sub-regions, and then obtain the expression according to the expression type and the preset region adjustment type, first obtain the expression, then obtain the region or sub-region corresponding to the expression, and then obtain the feature points of the region or sub-region corresponding to the expression, and then multiply the feature points by the region adjustment matrix corresponding to the expression to obtain the feature points with the expression, and then map the feature points with the expression to the corresponding region or sub-region to obtain the 3D face model with the above expression. The 3D face model is realized to simulate the same expression as the above face image. Then the first projection unit 35 projects the replacement image of the 3D face model with the above expression according to the deflection angle of the above image, which is the y value calculated in the formula. For example, when the expression is recognized as a smile, in the correspondence between the expression type and the area adjustment method, it is found that the adjustment area corresponding to the expression type of smile is the mouth area and the adjustment matrix corresponding to the mouth area, and then the mouth area in the above 3D model is multiplied by the above adjustment matrix to obtain a 3D face model with a smiling expression.Then the 3D face model with a smiling expression is rotated at the above deflection angle, and then the rotated 3D face model with a smiling expression is projected onto the plane behind the initial 3D face model from the direction directly facing the initial 3D face model, and finally a replacement picture with a smiling expression is obtained. Specifically, the 3D face model with the above expression is rotated by the angle of the y value calculated above with the symmetry axis of the 3D face model as the center, and then a camera is simulated to take a picture from the direction directly facing the initial 3D face model (not rotated), and the obtained picture is the above replacement picture.

[0122] Reference Figure 4 In one embodiment, the 3D model is a face 3D model, and the projection module 3 includes:

[0123] An organ obtaining unit 36 ​​is used to input the face image into a preset organ recognition model to obtain a first organ in the face image;

[0124] A matrix building unit 37 is used to build a matrix with the same number of rows and columns between the first organ and the second organ in a preset normal state according to the pigment difference, so as to obtain a first matrix and a second matrix respectively;

[0125] a subtraction unit 38, configured to subtract the second matrix from the first matrix to obtain a matrix difference;

[0126] A rank calculation unit 39, used to calculate the rank of the matrix difference;

[0127] An action acquisition unit 310 is used to call a preset correspondence relationship between a rank and a facial action, and acquire the facial action corresponding to the first organ according to the rank of the matrix difference;

[0128] A simulation action unit 311, used for controlling various organs of the 3D face model to simulate the facial action;

[0129] The second projection unit 312 is used to rotate the 3D face model simulating the facial action by the degree of the deflection angle, and then project it onto the back side of the 3D face model when it is not rotated, so as to obtain a replacement image.

[0130] In this embodiment, after the extracted face image in the video is preprocessed, the organ unit 36 ​​is obtained and input into a trained organ recognition model. The organ recognition model segments the above face image, and the organ unit 36 ​​identifies the various organs of the face. The image area containing the various organs in the above face image is defined as the first organ. The first organ includes multiple organs that can move on the face. Specifically, the first organ includes eyes, mouth, nose, eyebrows, and cheek muscles. The action acquisition unit 310 compares each first organ with the state of the second organ under the preset normal state one by one, and the action acquisition unit 310 determines the action of each organ according to the comparison result. The specific process of judging the action of the organ is that the matrix establishment unit 37 performs image analysis on the first organ and the corresponding second organ, and establishes a matrix with the same number of rows and columns for the first organ and the second organ according to the pigment difference, and then the subtraction unit 38 subtracts the matrix of the first organ from the matrix of the second organ to obtain the matrix difference, and the rank calculation unit 39 calculates the rank of the matrix difference, and the action acquisition unit 310 determines the facial action of the organ according to the rank result in the corresponding relationship between the rank of the organ and the facial action. In addition, if the result of the rank is less than a certain value, it is determined that the organ is in a normal state, and the corresponding organ in the above-mentioned 3D face model does not need to simulate other facial movements. Then the various organs of the 3D face model are identified, and the organs with facial movements in abnormal states in the above-mentioned first organ are confirmed. Then the simulation action unit 311 multiplies the various organs of the 3D face model by the action matrix of the facial movement corresponding to the organ to obtain the facial movements of the various organs of the face model, so that the 3D face model makes the same action as the above-mentioned changed facial movement. Then the second projection unit 312 projects the 3D face model with the same two-dimensional picture of the above-mentioned facial movement according to the deflection angle of the above-mentioned image, and then loads the two-dimensional picture at the position of the face image in the video. The step of projecting the 3D face model with facial movement to obtain the replacement picture is the same as the execution method of the above-mentioned first projection unit 35.

[0131] The above-mentioned organ recognition model is obtained through training based on a deep neural network model. The staff first collects multiple pictures containing human faces, and labels each organ on the face of each person in the picture, and then inputs the picture and each annotation into the deep neural network model for training to obtain the organ recognition model.

[0132] Reference Figure 5 In one embodiment, the loading module 4 includes:

[0133] A size acquisition unit 41 is used to acquire the size of the display screen in the attribute information of the terminal and the proportion of the face image to the display screen in the playback interface;

[0134] A size calculation unit 42, used for simulating loading the face image on the play interface and calculating the size of the face image on the play interface;

[0135] A ratio calculation unit 43, used for calculating the ratio between the size of the face image and a preset standard size;

[0136] A scaling unit 44, configured to scale the replacement image according to the ratio;

[0137] The loading unit 45 is used to load the scaled replacement image onto the face image.

[0138] In this embodiment, the calculation ratio unit 43 calculates the size of the above-mentioned face image according to the video information. Specifically, first, the acquisition size unit 41 obtains the attribute information of the mobile phone where the APP is located to obtain the size of the display screen, and then according to the ratio of the APP playback interface to the display screen, the calculation size unit 42 simulates loading the face image on the playback interface, and then calculates the size of the face image in the playback interface. Then the calculation ratio unit 43 compares the size with the preset standard size to obtain the ratio between the two. The standard size is set manually, and the setting process is to place a standard face at a specified distance from a specified camera and collect the size of the face. The 3D model corresponding to the object in the database is also based on the specified camera at a specified distance. The ratio of the size of the face image to the standard size is calculated, and then the scaling unit 44 scales the replacement image according to the above ratio to match the size of the replacement image with the size of the face image, and the size of the replacement image is close to the size of the face image, so that the replacement image is of appropriate size when loaded on the face image and looks more coordinated. Then the loading unit 45 loads the scaled replacement image on the face image.

[0139] Reference Figure 6 In one embodiment, the extraction module 1 includes:

[0140] The acquisition unit 11 is used to acquire frame images in the video after receiving an instruction to modify the image from the user;

[0141] The output unit 12 is used to input the frame image into a preset face recognition model and output the face image.

[0142] In this embodiment, after the processor receives the replacement or addition instruction issued by the user, the acquisition unit 11 obtains the video played in the specified APP, then reads the detailed information of the video, captures the frame image played at the current moment of the video, and then the output unit 12 inputs the frame image into the preset face recognition model, identifies and recognizes it according to the face recognition model, and outputs a face image.

[0143] In one embodiment, the above-mentioned apparatus for modifying a picture based on face recognition further includes:

[0144] The training module 101 is used to input multiple pictures containing face images in the training set into a preset neural network model for training, and obtain a neural network model for identifying faces in the pictures as the face recognition model.

[0145] In this embodiment, the staff selects a plurality of pictures containing face images in advance to form a training set, and then the training module 101 inputs these pictures into a preset neural network model for training. The neural network model automatically calculates and optimizes the characteristic coefficients of the face image based on the trajectory formed by the grayscale in the face image, even if the neural network model can be used to identify whether there is a face image in the picture. When extracting the face image in the video later, the frame image is processed to obtain the grayscale of the image, and then the grayscale trajectory is calculated to determine whether the characteristic coefficient obtained by the above training is included. If so, it is determined that there is a face image in the video, and the face image is extracted according to the grayscale trajectory corresponding to the characteristic coefficient.

[0146] Reference Figure 7 In one embodiment, the above-mentioned apparatus for modifying a picture based on face recognition further includes:

[0147] An acquisition module 5 is used to acquire the attribute information of the object;

[0148] A judging module 6, used to judge whether the attribute information is facial information;

[0149] The deleting module 7 is used to delete the face image if the attribute information is face information.

[0150] In this embodiment, the objects are stored in the database, and the corresponding information of each object is also stored in the database. The attributes of each object include whether it is facial information. If it is facial information, the replacement picture corresponds to the facial information of the person. The facial information is irregular in shape, and the replacement picture formed can rarely cover the above-mentioned facial image in full. Therefore, it is necessary to delete the facial image in the video to make the overall replaced video information more coordinated. The acquisition module 5 reads the attribute information of the object, and the judgment module 6 judges whether the attribute information is facial information. If it is facial information, the deletion module 7 deletes the facial image. In a specific embodiment, the attribute information of the object includes two categories: facial information and ornament information, wherein the facial information includes human face, dog face, and cat face, and the ornament information includes glasses, earrings, and hats. If it is determined that the object is not facial information, the replacement picture is only loaded on the facial image to form the effect of wearing accessories for the characters in the video, giving users a better experience.

[0151] To sum up, the device for modifying images based on face recognition of the present application, when replacing a face image, will replace the angle of the pre-replaced face with the same deflection angle as the face in the video according to the deflection angle of the face in the image or video, so as to make the replaced image more realistic.

[0152] Reference Figure 8 In an embodiment of the present application, a computer device is also provided. The computer device may be a server, and its internal structure may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as 3D models. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for modifying a picture based on face recognition is implemented.

[0153] The processor executes the steps of the method for modifying an image based on face recognition: after receiving an instruction from a user to modify an image, extract the face image in the video, wherein the instruction includes an object to be loaded on the face image; according to the formula: y=18.75x 2-135x+116.25, calculate the deflection angle of the facial image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the facial image to the size of the corresponding right organ; project the 3D model according to the deflection angle to obtain a replacement image; and load the replacement image on the facial image.

[0154] In one embodiment, the 3D model is a 3D face model, and the processor executes the step of projecting the 3D model according to the deflection angle to obtain a replacement picture, including: preprocessing the face image and inputting it into a trained expression recognition model for recognition to obtain the expression of the face image; obtaining a first feature point of the 3D face model and an adjustment matrix corresponding to the expression, wherein the correspondence between the expression and the adjustment matrix is ​​preset; multiplying the first feature point by the adjustment matrix to obtain the second feature point; mapping the second feature point onto the 3D face model to control the 3D face model to simulate the expression; rotating the 3D face model that simulates the expression by the degree of the deflection angle, and then mapping it onto the back of the 3D face model when it is not rotated for projection to obtain a replacement picture.

[0155] In one embodiment, the 3D model is a 3D face model, and the processor executes the step of projecting the 3D model according to the deflection angle to obtain a replacement picture, including: inputting the face image into a preset organ recognition model to obtain a first organ in the face image; establishing matrices with the same number of rows and columns for the first organ and a second organ under a preset normal state according to pigment difference, respectively obtaining a first matrix and a second matrix; subtracting the second matrix from the first matrix to obtain a matrix difference; calculating the rank of the matrix difference; calling a preset correspondence between the rank and the facial action, obtaining a comparison based on the rank of the matrix difference, and calculating the facial action corresponding to the first organ based on the comparison result; controlling each organ of the 3D face model to simulate the facial action; rotating the 3D face model that simulates the facial action by the degree of the deflection angle, and mapping it on the back of the 3D face model when it is not rotated for projection, to obtain a replacement picture.

[0156] In one embodiment, the processor executes the step of loading the replacement picture onto the facial image, including: obtaining the size of the display screen in the attribute information of the terminal and the proportion of the facial image in the display screen in the playback interface; simulating loading the facial image on the playback interface, and calculating the size of the facial image in the playback interface; calculating the ratio between the size of the facial image and a preset standard size; scaling the replacement picture according to the ratio; and loading the scaled replacement picture onto the facial image.

[0157] In one embodiment, the processor executes the step of extracting a facial image in a video after receiving an instruction from a user to modify an image, including: after receiving an instruction from a user to replace a face, capturing a frame image in the video; inputting the frame image into a preset face recognition model, and outputting the facial image.

[0158] In one embodiment, before the processor executes the step of inputting the frame image into a preset face recognition model to output the face image, the step includes: inputting multiple pictures containing face images in a training set into a preset neural network model for training, and obtaining a neural network model for identifying faces in pictures as the face recognition model.

[0159] In one embodiment, after the processor executes the step of loading the replacement picture onto the face image, the following steps are performed: obtaining attribute information of the object; determining whether the attribute information is face information; and if so, deleting the face image.

[0160] To sum up, when replacing a face picture, the computer device of the present application replaces the angle of the pre-replaced face with the same deflection angle as the face in the video according to the deflection angle of the face in the picture or video, so that the replaced picture is more realistic.

[0161] Those skilled in the art will understand that Figure 8 The structure shown in is merely a block diagram of a portion of the structure related to the present application solution and does not constitute a limitation on the computer device to which the present application solution is applied.

[0162] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, a method for modifying an image based on face recognition is implemented, specifically comprising: extracting a face image in a video after receiving an instruction to modify an image issued by a user, wherein the instruction includes an object to be loaded on the face image; according to the formula: y=18.75x 2-135x+116.25, calculate the deflection angle of the facial image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the facial image to the size of the corresponding right organ; project the 3D model according to the deflection angle to obtain a replacement image; and load the replacement image on the facial image.

[0163] In one embodiment, the 3D model is a 3D face model, and the processor executes the step of projecting the 3D model according to the deflection angle to obtain a replacement picture, including: preprocessing the face image and inputting it into a trained expression recognition model for recognition to obtain the expression of the face image; obtaining a first feature point of the 3D face model and an adjustment matrix corresponding to the expression, wherein the correspondence between the expression and the adjustment matrix is ​​preset; multiplying the first feature point by the adjustment matrix to obtain the second feature point; mapping the second feature point onto the 3D face model to control the 3D face model to simulate the expression; rotating the 3D face model that simulates the expression by the degree of the deflection angle, and then mapping it onto the back of the 3D face model when it is not rotated for projection to obtain a replacement picture.

[0164] In one embodiment, the 3D model is a 3D face model, and the processor executes the step of projecting the 3D model according to the deflection angle to obtain a replacement picture, including: inputting the face image into a preset organ recognition model to obtain a first organ in the face image; establishing matrices with the same number of rows and columns for the first organ and a second organ under a preset normal state according to pigment difference, respectively obtaining a first matrix and a second matrix; subtracting the second matrix from the first matrix to obtain a matrix difference; calculating the rank of the matrix difference; calling a preset correspondence between the rank and the facial action, obtaining a comparison based on the rank of the matrix difference, and calculating the facial action corresponding to the first organ based on the comparison result; controlling each organ of the 3D face model to simulate the facial action; rotating the 3D face model that simulates the facial action by the degree of the deflection angle, and mapping it on the back of the 3D face model when it is not rotated for projection, to obtain a replacement picture.

[0165] In one embodiment, the processor executes the step of loading the replacement picture onto the facial image, including: obtaining the size of the display screen in the attribute information of the terminal and the proportion of the facial image in the display screen in the playback interface; simulating loading the facial image on the playback interface, and calculating the size of the facial image in the playback interface; calculating the ratio between the size of the facial image and a preset standard size; scaling the replacement picture according to the ratio; and loading the scaled replacement picture onto the facial image.

[0166] In one embodiment, the processor executes the step of extracting a facial image in a video after receiving an instruction from a user to modify an image, including: after receiving an instruction from a user to replace a face, capturing a frame image in the video; inputting the frame image into a preset face recognition model, and outputting the facial image.

[0167] In one embodiment, before the processor executes the step of inputting the frame image into a preset face recognition model to output the face image, the step includes: inputting multiple pictures containing face images in a training set into a preset neural network model for training, and obtaining a neural network model for identifying faces in pictures as the face recognition model.

[0168] In one embodiment, after the processor executes the step of loading the replacement picture onto the face image, the following steps are performed: obtaining attribute information of the object; determining whether the attribute information is face information; and if so, deleting the face image.

[0169] To sum up, the computer-readable storage medium of the present application, when replacing a face picture, replaces the angle of the pre-replaced face with the same deflection angle as the face in the video according to the deflection angle of the face in the picture or video, so that the replaced picture is more realistic.

[0170] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0171] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.

[0172] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for modifying pictures based on face recognition, It is characterized in that include: After receiving a command from a user to modify a picture, extracting a face image in the video, wherein the command includes an object to be loaded on the face image; According to the formula: y=18.75x 2 -135x+116.25, calculate the deflection angle of the face image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the face image to the size of the corresponding right organ; Projecting the 3D model according to the deflection angle to obtain a replacement image; Loading the replacement picture onto the face image; The 3D model is a 3D face model, and the step of projecting the 3D model according to the deflection angle to obtain a replacement image includes: Inputting the face image into a preset organ recognition model to obtain a first organ in the face image; the first organ is a plurality of movable organs on the face, including eyes, mouth, nose, eyebrows, and cheek muscles; The first organ and the second organ in a preset normal state are used to establish matrices with the same number of rows and columns according to the pigment difference, thereby obtaining a first matrix and a second matrix respectively; Subtracting the second matrix from the first matrix to obtain a matrix difference; Calculating the rank of the matrix difference; Calling a preset correspondence between a rank and a facial action, and obtaining the facial action corresponding to the first organ according to the rank of the matrix difference; Controlling various organs of the 3D face model to simulate the facial movements; After the 3D face model simulating the facial action is rotated by the degree of the deflection angle, it is mapped on the back side of the 3D face model when it is not rotated for projection, so as to obtain a replacement image.

2. The method for modifying a picture based on face recognition as claimed in claim 1, It is characterized in that The 3D model is a 3D face model, and the step of projecting the 3D model according to the deflection angle to obtain a replacement image includes: After preprocessing the facial image, the facial image is input into a trained expression recognition model for recognition to obtain the expression of the facial image; Obtaining a first feature point of the 3D face model and an adjustment matrix corresponding to the expression, wherein the correspondence between the expression and the adjustment matrix is ​​preset; Multiplying the first feature point by the adjustment matrix to obtain a second feature point; Mapping the second feature point onto the 3D face model, and controlling the 3D face model to simulate the expression; After the 3D face model simulating the expression is rotated by the degree of the deflection angle, it is mapped on the back side of the 3D face model when it is not rotated for projection, so as to obtain a replacement image.

3. The method for modifying a picture based on face recognition as claimed in claim 1, It is characterized in that The step of loading the replacement picture onto the face image comprises: Obtaining the size of the display screen in the terminal's attribute information and the proportion of the face image to the display screen in the playback interface; Simulate loading the face image on a playback interface, and calculate the size of the face image on the playback interface; Calculating the ratio between the size of the face image and a preset standard size; Scaling the replacement image according to the ratio; The scaled replacement image is loaded onto the face image.

4. The method for modifying a picture based on face recognition as claimed in claim 1, It is characterized in that After receiving the instruction to modify the picture from the user, the step of extracting the face image in the video includes: After receiving the instruction to replace the face from the user, the frame image in the video is collected; The frame image is input into a preset face recognition model, and the face image is output.

5. The method for modifying a picture based on face recognition as claimed in claim 4, It is characterized in that Before the step of inputting the frame image into a preset face recognition model to output the face image, the method further comprises: A plurality of pictures containing face images in a training set are input into a preset neural network model for training, and a neural network model for identifying faces in the pictures is obtained as the face recognition model.

6. The method for modifying a picture based on face recognition as claimed in claim 1, Features , after the step of loading the replacement picture on the face image, comprising: Obtaining attribute information of the object; Determining whether the attribute information is facial information; If so, delete the face image.

7. A device for modifying pictures based on face recognition, It is characterized in that include: An extraction module, configured to extract a face image in a video after receiving a command from a user to modify a picture, wherein the command includes an object to be loaded on the face image; Calculate the angle module according to the formula: y=18.75x 2 -135x+116.25, calculate the deflection angle of the face image, and call the 3D model corresponding to the object in the database, where y represents the deflection angle to the left, and x represents the ratio of the size of the left organ in the face image to the size of the corresponding right organ; A projection module, used for projecting the 3D model according to the deflection angle to obtain a replacement image; A loading module, used for loading the replacement image onto the face image; The 3D model is a human face 3D model, and the projection module includes: Obtaining an organ unit, which is used to input the face image into a preset organ recognition model to obtain a first organ in the face image; the first organ is a plurality of organs that move on the face, including eyes, mouth, nose, eyebrows, and cheek muscles; A matrix establishment unit is used to establish a matrix with the same number of rows and columns between the first organ and the second organ in a preset normal state according to the pigment difference, so as to obtain a first matrix and a second matrix respectively; a subtraction unit, configured to subtract the second matrix from the first matrix to obtain a matrix difference; A rank calculation unit, used for calculating the rank of the matrix difference; An action acquisition unit, used for calling a preset correspondence relationship between a rank and a facial action, and acquiring the facial action corresponding to the first organ according to the rank of the matrix difference; A simulation action unit, used for controlling various organs of the 3D face model to simulate the facial action; The second projection unit is used to rotate the 3D face model simulating the facial action by the degree of the deflection angle, and then project it onto the back side of the 3D face model when it is not rotated to obtain a replacement image.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Face projection method for facial makeup based on face features

    CN105893984A

  • Human face three-dimensional reconstruction and human face replacing video editing system and method based on deep learning

    CN107067429A

  • Video image interaction processing method and device

    CN109151540A

  • Method for preventing privacy disclosure based on face recognition and related equipment

    CN109376518A

  • Method for tracking head motion for 3D facial model animation from video stream

    US20090153569A1