WO2021027585A1 - Human face image processing method and electronic device - Google Patents

Human face image processing method and electronic device Download PDF

Info

Publication number
WO2021027585A1
WO2021027585A1 PCT/CN2020/105873 CN2020105873W WO2021027585A1 WO 2021027585 A1 WO2021027585 A1 WO 2021027585A1 CN 2020105873 W CN2020105873 W CN 2020105873W WO 2021027585 A1 WO2021027585 A1 WO 2021027585A1
Authority
WO
WIPO (PCT)
Prior art keywords
grid
dimensional
electronic device
face
model
Prior art date
Application number
PCT/CN2020/105873
Other languages
French (fr)
Chinese (zh)
Inventor
丁欣
王利强
周恒�
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021027585A1 publication Critical patent/WO2021027585A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T19/00Manipulating 3D models or images for computer graphics
    • G06T19/20Editing of 3D images, e.g. changing shapes or colours, aligning objects or positioning parts
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/08Projecting images onto non-planar surfaces, e.g. geodetic screens
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2219/00Indexing scheme for manipulating 3D models or images for computer graphics
    • G06T2219/20Indexing scheme for editing of 3D models
    • G06T2219/2016Rotation, translation, scaling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2219/00Indexing scheme for manipulating 3D models or images for computer graphics
    • G06T2219/20Indexing scheme for editing of 3D models
    • G06T2219/2021Shape modification

Definitions

  • This application relates to the field of image processing, and in particular to a face image processing method and electronic equipment.
  • the camera function is more and more widely used in smart devices, such as smart phones, tablet computers, and notebook computers.
  • the camera function can facilitate users to collect images, including taking photos or videos, making smart devices more popular with users.
  • the camera device of the smart device When using the camera function of a smart device, since the camera device of the smart device is generally set in an area outside the screen, when the user looks at the screen, the facial posture in the image collected by the camera device will be tilted. Correct the face posture.
  • the current method of deformation fusion based on 3D face reconstruction after reconstruction takes a long time to generate a corrected 2D face and fusion with the background, especially when the camera function is used for video calls, which cannot achieve real-time processing. Requirements.
  • the present application provides a face image processing method and electronic device to solve the problem that when correcting the face posture in the image in the prior art, it takes a long time and cannot meet the real-time requirements.
  • an embodiment of the present application provides a face image processing method for a face image.
  • the face image processing method includes: an electronic device acquires a two-dimensional image to be processed, and constructs a face image according to a preset reference grid.
  • the three-dimensional mesh model corresponding to the two-dimensional image to be processed, the texture map of the three-dimensional mesh model is obtained according to the shooting parameters of the two-dimensional image to be processed, and the visible boundary of the face of the reference mesh is determined Boundary points, and control points corresponding to the boundary points;
  • the electronic device performs deformation processing on the three-dimensional mesh model according to preset deformation requirements and in combination with the corresponding relationship between the boundary points and the control points, and
  • the texture image is rendered to the deformed three-dimensional mesh model, and the processed image is generated according to the rendered three-dimensional mesh model.
  • the electronic device acquires shooting parameters according to the acquired two-dimensional image to be processed, builds a three-dimensional grid model according to the two-dimensional image combined with the reference grid, determines the boundary points and control points according to the reference grid, and according to the preset deformation It is required to combine the boundary points and control points to deform the 3D mesh model, which can effectively improve the efficiency of the deformation processing of the 3D mesh model, and render the processed 3D mesh model to the texture image, thereby improving the electronic equipment
  • the efficiency of image processing can better meet the timeliness requirements of electronic equipment for real-time image processing. For example, it can be applied to real-time processing of video images to reduce the delay of processed images and improve user experience.
  • the electronic device extracts video frames in real time from the video collected by the camera, and uses the extracted video frames as the two-dimensional images to be processed; or, the electronic device uses the photos taken by the camera as the two-dimensional images to be processed.
  • Dimensional image After acquiring the two-dimensional image to be processed, it can be detected whether the two-dimensional image includes a face image. If the two-dimensional image includes a face image, the face image processing method described in this application is activated and the preset Build a three-dimensional grid model based on a predetermined reference grid. If no face image is detected in the two-dimensional image, the collected image can be directly displayed.
  • the reference grid includes a three-dimensional face model reference grid and a background plane reference grid
  • the three-dimensional grid model includes a three-dimensional face model modeling grid and a background plane modeling grid.
  • the step of the electronic device constructing a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid includes: the electronic device combines the reference grid of the three-dimensional face model with the two-dimensional image to be processed Fit, and obtain the shooting parameters of the two-dimensional image to be processed according to the fitted reference grid of the three-dimensional face model; according to the shooting parameters, the electronic device poses the reference grid of the three-dimensional face model Through adjustment, a three-dimensional face model modeling grid is obtained, and the three-dimensional face model modeling grid is consistent with the face pose in the two-dimensional image.
  • the reference grid of the three-dimensional face model in the reference grid is a general face model or a three-dimensional deformed model.
  • a fitting operation is performed on the reference grid based on the features of the face image included in the two-dimensional image to be processed, so that after the reference grid is transformed, the reference grid including the face features is obtained.
  • the reference grid can be rotated by the rotation vector in the shooting parameters in this application, so that the three-dimensional face model can effectively match the face in the two-dimensional image. Posture matching.
  • the shooting parameters include a model view matrix and a projection matrix
  • the step of adjusting the posture of the reference grid of the three-dimensional face model by the electronic device according to the shooting parameters includes: In the model view matrix, the electronic device extracts the rotation component; according to the extracted rotation component, the electronic device controls the fitted reference grid of the three-dimensional face model to rotate to the face pose corresponding to the two-dimensional image to be processed.
  • the pose adjustment is performed on the reference grid of the three-dimensional face model
  • the rotation of the reference grid of the three-dimensional face model can also be determined by means of feature point combination or feature comparison.
  • Component rotate the reference grid of the fitted 3D face model.
  • the step of the electronic device constructing a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid further includes: determining a three-dimensional face model after posture adjustment Boundary points in the modeling grid that have changed positions; search for corresponding control points according to the changed positional boundary points, and perform deformation control on the background plane reference grid according to the searched control points.
  • the background plane modeling grid is obtained by fitting a reference grid of a three-dimensional face model with a face image in a two-dimensional image
  • the background plane modeling grid can be obtained after a reference grid of a three-dimensional face model
  • the background plane reference grid is adjusted according to the relationship between the boundary points and the control points.
  • the texture map includes a three-dimensional face model grid texture map and a background plane grid texture map
  • the electronic device obtains the three-dimensional face model according to the shooting parameters of the two-dimensional image to be processed.
  • the step of the texture map of the grid model includes: according to the model view matrix and the projection matrix, the electronic device obtains the three-dimensional face model grid texture map; according to the projection matrix and the translation vector in the model view matrix And a zoom vector, the electronic device obtains the background plane grid texture map.
  • the step of obtaining the three-dimensional face model mesh texture map by the electronic device may include: the electronic device obtaining the three-dimensional face model modeling grid The coordinates of the vertices in the space rectangular coordinate system, when the z coordinate in the vertices coordinates is 0, the first plane is rendered; the electronic device is based on the position of the first pixel of the first plane and the model view matrix and projection The product of the matrix determines the second pixel corresponding to the first pixel on the two-dimensional image to be processed, and the color of the first pixel is determined according to the color of the second pixel.
  • the step of obtaining the background plane grid texture map by the electronic device may include: the electronic device modeling the network according to the background plane The grid determines the second plane, and extracts the translation matrix and the zoom matrix in the model view matrix; the electronic device determines the second plane according to the position of each third pixel in the second plane and the product of the translation matrix, the zoom matrix, and the projection matrix. For the fourth pixel point corresponding to the three-pixel point on the two-dimensional image to be processed, the color of the third pixel point is determined according to the color of the fourth pixel point.
  • the correspondence between the pixels in the two-dimensional image and the texture map can be determined, and the background plane network
  • the lattice texture map does not need to be rotated, you can use the zoom vector and the translation vector in the model view matrix.
  • the texture map of the three-dimensional mesh model can also be generated by means of feature point matching.
  • the step of the electronic device deforming the three-dimensional mesh model includes: the electronic device obtains the information of the three-dimensional face model modeling mesh in the constructed three-dimensional mesh model Posture; the electronic device rotates the three-dimensional face model modeling grid according to the angle relationship between the posture of the constructed three-dimensional face model modeling grid and the target posture.
  • the determined target posture is The user image corresponding to the horizontal angle.
  • the angle relationship between the posture of the constructed three-dimensional face model modeling grid and the target posture is the angle between the upward angle of the image collected by the electronic device and the horizontal line.
  • the three-dimensional face model modeling grid is rotated downward according to the included angle, so that the posture of the three-dimensional face model modeling grid faces forward horizontally.
  • the step of the electronic device performing deformation processing on the three-dimensional face model modeling grid according to preset deformation requirements includes: the electronic device obtains preset face beautification parameters ; According to the face beautification parameters, the electronic device adjusts the three-dimensional face model modeling grid in the three-dimensional grid model.
  • the face beautification parameters include one or more of eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, face shape parameters, and nose wings size parameters.
  • an electronic device when it receives a user's beautification request, it can select preset eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, and face shape according to the beautification request.
  • One or more of the parameters and the wing size parameters are used as the face beautification parameters corresponding to the current beautification request.
  • the modeling grid of the three-dimensional face model is adjusted according to the face beautification parameters.
  • the distance between the feature points in the 3D face model modeling grid can be adjusted according to a certain ratio.
  • the face beautification parameters include face shape parameters
  • two or more than two sets of feature point pairs can be selected to characterize the face width, and the distance of the feature point pairs conforms to a predetermined ratio relationship.
  • the pre-set ratio of the distance between the feature point pairs adjust the ratio of the distance between the corresponding feature point pairs in the current three-dimensional face model modeling grid to make it consistent with the preset ratio relationship.
  • the beautification of the face such as adjusting the width of the chin relative to the face, so that the face shape of melon seeds can be obtained after beautification.
  • the step of performing deformation processing on the three-dimensional mesh model by the electronic device in combination with the corresponding relationship between the boundary points and the control points includes: the electronic device acquires that the boundary points are located in the reference grid The first position on the reference grid of the three-dimensional face model, and the boundary point is located at the second position on the three-dimensional face model modeling grid in the three-dimensional grid model; the difference between the second position and the first position
  • the electronic device searches for a control point corresponding to the boundary point; the electronic device performs deformation processing on the background plane modeling grid according to the searched control point.
  • the step of the electronic device performing deformation processing on the background plane modeling grid according to the searched control point includes: the electronic device obtains the coordinate position of the boundary point on the background plane According to the coordinate change of the coordinate position of the boundary point in the background plane, the electronic device determines the target position of the control point; according to the target position, the electronic device models the background plane Grid performs Laplace deformation processing.
  • the reference grid of the 3D face model when the reference grid of the 3D face model is deformed, it includes processing methods such as fitting or posture adjustment.
  • the background plane reference grid can quickly determine the target transformation position according to the corresponding relationship between the boundary points and the control points. , Thereby quickly completing the adjustment to the background plane reference grid, thereby improving the response speed of image processing.
  • the vertical projection of the boundary point on the background plane can be obtained, or the two-dimensional coordinates can be obtained by intercepting the three-dimensional coordinates of the boundary point The corresponding control.
  • the step of the electronic device performing Laplace deformation processing on the background plane modeling grid includes: the electronic device obtains the background plane modeling grid According to the set control point and the target position of the control point, the electronic device performs Laplace deformation processing on the background plane modeling grid.
  • the background plane modeling grid can be combined with the three-dimensional face model.
  • the modeling grid is effectively fused to improve the authenticity of the transformed image and avoid image gaps.
  • the method before the step of acquiring the two-dimensional image to be processed by the electronic device, the method further includes: the electronic device constructing a three-dimensional face model reference grid and a background plane reference grid; The electronic device obtains the face area in the reference grid of the three-dimensional face model; according to the visible boundary of the face area, the electronic device determines the positions of the boundary points and the control points.
  • the present application provides an electronic device that includes a memory, a processing screen, and a computer program.
  • the display screen is used for processed images.
  • the computer program is stored in the memory.
  • the computer program includes instructions, which when executed by the electronic device, cause the electronic device to execute the face image processing method according to any one of the first aspect.
  • the present application provides a computer-readable storage medium that stores a computer program that, when executed by a processor, realizes the face image described in any one of the first aspect Approach.
  • this application provides a computer program product containing instructions that, when the computer program product runs on an electronic device, causes the electronic device to execute the face image processing method described in any one of the first aspect.
  • the electronic equipment described in the second aspect, the computer storage medium described in the third aspect, and the computer program product described in the fourth aspect provided above are all used to execute the corresponding methods provided above.
  • the beneficial effects that can be achieved please refer to the beneficial effects in the corresponding method provided above, which will not be repeated here.
  • FIG. 1 is a schematic structural diagram of a hidden camera provided by an embodiment of the application.
  • FIG. 2 is a schematic diagram of using a hidden camera to make a video call according to an embodiment of the application
  • FIG. 3 is a schematic diagram of the effect of an image captured by a hidden camera provided by an embodiment of the application
  • FIG. 4 is a schematic diagram of the comparison effect of face image processing based on a target image matching method provided by an embodiment of the application;
  • FIG. 5 is a schematic flowchart of a face image processing provided by an embodiment of the application.
  • Fig. 6 is a schematic diagram of a general face model provided by an embodiment of the application.
  • FIG. 7 is a schematic diagram of a three-dimensional deformation model provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of a reference grid provided by an embodiment of this application.
  • FIG. 9 is a schematic diagram of marking boundary points at the front right perspective of a reference grid according to an embodiment of the application.
  • FIG. 10 is a schematic diagram of marking boundary points on the front of a reference grid according to an embodiment of the application.
  • FIG. 11 is a schematic diagram of a modeling mesh after deformation processing provided by an embodiment of the application.
  • FIG. 12 is a schematic diagram of a mesh texture map of a three-dimensional face model provided by an embodiment of the application.
  • FIG. 13 is a schematic diagram of a background plane grid texture map provided by an embodiment of this application.
  • 14a and 14b are respectively a side view and a front view of a three-dimensional face model modeling grid after deformation processing provided by an embodiment of the application;
  • 15 is a schematic diagram of an image after posture adjustment and rendering provided by an embodiment of the application.
  • 16a and 16b are respectively a front view and a side view of a three-dimensional grid model after adjusting the background plane modeling grid according to an embodiment of the application;
  • FIG. 17 is a schematic structural diagram of an image processing device provided by an embodiment of this application.
  • FIG. 18 is a schematic structural diagram of an electronic device provided by an embodiment of this application.
  • FIG. 19 is a block diagram of the software structure of an electronic device provided by an embodiment of the application.
  • the main purpose of the embodiments of the present application is to solve the problems of poor transformation effect and slow response speed when processing face images collected in real time in the existing face image processing.
  • the details are as follows:
  • the face image processing methods described in this application may include transforming the pose or angle of the face in the image, or performing special effects processing on the face in the image, including collecting facial beauty, fattening, thinning, and mirroring. And other face image processing methods.
  • the camera may be a hidden camera with a keyboard set at the bottom of the screen.
  • the hidden camera can choose to set a special button in the middle of the keyboard, and install the camera through this button.
  • the camera can be set on the button through a pressing structure, for example, the camera is set on the front side of the button, or when the button is a push button that can be rotated, it can be set at any side.
  • the button When the user needs to use the camera, he can press the button.
  • the rear side of the button can be fixed by a rotating shaft.
  • the front side of the button can be popped up by the elastic force of the elastic member, so that the side of the keyboard where the camera is located is in line with the keyboard.
  • the angle between the front keyboard planes is greater than 90 degrees, such as 120 degrees, 135 degrees, etc., so that the camera can collect a complete face image of the user who normally uses the notebook.
  • the camera can also be set to be flexibly adjustable to multiple angles.
  • the rotation angle of the camera can be adjusted according to the integrity of the face image currently detected. For example, when the user is close to the screen, if only the lower part of the user's face image can be detected according to the image collected by the camera, the camera can be controlled to rotate upward until the complete face image is obtained, or the user is far away from the screen If the face of the collected image is located in the lower part of the image, the angle of the camera can be adjusted so that the face image is located in the middle of the image.
  • the user’s eye gaze direction is usually in the direction corresponding to the screen area during the video call.
  • the hidden camera captures the face at an elevation angle, so that the user is in When making a video call or taking a photo, there is a certain angle ⁇ between the camera's shooting angle and the user's gaze angle, and the captured face image will show a "big chin", "upward nose”, etc. as shown in Figure 3
  • the image effect does not meet the requirements of the shooting angle of view desired by the user.
  • the gaze angle of the face in the captured image usually shows the illusion of not looking at or paying attention to the other party (actually the user is looking at the other party on the screen), which is not conducive to improving users Communication experience.
  • a desktop computer acquires a user's face image through an external camera
  • a tablet or a laptop acquires a user's face image through a camera set above or below the screen
  • the difference between the position of the camera and the center of the screen makes the captured image
  • the angle of the image has a certain depression or elevation angle, and it is also necessary to transform the face through the face image processing method, so that the image can display the desired shooting angle of view, and improve the user's call experience during video calls.
  • the smart terminal can adjust the facial features in the captured image in order to obtain a better shooting effect when collecting photos or videos that include the user's face image. Or adjust the figure and so on.
  • This is convenient for users to publish adjusted photos or videos, including, for example, users publishing short videos through small video applications (including applications such as Douyin, Kuaishou, etc.), or publishing photos or small videos through platforms such as WeChat, Weibo, and blogs. Video etc.
  • Processing the collected face image in a two-dimensional transformation manner may include: first obtaining a face photo of the user as reference data for subsequent image or video processing, and detecting feature points of the face photo. When the photo to be transformed is obtained, the feature points in the photo to be transformed are recognized. The captured image is deformed according to the pre-stored front face photo, and the sight direction and the orientation of the facial features in the deformed face image remain unchanged.
  • the picture on the left is the photo to be transformed.
  • the photo to be converted may be the user using an electronic device, for example, when using a laptop with a hidden camera function to make a video call, or using a laptop with a hidden camera function to take a video, or the screen position of other cameras and electronic devices
  • the camera is set in front of and below the face, and the camera's collection angle is the upward viewing angle.
  • the chin and nostrils of the collected images are large, and the user experience is not good.
  • this figure shows the effect of the camera set at the bottom of the screen.
  • the middle image in Figure 4 is a deformed photo using the pre-stored front face photo as the target. Although the entire face shape has changed, the sight direction and facial features of the face have not changed, while the target in the right image in Figure 4 It can be seen from the renderings that, in order to be able to effectively process the face image, it is necessary to change the line of sight of the eyes in the face, and it is necessary to change the display perspective of the nose in the face.
  • the feature points are usually used to create a grid on the picture, and for each triangle in the grid, the image is mapped according to the transformation matrix or function, and it needs to be traversed during the transformation process. For each pixel position, the pixel color is calculated by interpolation.
  • the larger the deformation processing range the greater the processing time that needs to be spent. Under normal circumstances, it takes 4-6ms to deform only the facial features and only the face The time spent in deformation is usually 20-40ms, and the time required for full image transformation of the collected image is 130-170ms. Therefore, if in order to obtain a better image effect, a larger processing delay will occur.
  • the three-dimensional deformation + background two-dimensional fusion method is used to perform three-dimensional reconstruction according to the collected images, deform the reconstructed face in three-dimensional space, and then reproject the deformed face into a two-dimensional face target image, and
  • a two-dimensional face target image if only the face is reconstructed, deformed and projected, it usually takes 30-40ms to complete.
  • there will be a gap between the face image and the background image which will affect The real effect of the image.
  • fusing the projected two-dimensional face target image with the background image it takes a long time, and it usually takes 35-55ms to fuse the face image with the background image.
  • the process of generating a corrected two-dimensional face model and fusion requires 65-95ms, which cannot meet the requirements for real-time video processing.
  • the embodiment of the present application constructs a three-dimensional face model benchmark Grid and background plane datum grid, when transforming the 3D face model datum grid, adjust the background plane datum grid accordingly through the boundary points of the 3D face model datum grid and the background plane datum grid control point, Thereby improving the efficiency of face image processing.
  • the reference grid of the three-dimensional face model may be a grid model of the three-dimensional face model formed by polygons (including triangles, quadrilaterals, etc.).
  • the three-dimensional face model selected by the three-dimensional face reference grid may be a general face model, or may be a three-dimensional face model of the user who uses the image processing device.
  • the background plane reference grid is a plane grid corresponding to the size of the image to be processed.
  • the background plane grid can be composed of a uniform grid or a non-uniform grid.
  • the reference grid to be constructed may include a three-dimensional face model reference grid and a background plane reference grid.
  • the reference grid of the three-dimensional face model may be a general face model, a three-dimensional deformable model (3DMM, 3D Morphable Models), or a variant model thereof.
  • the general face model is a three-dimensional face model grid established based on a general face, and may include, for example, a CANDIDE-3 model, a CANDIDE model, and the like.
  • the CANDIDE-3 model includes 113 vertices and 168 faces. Through the operation and adjustment of these points and faces, the feature points in the general face model and the two-dimensional image collected by the camera (requires three-dimensional face The facial features in the reconstructed image) are matched.
  • the advantage of using a general face model is that the amount of calculation is small, and it can quickly respond to the reconstruction of the three-dimensional face image.
  • the general face model may be obtained by using a three-dimensional scanner to obtain the data of the general face model, or may be created by computer graphics technology, or the general face model may be generated by commercial modeling software.
  • the universal face model may acquire a user of the image processing device, and establish a universal face model corresponding to the user.
  • the user's face model can be scanned as the general face model.
  • the general face models corresponding to the multiple users can be stored, and the general face models corresponding to the users can be selected according to the user currently using the electronic device.
  • a general face model corresponding to the user's group may be selected according to the user's facial features. For example, the user's group may be a group determined by middle-aged men, young girls, etc.
  • you can improve the efficiency of fitting the collected images to the reference grid of the three-dimensional face model during subsequent reconstruction of the three-dimensional face model which is beneficial to improve the response speed of the device.
  • the real-time images of the big chin, big nostril, and upward viewing angle taken by the laptop can be fitted for processing, which can improve the response speed after fitting processing , Improve the real-time performance of video display.
  • a preset universal face model corresponding to the user group can be used.
  • the facial features of the user can be collected, and the corresponding relationship between the user and the general face model can be added to the system.
  • the three-dimensional deformed model 3DMM When the three-dimensional deformed model 3DMM is selected as the reference grid of the three-dimensional face model, the three-dimensional deformed model 3DMM can be established on the basis of the three-dimensional face database, with the face shape and face texture statistics as constraints, and can take into account the human Due to the influence of the posture of the face and illumination factors, the three-dimensional deformation model can be adjusted with higher precision.
  • Figure 7 is a schematic diagram of the 3D deformed model. Compared with the general face model, the reference grid of the 3D face model based on the 3D deformed model has greatly increased the number of triangles and vertices. The 3D deformed model includes More features and details.
  • each face model includes a corresponding face 3D coordinate shape vector Si
  • the new 3D face model can be expressed as:
  • S new is a new face shape model
  • si represents the main component of the new face shape, that is, the feature of the new face that is different from other faces
  • ⁇ i is the face shape coefficient
  • facial expression data may be further included, so that the three-dimensional deformation model is further expanded to:
  • e i represents the main components of facial expressions, that is, the characteristic parts that are different from other facial expressions
  • ⁇ i is the facial expression coefficient.
  • the facial shape coefficient ⁇ i and the facial expression coefficient ⁇ i can be solved using the least square method.
  • the 3D deformed model determined by the user group may be used.
  • the background plane reference grid can be constructed according to the size of the collected image.
  • the reference grid of the three-dimensional face model is overlaid on the background plane reference grid.
  • the constructed background plane reference grid can be constructed according to a grid of a predetermined size and shape.
  • the predetermined shape of the grid may include a triangular grid, a square grid, and the like.
  • the triangular grids in the background plane reference grid can be all the same triangular grids, or can only set the triangular grids of the same shape within a predetermined range around the face, and can be outside the face area, and A denser triangular grid is set in a predetermined range within the head area, so that the face image can be deformed and more accurate and adaptive adjustment can be made to the predetermined range of the head image.
  • FIG. 9 is a schematic diagram of the boundary points marked by the front right perspective of the reference grid. In the front right perspective, there are more visible parts on the right side of the face model, and the distance between the boundary points on the visible boundary and the front center line of the face Far away.
  • the boundary points may select different numbers of boundary points according to the accuracy of image processing. For example, the higher the accuracy required for image processing, the more boundary points can be selected.
  • the boundary points may be evenly distributed on the intersection line, or the boundary points may be densely distributed in the parts where the contour line of the human face is deformed more frequently. As shown in Figure 9, more boundary points can be set near the mouth of the face.
  • the visible boundary of the face is determined according to the visible area of the face of the reference grid of the three-dimensional face model. According to the visible boundary, Determine the boundary point corresponding to the frontal perspective.
  • the control points of the background plane reference grid may also be determined according to the boundary points.
  • the boundary points determined according to the frontal perspective of the reference grid of the three-dimensional face model and the control points of the background plane reference grid determined according to the boundary points can completely overlap, but of course, it should not be limited to this ,
  • the distance between the boundary point and the control point may be set to be less than a predetermined distance.
  • this application can also set a fixed point for the background plane reference grid, and the fixed point makes the overall size of the background plane reference grid Will not change, on the other hand, it is also helpful to ensure the overall stability of the picture.
  • the fixed points of the background plane reference grid can be further set.
  • the position of the fixed point may be set at the outer boundary of the background plane reference grid, and the fixed point on the outer boundary is used to prevent the image size after the deformation process from changing.
  • the boundary point is located on the reference grid of the three-dimensional face model.
  • the changes include the leftward, rightward, downward or upward movement of the boundary point in the plane direction, and may also include the upper left forward, the upper left rear, and the lower left forward.
  • the corresponding control point determines the deformation of the background plane reference grid, and the background plane reference grid may be compressed or stretched according to the Laplace deformation method.
  • the alignment control can be performed according to the changes in the x-coordinate and y-coordinate of the boundary point Changes in the x-coordinate and y-coordinate of the corresponding control point.
  • the coordinate position of the boundary point before the deformation and the coordinate position after the deformation can be obtained, and the change of the x coordinate and the y coordinate in the coordinate position before and after the change can be extracted, and the boundary can be controlled according to the change of the extracted x coordinate and y coordinate
  • the coordinate change of the control point corresponding to the point can be obtained, and the change of the x coordinate and the y coordinate in the coordinate position before and after the change.
  • the target position of the control point that needs to be deformed can be determined directly according to the x coordinate and the y coordinate in the coordinate position of the boundary point after the change.
  • the control point corresponding to the boundary point can be determined according to the amount of change in the position of the boundary point in the xoy plane. The amount of change in the position of the point.
  • the change in the position of the boundary point in the xoy plane can be decomposed into the horizontal change and the vertical change, and the movement of the control point is determined according to the horizontal change and the vertical change, so that It corresponds to the boundary points on the 3D face model modeling grid.
  • the change amount of the boundary point can be decomposed into a moving distance and a moving direction, and the movement of the control point is determined according to the moving distance and the moving direction.
  • the items in the image corresponding to the background plane reference grid can be identified, and the items in the image corresponding to the background plane reference grid can be globally stretched or compressed. That is, through the recognized object in the two-dimensional image corresponding to the background plane reference grid, the equal-proportion adjustment control point of the object is determined.
  • the deformation processing method according to the deformed position Perform the same deformation processing on other control points of the object, so that the shape of the deformed object is still in a normal state, avoiding the defect of background image deformation caused by fusion.
  • the control points of the boundary position of the target object A are set. If the control point located at the boundary point is stretched or compressed, so that the part of the target object A is changed, such as the part is stretched or squeezed, it will be deformed according to the scaled control point corresponding to the recognized target object A
  • the processing enables the target object A to achieve overall stretching or compression, so as to avoid affecting the authenticity of the background image when the background plane reference grid is deformed to obtain the background plane modeling grid.
  • the construction process of the aforementioned reference grid can be executed at any time before face processing, and the reference grid can be constructed in non-real-time. That is, the construction of the reference grid can be completed before the image is taken, and once constructed, it can be repeatedly applied to the taken photo processing, or repeatedly applied to the image processing of the video frame of the taken video image.
  • the image can be modeled and used for multiple times according to the pre-built reference grid. For example, after completing a reference grid preprocessing, when the face transformation processing needs to be activated at any time, the pre-built reference grid can be called for image modeling at any time.
  • the reference grid may be constructed in an offline state, that is, the reference grid may not be constructed in the process of performing face image processing on the image.
  • the captured photo is processed in real time, or the captured video is processed with the face image of the video frame deal with.
  • the pre-built three-dimensional face model reference grid and the background plane reference grid to restore the three-dimensional face image corresponding to the face image in the captured photo or video frame.
  • a model fitting method can be used to obtain a three-dimensional mesh model corresponding to the two-dimensional image.
  • the face grid may include a three-dimensional face model. That is, the feature points of the face in the image and the feature points in the pre-built reference grid of the three-dimensional face model can be used to fit the model, and the three-dimensional face model modeling can be matched with the feature points of the collected two-dimensional image grid.
  • the shooting parameters of the two-dimensional image may be determined according to the positions of the feature points of the two-dimensional image, and the shooting parameters may include a model view matrix and a projection matrix.
  • the position of the vertex of the three-dimensional face model reference grid can be changed, and the three-dimensional face model reference grid can be deformed, etc. Processing, so that when the feature point positions in the three-dimensional face model modeling grid are mapped to the collected image, they match with the feature point positions in the collected image. That is, the location of the feature points mapped by the 3D face model modeling grid is consistent with the location of the feature points in the collected image.
  • the attitude of the reference grid of the three-dimensional face model can be adjusted first, including the adjustment of the yaw angle, pitch angle or roll angle of the reference grid of the three-dimensional face model, and then the attitude
  • the vertices at the detailed image of the adjusted three-dimensional face model reference grid are fitted and deformed, so that the feature points in the collected image are different from those in the image projected and mapped by the adjusted three-dimensional face model modeling grid.
  • the sum of the distances between the corresponding feature points is the smallest, or the feature points in the collected image, and the corresponding feature points in the image projected and mapped by the adjusted three-dimensional face model modeling grid are completely matched.
  • the corresponding relationship between the two sets of feature points and the three-dimensional face model grid (including the three-dimensional face model reference grid, and According to the changes of the feature points of the three-dimensional face model modeling grid obtained by fitting the three-dimensional face model reference grid before and after fitting, it is determined that the three-dimensional face model reference grid is transformed into the collected image
  • the corresponding posture model view (MV, model view) matrix and projection matrix is a well-known technology, and will not be detailed here. description.
  • the position of the feature points of the face in the two-dimensional image can be analyzed, combined with the feature points in the preset reference grid of the three-dimensional face model, and the The feature points of the face in the two-dimensional image are fitted to the reference grid of the three-dimensional face model, that is, the positions of the vertices in the reference grid of the three-dimensional face model are adjusted so that the adjusted grid matches The features of the human face in the two-dimensional image.
  • the MV matrix can extract the rotation component, and rotate the three-dimensional face model modeling grid at the same angle according to the extracted rotation component, so as to transform the pose of the three-dimensional face model modeling grid It is the posture corresponding to the collected image.
  • the MV matrix is:
  • I0, I1, and I2 are the modulus of the vector formed by column 0, column 1, and column 2 of the MV matrix, respectively.
  • the movement parameters m30, m31 and m32 are not related to the rotation parameters.
  • the posture of the reference grid of the three-dimensional face model can be adjusted.
  • the reference grid of the three-dimensional face model can be rotated and transformed to restore the face pose corresponding to the collected image.
  • the reference grid of the three-dimensional face model is a general face model grid
  • the general face model grid when used for reconstruction, it may include the entirety of the face model grid.
  • the overall adjustment can be adjusted for the contour of the model.
  • the overall layout of the universal face model including parts such as eyes, ears, nose, mouth, and eyebrows, can be made consistent with the five senses layout of the picture to be restored by including the corresponding feature points.
  • the local adjustment may be fine-tuned for local details, especially facial features, so that local details are more accurate.
  • the face can be reconstructed using vertex-based interpolation.
  • the three-dimensional face model reference grid is a three-dimensional deformed model grid
  • the three-dimensional face model reference may be controlled according to the rotation component in the MV matrix
  • the grid is rotated.
  • the reference grid of the three-dimensional face model is adjusted to the pose corresponding to the collected image, which can be further based on the feature points in the five senses in the two-dimensional face model.
  • Position, to determine the changes in facial features of the reference grid of the 3D face model which can include adjusting facial styles such as eyes, eyebrows, mouth, nose, ears, or face shape, so as to make the adjusted 3D face model grid It more closely matches the face in the captured image.
  • the modeling mesh of the fitted 3D face model is inconsistent with the pose of the face in the collected 2D image.
  • Including, for example, the human face in the two-dimensional image is from the upward perspective, while the three-dimensional face model modeling grid is the frontal perspective.
  • the three-dimensional face model modeling grid needs to be Rotate so that the rotated 3D face model modeling grid is consistent with the angle of view of the face in the collected 2D image.
  • the position of the boundary points of the rotated three-dimensional face model may change when the three-dimensional face model is transformed, according to the preset Whether the position of the boundary point of the three-dimensional face model is changed to determine whether the position of the control point in the background plane reference grid needs to be adjusted accordingly.
  • the control point corresponding to the boundary point is searched, and the background plane reference network is set according to the change of the x-coordinate and y-coordinate of the boundary point.
  • the control points corresponding to the boundary points in the grid are aligned with the boundary points, thereby completing the deformation processing of the background plane reference grid to obtain a background plane modeling grid.
  • the deformation of the control point can be determined according to the change of the coordinate of the boundary point before and after the deformation, for example, according to the change of the x coordinate and the y coordinate of the boundary point Amplitude such that the control point is aligned with the boundary point in the x direction and the y direction.
  • the background plane reference grid is deformed, so that the distance between the position of the deformed control point and the position of the corresponding boundary point is less than a predetermined value, or the processed The position of the control point coincides with the position of the corresponding boundary point.
  • the proportional adjustment control point is set according to the recognized object, if any control point in the object needs Adjustment, that is, when any one of the control points moves, the other control points of the object also move correspondingly, and when any one of them is scaled and adjusted, the other proportional control points are correspondingly controlled to scale.
  • the fixed point may be set around the background plane reference grid, or may be set at the position of some objects.
  • the deformation processing method of the background plane grid may include Laplace transform. It should not be limited to this, it can also include other mesh deformation processing methods such as bone skin animation algorithm.
  • Figure 11 is a schematic diagram of the modeling mesh after deformation processing.
  • the modeling grid schematic diagram includes a three-dimensional face model modeling grid and a background plane modeling grid.
  • the background plane reference grid is deformed by the control points and fixed points to obtain the background plane modeling grid Schematic of the image. It can be seen from Figure 11 that through fitting and combining the model view matrix to deform the reference grid of the three-dimensional face model, including rotating and deforming the reference grid of the three-dimensional face model and/or scaling and deforming, the result is The position of the boundary point of the visible boundary of the three-dimensional face model modeling grid changes. According to the change of the position of the boundary point, the position of the control point of the background plane reference grid is adjusted accordingly, and the background plane reference grid is deformed After processing, the 3D face model modeling grid and the background plane modeling grid obtained after deformation can still be effectively integrated.
  • the collected image can be rendered according to the MV matrix and the projection matrix to obtain the three-dimensional face model grid texture map; extract the The translation component and zoom component in the MV matrix form a new matrix, and use the same projection matrix as the three-dimensional face model to render the background plane grid texture map.
  • a rectangular coordinate system OXYZ for marking the vertex positions on the three-dimensional face model modeling grid may be set, and the three-dimensional face model modeling grid
  • the coordinate position of any vertex on can be expressed as (x, y, z).
  • a UV coordinate system is set on the XOY plane in the rectangular coordinate system, and the collected image can be expressed as (u, v) through the UV coordinate system.
  • the background plane modeling grid determines the second plane, and the second plane may correspond to the two-dimensional image to be processed by a scaling ratio. Since the background plane grid is modeled as a plane, there should be no posture changes. Therefore, for the color of each third pixel on the plane, only the translation component and the zoom component in the MV matrix need to be obtained without consideration.
  • the rotation component is multiplied by the projection matrix, and the translation component and zoom component in the MV matrix to determine that the third pixel is in the acquired two-dimensional image to be processed, such as the fourth pixel corresponding to the acquired picture.
  • the corresponding fourth pixel takes a value on the color of the third pixel on the second plane.
  • the translation component T can be extracted as:
  • the scaling component S is:
  • I0, I1, and I2 are the modulus of the vector formed by column 0, column 1, and column 2 of the MV matrix, respectively.
  • the rendered 3D face model mesh texture map and the background plane mesh texture map it is convenient to render the entire mesh after adjusting the perspective of the 3D face model modeling mesh to obtain a processed image.
  • the projection matrix and the MV matrix are used to determine the rendering plane
  • the corresponding relationship between the pixel value of the pixel and the two-dimensional image results in the three-dimensional face model grid texture map shown in FIG. 12 and the background plane grid texture map shown in FIG. 13.
  • the 3D face model modeling mesh needs to be deformed according to actual usage.
  • the posture of the portrait in the video screen is transformed from the posture of looking at the screen to the posture of looking at the camera. It is necessary to transform the posture of the restored 3D face model modeling grid, for example, for a notebook with a hidden camera, adjust the top view angle of the 3D face model, etc., when the camera is set on the left or right side of the desktop computer monitor , Adjusting the yaw angle of the three-dimensional face model modeling grid, that is, rotating the three-dimensional face model to the left or to the right by a certain angle.
  • the required rotation angle of the three-dimensional face model modeling grid can be determined according to the rotation component extracted from the MV matrix obtained during the modeling of the three-dimensional face model reference grid.
  • the posture angle of a two-dimensional face image collected by a notebook with a hidden camera is 20 degrees upwards horizontally.
  • the posture of looking at the screen is transformed into the posture of looking at the camera.
  • the face model modeling grid is rotated downward by 20 degrees to obtain a front view of the grid as shown in Fig. 14a and a side view of the grid in Fig. 14b.
  • Figure 14b it can be seen that the position of the boundary points of the three-dimensional face model modeling grid has changed, but the control points corresponding to the boundary points have not undergone corresponding deformation processing, and the background plane modeling grid A gap appears between the deformed three-dimensional face model modeling grid.
  • deformation processing When performing deformation processing on the 3D face model modeling grid after restoring the pose corresponding to the human face in the 2D image, a variety of different deformation processing methods can be included according to different application scenarios. For example, it may include face posture deformation processing, face partial deformation processing, and so on.
  • facial posture deformation processing it can be applied to devices where the image capturing camera does not match the center of the screen, including notebooks and desktop computers with hidden camera functions.
  • the captured image will be as shown in Figure 3.
  • the camera is located where the face is looking at. Below the direction, the collected images will show images with a big chin and nose facing upwards that are not what the user expects.
  • the reference grid can be constructed offline in advance, including the construction of the reference grid of the three-dimensional face model and the background plane reference grid.
  • marking the constructed reference grid by identifying the position of the face in the reference grid of the three-dimensional face model in the reference grid, the boundary points of the face are determined, and the boundary points are used to determine the background plane
  • the grid (including the background plane reference grid and the background plane modeling grid) is the control point for transformation, and the fixed point in the background plane grid can be determined according to the magnitude of the image transformation.
  • the fixed point can be set as the edge of the image Place.
  • the camera When the camera collects the user's face image, it can obtain the feature points of the face image, and fit the collected face image with the reference grid of the 3D face model based on the 3D reconstruction algorithm.
  • the correspondence between the feature points and the changes of the feature points of the 3D face model modeling grid before and after fitting, determine the model view matrix and the projection matrix, and use the fitted 3D face model reference grid according to the model view matrix Rotate the rotation component in the image to obtain the face pose model corresponding to the captured image, and determine the control points that need to be adjusted according to the changes in the position of the boundary points of the three-dimensional face model modeling grid obtained after the rotation.
  • the control points deform the background plane reference grid to fuse the background plane modeling grid with the 3D face model modeling grid, and determine the acquisition according to the MV matrix including the image shooting parameters and the projection matrix including the imaging parameters 3D face model grid texture map and background plane grid texture map corresponding to the image.
  • the face pose is transformed so that the adjusted angle of view is adjusted downward to a certain angle, such as 20 degrees downward, and the adjusted 3D model grid is rendered ,
  • the adjusted image effect as shown in Figure 15 is obtained, and the user's front face image is obtained.
  • the captured image may capture the user’s profile image or capture
  • the user's overhead image is not conducive to improving the user's call experience.
  • the reference grid of the 3D face model When the reference grid of the 3D face model is rotated according to the collected images, the reference grid of the 3D face model is rotated in the opposite direction when the camera is set on the left side of the display according to the recognized face posture , To restore the pose of the three-dimensional face model corresponding to the two-dimensional face image.
  • the reference grid of the three-dimensional face model When the camera is set on the right side of the display, the reference grid of the three-dimensional face model is rotated in the opposite direction to restore the posture of the three-dimensional face image corresponding to the two-dimensional face image, and complete the construction of the currently collected image. mold.
  • the three-dimensional face model grid texture map and the background plane grid texture map are obtained.
  • the modeled face model is deformed, including rotating left or right, etc., and the rotated background plane reference grid is deformed, and the obtained three-dimensional
  • the face model grid texture map and the background plane grid texture map are used to render the entire deformed grid to obtain a processed two-dimensional image, and the gaze direction and camera position of the face in the processed two-dimensional image Matching enables users to get a better attention experience during video calls.
  • the time required for the conversion process is relatively short, which helps to improve the real-time performance of video image display and to improve the user experience.
  • the service platform When applied to the local deformation processing of human face, after the user uses any smart device to collect images, including images such as photos or videos, the user may need to send the collected images to other users, or send the collected images to social media In order to improve the satisfaction of users, the service platform needs to make partial adjustments to the collected images, such as thinning the face and thinning the chin.
  • the face in the collected image can be fitted with the reference grid of the three-dimensional face model based on the preset reference grid model and restored to the image
  • the pose corresponding to the face is determined by the MV matrix and projection matrix according to the fitting process, and the fusion transformation is performed according to the boundary points in the 3D face model modeling grid and the control points in the background plane reference grid.
  • the MV matrix and The projection matrix obtains the three-dimensional face model grid texture map and the background plane grid texture map.
  • the three-dimensional face model can be modeled according to preset face beautification parameters The mesh is deformed.
  • the face beautification parameters may include one or more of eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, face shape parameters, and nose wing size parameters.
  • the modeling grid of the three-dimensional face model is further deformed and adjusted according to the face beautification parameters. After the three-dimensional face model modeling grid is adjusted, the background plane modeling grid is further transformed and fused, and a transformed image is obtained through rendering, for example, an image with a thin face or a thin chin is obtained after transformation.
  • the control points corresponding to the boundary points of the three-dimensional face model modeling grid combined with the fixed points in the background plane modeling grid, transform the background plane modeling grid, such as performing Laplace Deformation, so that the front view of the mesh after the background plane modeling mesh is deformed as shown in FIG. 16a and the side view of the mesh after the deformation is completed as shown in FIG. 16b.
  • the three-dimensional face model modeling grid that is consistent with the perspective of the face in the acquired two-dimensional image is controlled to rotate in the opposite direction, so that the rotated three-dimensional face model
  • the modeling grid is transferred to a frontal perspective, which is convenient for generating a frontal two-dimensional image based on the three-dimensional face model modeling grid of the frontal perspective.
  • the transformed 3D face model modeling grid and background plane modeling grid are rendered to obtain the rendered 3D face
  • the image and the background plane image are projected on the three-dimensional face image to obtain a processed two-dimensional image.
  • the method for deforming the face includes deforming the face such as thinning the face or thinning the chin.
  • the 3D face model restored from the currently collected image can be modeled according to the way of pre-setting the standard grid of the 3D face model (3D face model grid for beautification), or preset beautification parameters
  • the grid is transformed, and control points and fixed points can be set on the 3D face model modeling grid, and the 3D face model modeling grid can be controlled to deform according to the standard 3D face model or beautification parameters
  • the deformed three-dimensional face model modeling mesh is obtained.
  • the position of the boundary point on the 3D face model modeling grid obtained after transformation is detected. If the position of the boundary point on the 3D face model modeling grid obtained after transformation is relative to the 3D face before transformation If the position of the boundary point of the model reference grid is changed, the control point of the corresponding background plane modeling grid can be determined according to the transformed boundary point, and the background plane modeling grid can be transformed to obtain the transformation The resulting background plane modeling grid. Or when transforming the background plane modeling grid, the fixed points of the background plane modeling grid can also be set, and the retention properties of the background plane modeling grid can be controlled by the fixed points. For example, the fixed point may be set around the background plane modeling grid.
  • the 3D face model modeling mesh and background plane modeling mesh obtained by the transformation can be rendered according to the texture characteristics of the 3D mesh model before the transformation, or combined with the current light, to obtain the rendered mesh model , Combined with the current posture angle to project the rendered grid model, the processed image can be obtained.
  • this application sets the boundary points of the face and the control points in the background while constructing the reference grid, the background is quickly deformed through the correspondence between the background points and the control points, and the same configuration is used. Next, while generating images with no gap effect, it can also significantly improve image processing efficiency.
  • the face image processing method described in this Set the reference grid, reconstruct the reference grid of the 3D face model, obtain the 3D face model modeling grid after reconstruction, and get the 3D face model mesh texture map and background plane grid texture map.
  • This process It usually takes 25-35ms to deform the reconstructed 3D face model modeling mesh and background plane modeling mesh. This process usually takes 2-3ms. Render the deformed image to get The process of the face deformed image is usually 4-6ms. Therefore, the entire process takes about 31-45ms, while the existing method of using the target image for two-dimensional transformation requires 130-170ms. Through the three-dimensional deformation+ The background fusion mode requires 65-95 ms.
  • the face image processing method described in the embodiment of the present application ensures a good fusion of the face image and the background image while effectively reducing the image processing time.
  • FIG. 17 shows a structural block diagram of a face image processing device provided by an embodiment of the present application. For ease of description, only the same as the embodiment of the present application is shown. The relevant part.
  • FIG. 17 is a schematic structural diagram of a face image processing device provided by an embodiment of the present application, and the face image processing device includes:
  • the image modeling unit 1701 is configured to obtain a two-dimensional image to be processed by an electronic device, construct a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid, and according to the two-dimensional image to be processed Acquiring the texture map of the three-dimensional grid model by taking the shooting parameters of the three-dimensional image, and determining the boundary point according to the visible boundary of the face of the reference grid, and the control point corresponding to the boundary point;
  • the model deformation unit 1702 is configured to perform deformation processing on the three-dimensional mesh model by the electronic device according to preset deformation requirements in combination with the corresponding relationship between the boundary points and the control points, and render the texture image to deform
  • the processed 3D mesh model generates a processed image according to the rendered 3D mesh model.
  • the face image processing device described in FIG. 17 corresponds to the aforementioned face processing method.
  • the face image processing method provided in the embodiments of this application can be applied to notebooks, desktop computers, tablet computers, mobile phones, wearable devices, vehicle-mounted devices, augmented reality (AR)/virtual reality (VR) devices, Ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (personal digital assistants, PDAs) and other electronic devices with cameras, the embodiments of this application do not impose any restrictions on the specific types of electronic devices.
  • FIG. 18 shows a block diagram of a part of the structure of an electronic device 1800 provided in an embodiment of the present application.
  • the electronic device 1800 includes: a memory 1810, a camera 1820, a display unit 1830, a power supply 140, a processor 1850 and other components.
  • the structure of the electronic device 1800 shown in FIG. 18 does not constitute a limitation on the electronic device 1800, and may include more or fewer components than shown, or a combination of certain components, or different components Layout.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2.
  • Mobile communication module 150 wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195, etc.
  • SIM Subscriber identification module
  • the sensor module 180 may include pressure sensor 180A, gyroscope sensor 180B, air pressure sensor 180C, magnetic sensor 180D, acceleration sensor 180E, distance sensor 180F, proximity light sensor 180G, fingerprint sensor 180H, temperature sensor 180J, touch sensor 180K, ambient light Sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100.
  • the electronic device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc.
  • AP application processor
  • modem processor modem processor
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • the different processing units may be independent devices or integrated in one or more processors.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, and a universal asynchronous transmitter (universal asynchronous transmitter) interface.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB Universal Serial Bus
  • the I2C interface is a two-way synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may include multiple sets of I2C buses.
  • the processor 110 may be coupled to the touch sensor 180K, charger, flash, camera 193, etc. through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through an I2C bus interface to implement the touch function of the electronic device 100.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low-frequency baseband signal is processed by the baseband processor and then passed to the application processor.
  • the application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194.
  • the modem processor may be an independent device.
  • the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
  • the electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor.
  • the GPU is a microprocessor for image processing, connected to the display 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
  • the display screen 194 is used to display images, videos, etc.
  • the display screen 194 includes a display panel.
  • the display panel can adopt liquid crystal display (LCD), organic light-emitting diode (OLED), active-matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
  • LCD liquid crystal display
  • OLED organic light-emitting diode
  • active-matrix organic light-emitting diode active-matrix organic light-emitting diode
  • AMOLED flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc.
  • the electronic device 100 may include one or N display screens 194, and N is a positive integer greater than one.
  • the electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
  • the ISP is used to process the data fed back from the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transfers the electrical signal to the ISP for processing and is converted into an image visible to the naked eye.
  • ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193.
  • the camera 193 is used to capture still images or videos.
  • the object generates an optical image through the lens and projects it to the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • ISP outputs digital image signals to DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats.
  • the electronic device 100 may include 1 or N cameras 193, and N is a positive integer greater than 1.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects the frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in a variety of encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, and so on.
  • MPEG moving picture experts group
  • NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • the NPU can realize applications such as intelligent cognition of the electronic device 100, such as image recognition, face recognition, voice recognition, text understanding, and so on.
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiment of the present invention takes an Android system with a layered architecture as an example to exemplify the software structure of the electronic device 100.
  • FIG. 2 is a software structure block diagram of an electronic device 100 according to an embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface.
  • the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
  • Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
  • the application layer and the application framework layer run in a virtual machine.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
  • the system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
  • the 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
  • the application layer is used to run installed applications or applications in the system, including, for example, camera, calendar, map, WLAN, music, short message, gallery, call, navigation, Bluetooth, and video.
  • the corresponding hardware interrupt is sent to the kernel layer.
  • the kernel layer processes touch operations into original input events (including touch coordinates, time stamps of touch operations, etc.).
  • the original input events are stored in the kernel layer.
  • the application framework layer obtains the original input event from the kernel layer, and identifies the control corresponding to the input event. Taking the touch operation as a touch click operation, and the control corresponding to the click operation is the control of the camera application icon as an example, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer.
  • the camera 193 captures still images or videos.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Software Systems (AREA)
  • Architecture (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Geometry (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Processing Or Creating Images (AREA)

Abstract

A human face image processing method, comprising: an electronic device obtains a two-dimensional image to be processed, constructs a three-dimensional grid model corresponding to said image according to a preset reference grid, obtains a texture map of the three-dimensional grid model according to a photographing parameter of said image, and determines a boundary point and a control point corresponding thereto according to the visible boundary of the face of the reference grid; the electronic device deforms the three-dimensional grid model in combination with the correspondence between the boundary point and the control point according to the preset deformation requirement, renders the texture map to the deformed three-dimensional grid model, and generates a processed image according to the rendered three-dimensional grid model.

Description

人脸图像处理方法及电子设备Human face image processing method and electronic equipment
本申请要求于2019年08月09日提交国家知识产权局、申请号为201910735963.9、申请名称为“人脸图像处理方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the State Intellectual Property Office on August 9, 2019, the application number is 201910735963.9, and the application name is "face image processing method and electronic equipment", the entire content of which is incorporated herein by reference Applying.
技术领域Technical field
本申请涉及图像处理领域,具体涉及一种人脸图像处理方法及电子设备。This application relates to the field of image processing, and in particular to a face image processing method and electronic equipment.
背景技术Background technique
随着摄像技术的发展,摄像功能被越来越广泛的应用于智能设备,比如应用于智能手机、平板电脑和笔记本电脑等。通过摄像功能可以方便用户进行图像采集,包括拍摄照片或视频等,使得智能设备更受用户的青睐。With the development of camera technology, the camera function is more and more widely used in smart devices, such as smart phones, tablet computers, and notebook computers. The camera function can facilitate users to collect images, including taking photos or videos, making smart devices more popular with users.
在使用智能设备的摄像功能时,由于智能设备的摄像装置一般设置在屏幕之外的区域,用户注视屏幕时,摄像装置所采集的图像中的人脸姿态会发生倾斜,需要对图像中的人脸姿态进行矫正。目前采用的基于3D人脸重建后进行形变融合方法,生成校正后的2D人脸并与背景融合时,需要耗费较长的时间,特别是在使用摄像功能进行视频通话时,达不到实时处理的要求。When using the camera function of a smart device, since the camera device of the smart device is generally set in an area outside the screen, when the user looks at the screen, the facial posture in the image collected by the camera device will be tilted. Correct the face posture. The current method of deformation fusion based on 3D face reconstruction after reconstruction takes a long time to generate a corrected 2D face and fusion with the background, especially when the camera function is used for video calls, which cannot achieve real-time processing. Requirements.
发明内容Summary of the invention
本申请提供一种人脸图像处理方法及电子设备,以解决现有技术中对图像中的人脸姿态进行矫正时,需要耗费较长时间,不能满足实时性要求的问题。The present application provides a face image processing method and electronic device to solve the problem that when correcting the face posture in the image in the prior art, it takes a long time and cannot meet the real-time requirements.
为达到上述目的,本申请采用如下技术方案:In order to achieve the above objectives, this application adopts the following technical solutions:
第一方面,本申请实施例提供了一种人脸图像人脸图像处理方法,所述人脸图像处理方法包括:电子设备获取待处理的二维图像,根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型,根据所述待处理的二维图像的拍摄参数获取所述三维网格模型的纹理图,根据所述基准网格的脸部的可见边界确定边界点,以及与所述边界点对应的控制点;所述电子设备根据预设的变形要求,结合所述边界点与控制点的对应关系,对所述三维网格模型进行变形处理,将所述纹理图像渲染至变形处理后的三维网格模型,根据渲染后的三维网格模型生成处理后的图像。In the first aspect, an embodiment of the present application provides a face image processing method for a face image. The face image processing method includes: an electronic device acquires a two-dimensional image to be processed, and constructs a face image according to a preset reference grid. The three-dimensional mesh model corresponding to the two-dimensional image to be processed, the texture map of the three-dimensional mesh model is obtained according to the shooting parameters of the two-dimensional image to be processed, and the visible boundary of the face of the reference mesh is determined Boundary points, and control points corresponding to the boundary points; the electronic device performs deformation processing on the three-dimensional mesh model according to preset deformation requirements and in combination with the corresponding relationship between the boundary points and the control points, and The texture image is rendered to the deformed three-dimensional mesh model, and the processed image is generated according to the rendered three-dimensional mesh model.
可以看出,电子设备根据所获取的待处理的二维图像获取拍摄参数,根据二维图像结合基准网格构建三维网格模型,根据基准网格确定边界点和控制点,根据预设的变形要求,结合边界点和控制点对三维网格模型进行变形处理,可以有效的提高三维网格模型的变形处理效率,并将处理后的三维网格模型进行纹理图像的渲染,从而能够提高电子设备处理图像的效率,较好的满足电子设备对图像实时处理的时效性要求。比如可以应用于视频图像的实时处理,减少处理后的图像的延时,提升用户使用体验。It can be seen that the electronic device acquires shooting parameters according to the acquired two-dimensional image to be processed, builds a three-dimensional grid model according to the two-dimensional image combined with the reference grid, determines the boundary points and control points according to the reference grid, and according to the preset deformation It is required to combine the boundary points and control points to deform the 3D mesh model, which can effectively improve the efficiency of the deformation processing of the 3D mesh model, and render the processed 3D mesh model to the texture image, thereby improving the electronic equipment The efficiency of image processing can better meet the timeliness requirements of electronic equipment for real-time image processing. For example, it can be applied to real-time processing of video images to reduce the delay of processed images and improve user experience.
可能的,所述电子设备根据摄像头所采集的视频中实时提取视频帧,将所提取的视频帧作为待处理的二维图像;或者,所述电子设备将摄像头所拍摄的照片作为待处理的二维图像。在获取待处理的二维图像后,可以检测所述二维图像是否包括人脸图像,如果所述二维图像中包括人脸图像,则启用本申请所述人脸图像处理方法,调用预先设定的基准网格构建三维网格模型。如果所述二维图像中没有检测到人脸图像,则可以直接显示所采集的图像。Possibly, the electronic device extracts video frames in real time from the video collected by the camera, and uses the extracted video frames as the two-dimensional images to be processed; or, the electronic device uses the photos taken by the camera as the two-dimensional images to be processed. Dimensional image. After acquiring the two-dimensional image to be processed, it can be detected whether the two-dimensional image includes a face image. If the two-dimensional image includes a face image, the face image processing method described in this application is activated and the preset Build a three-dimensional grid model based on a predetermined reference grid. If no face image is detected in the two-dimensional image, the collected image can be directly displayed.
在一种可能的实现方式中,所述基准网格包括三维人脸模型基准网格和背景平面基准网格,所述三维网格模型包括三维人脸模型建模网格和背景平面建模网格,电子设备根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型的步骤包括:电子设备将三维人脸模型基准网格与所述待处理的二维图像拟合,并根据拟合后的三维人脸模型基准网格,获取所述待处理的二维图像的拍摄参数;根据所述拍摄参数,电子设备对所述三维人脸模型基准网格进行姿态调整,得到三维人脸模型建模网格,所述三维人脸模型建模网格与所述二维图像中的人脸姿态一致。In a possible implementation manner, the reference grid includes a three-dimensional face model reference grid and a background plane reference grid, and the three-dimensional grid model includes a three-dimensional face model modeling grid and a background plane modeling grid. The step of the electronic device constructing a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid includes: the electronic device combines the reference grid of the three-dimensional face model with the two-dimensional image to be processed Fit, and obtain the shooting parameters of the two-dimensional image to be processed according to the fitted reference grid of the three-dimensional face model; according to the shooting parameters, the electronic device poses the reference grid of the three-dimensional face model Through adjustment, a three-dimensional face model modeling grid is obtained, and the three-dimensional face model modeling grid is consistent with the face pose in the two-dimensional image.
示例性的,所述基准网格中的三维人脸模型基准网格为通用人脸模型或三维变形模型。通过待处理的二维图像中所包括的人脸图像的特征,对基准网格进行拟合操作,使得基准网格变换后,得到包括人脸特征的基准网格。然后进一步结合二维图像中的姿态特征,可以为本申请中的拍摄参数中的旋转向量,对所述基准网格进行旋转,从而使得三维人脸模型能够有效的与二维图像中的人脸姿态匹配。Exemplarily, the reference grid of the three-dimensional face model in the reference grid is a general face model or a three-dimensional deformed model. A fitting operation is performed on the reference grid based on the features of the face image included in the two-dimensional image to be processed, so that after the reference grid is transformed, the reference grid including the face features is obtained. Then, in combination with the posture features in the two-dimensional image, the reference grid can be rotated by the rotation vector in the shooting parameters in this application, so that the three-dimensional face model can effectively match the face in the two-dimensional image. Posture matching.
可能的实现方式中,所述拍摄参数包括模型视图矩阵和投影矩阵,所述根据所述拍摄参数,所述电子设备对所述三维人脸模型基准网格进行姿态调整的步骤包括:根据所述模型视图矩阵,电子设备提取旋转分量;根据所提取的旋转分量,电子设备控制拟合后的三维人脸模型基准网格旋转至所述待处理的二维图像所对应的人脸姿态。In a possible implementation manner, the shooting parameters include a model view matrix and a projection matrix, and the step of adjusting the posture of the reference grid of the three-dimensional face model by the electronic device according to the shooting parameters includes: In the model view matrix, the electronic device extracts the rotation component; according to the extracted rotation component, the electronic device controls the fitted reference grid of the three-dimensional face model to rotate to the face pose corresponding to the two-dimensional image to be processed.
当然,对所述三维人脸模型基准网格进行姿态调整时,不局限于此,还可以通过特征点组合的方式,或者通过特征对比的方式,确定所述三维人脸模型基准网格的旋转分量,对拟合后的三维人脸模型基准网格进行旋转操作。Of course, when the pose adjustment is performed on the reference grid of the three-dimensional face model, it is not limited to this, and the rotation of the reference grid of the three-dimensional face model can also be determined by means of feature point combination or feature comparison. Component, rotate the reference grid of the fitted 3D face model.
在一种可能的实现方式中,所述电子设备根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型的步骤还包括:确定姿态调整后的三维人脸模型建模网格中发生位置改变的边界点;根据发生位置改变的边界点查找对应的控制点,根据所查找的控制点对所述背景平面基准网格进行变形控制。In a possible implementation manner, the step of the electronic device constructing a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid further includes: determining a three-dimensional face model after posture adjustment Boundary points in the modeling grid that have changed positions; search for corresponding control points according to the changed positional boundary points, and perform deformation control on the background plane reference grid according to the searched control points.
可以看出,通过设定背景平面建模网格和三维人脸模型建模网格,在对三维人脸模型建模网格进行调整后,可以根据边界点的变化,快速的对背景平面建模网格进行适应性调整,有利于提高调整的响应速度。其中,所述三维人脸模型建模网格为三维人脸模型基准网格与二维图像中的人脸图像拟合后得到,所述背景平面建模网格可以在对三维人脸模型基准网格进行拟合或姿态调整时,根据边界点与控制点的关系调整背景平面基准网格得到。It can be seen that by setting the background plane modeling grid and the 3D face model modeling grid, after adjusting the 3D face model modeling grid, the background plane can be quickly constructed according to the changes in the boundary points. The adaptive adjustment of the mold grid is helpful to improve the response speed of adjustment. Wherein, the three-dimensional face model modeling grid is obtained by fitting a reference grid of a three-dimensional face model with a face image in a two-dimensional image, and the background plane modeling grid can be obtained after a reference grid of a three-dimensional face model When the grid is fitted or the attitude is adjusted, the background plane reference grid is adjusted according to the relationship between the boundary points and the control points.
在一种可能的实现方式中,所述纹理图包括三维人脸模型网格纹理图和背景平面网格纹理图,所述电子设备根据所述待处理的二维图像的拍摄参数获取所述三维网格模型的纹理图的步骤包括:根据所述模型视图矩阵和投影矩阵,所述电子设备获取所述三维人脸模型网格纹理图;根据投影矩阵,以及所述模型视图矩阵中的平移向量和 缩放向量,所述电子设备获取所述背景平面网格纹理图。In a possible implementation, the texture map includes a three-dimensional face model grid texture map and a background plane grid texture map, and the electronic device obtains the three-dimensional face model according to the shooting parameters of the two-dimensional image to be processed. The step of the texture map of the grid model includes: according to the model view matrix and the projection matrix, the electronic device obtains the three-dimensional face model grid texture map; according to the projection matrix and the translation vector in the model view matrix And a zoom vector, the electronic device obtains the background plane grid texture map.
其中,所述根据所述模型视图矩阵和投影矩阵,所述电子设备获取所述三维人脸模型网格纹理图的步骤可以包括:所述电子设备获取所述三维人脸模型建模网格中的顶点在空间直角坐标系中的坐标,在所述顶点坐标中的z坐标为0时渲染得到第一平面;所述电子设备根据第一平面的第一像素点的位置与模型视图矩阵、投影矩阵的乘积,确定第一像素点在待处理的二维图像上所对应的第二像素点,根据第二像素点的颜色确定第一像素点的颜色。Wherein, according to the model view matrix and the projection matrix, the step of obtaining the three-dimensional face model mesh texture map by the electronic device may include: the electronic device obtaining the three-dimensional face model modeling grid The coordinates of the vertices in the space rectangular coordinate system, when the z coordinate in the vertices coordinates is 0, the first plane is rendered; the electronic device is based on the position of the first pixel of the first plane and the model view matrix and projection The product of the matrix determines the second pixel corresponding to the first pixel on the two-dimensional image to be processed, and the color of the first pixel is determined according to the color of the second pixel.
其中,所述根据投影矩阵,以及所述模型视图矩阵中的平移向量和缩放向量,所述电子设备获取所述背景平面网格纹理图的步骤可以包括:所述电子设备根据背景平面建模网格确定第二平面,并提取模型视图矩阵中的平移矩阵和缩放矩阵;所述电子设备根据第二平面的每一个第三像素点的位置与平移矩阵、缩放矩阵和投影矩阵的乘积,确定第三像素点在待处理的二维图像上所对应的第四像素点,根据第四像素点的颜色确定第三像素点的颜色。Wherein, according to the projection matrix, and the translation vector and the zoom vector in the model view matrix, the step of obtaining the background plane grid texture map by the electronic device may include: the electronic device modeling the network according to the background plane The grid determines the second plane, and extracts the translation matrix and the zoom matrix in the model view matrix; the electronic device determines the second plane according to the position of each third pixel in the second plane and the product of the translation matrix, the zoom matrix, and the projection matrix. For the fourth pixel point corresponding to the three-pixel point on the two-dimensional image to be processed, the color of the third pixel point is determined according to the color of the fourth pixel point.
可以看出,通过模型视图矩阵和投影矩阵,可以确定二维图像中的像素点与纹理图(包括三维人脸模型网格纹理图和背景平面网格纹理图)的对应关系,并且背景平面网格纹理图不需要旋转处理,则可以通过模型视图矩阵中的缩放向量和平移向量即可。通过生成三维网格模型的纹理图,便于在三维网格模型变换后,能够快速的生成三维网格模型的图像。不局限于此,还可以通过特征点匹配等方式,生成三维网格模型的纹理图。It can be seen that through the model view matrix and the projection matrix, the correspondence between the pixels in the two-dimensional image and the texture map (including the three-dimensional face model grid texture map and the background plane grid texture map) can be determined, and the background plane network The lattice texture map does not need to be rotated, you can use the zoom vector and the translation vector in the model view matrix. By generating the texture map of the 3D mesh model, it is convenient to quickly generate the image of the 3D mesh model after the 3D mesh model is transformed. Not limited to this, the texture map of the three-dimensional mesh model can also be generated by means of feature point matching.
在一种可能的实现方式中,所述电子设备对所述三维网格模型进行变形处理的步骤包括:所述电子设备获取所构建的三维网格模型中的三维人脸模型建模网格的姿态;所述电子设备根据所构建的三维人脸模型建模网格的姿态与目标姿态的角度关系,旋转所述三维人脸模型建模网格。In a possible implementation manner, the step of the electronic device deforming the three-dimensional mesh model includes: the electronic device obtains the information of the three-dimensional face model modeling mesh in the constructed three-dimensional mesh model Posture; the electronic device rotates the three-dimensional face model modeling grid according to the angle relationship between the posture of the constructed three-dimensional face model modeling grid and the target posture.
示例性的,当电子设备采集到的用户图像的角度为仰视角度,得到的二维图像呈现出双下巴、朝天鼻等特征时,对该二维图像进行调整时,所确定的目标姿态即为水平角度所对应的用户图像。所构建的三维人脸模型建模网格的姿态与目标姿态的角度关系,即为电子设备采集图像的仰视角度与水平线的夹角。使三维人脸模型建模网格根据该夹角向下旋转,使得三维人脸模型建模网格的姿态水平面向前方。Exemplarily, when the angle of the user image collected by the electronic device is the looking-up angle, and the obtained two-dimensional image presents features such as double chin and upward nose, when the two-dimensional image is adjusted, the determined target posture is The user image corresponding to the horizontal angle. The angle relationship between the posture of the constructed three-dimensional face model modeling grid and the target posture is the angle between the upward angle of the image collected by the electronic device and the horizontal line. The three-dimensional face model modeling grid is rotated downward according to the included angle, so that the posture of the three-dimensional face model modeling grid faces forward horizontally.
在一种可能的实现方式中,所述电子设备根据预设的变形要求,对所述三维人脸模型建模网格进行变形处理的步骤包括:所述电子设备获取预设的人脸美化参数;根据所述人脸美化参数,所述电子设备对所述三维网格模型中的三维人脸模型建模网格进行调整。In a possible implementation manner, the step of the electronic device performing deformation processing on the three-dimensional face model modeling grid according to preset deformation requirements includes: the electronic device obtains preset face beautification parameters ; According to the face beautification parameters, the electronic device adjusts the three-dimensional face model modeling grid in the three-dimensional grid model.
可能的实现方式中,所述人脸美化参数包括眼睛大小参数、眼睛间距参数、人脸胖瘦参数、嘴巴大小参数、去眼袋参数、脸型参数和鼻翼大小参数中的一种或者多种。In a possible implementation manner, the face beautification parameters include one or more of eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, face shape parameters, and nose wings size parameters.
示例性的,当电子设备接收到用户的美化请求时,可以根据所述美化请求,选择预先设定的眼睛大小参数、眼睛间距参数、人脸胖瘦参数、嘴巴大小参数、去眼袋参数、脸型参数和鼻翼大小参数中的一种或者多种,作为当前美化请求对应的人脸美化参数。根据所述人脸美化参数对所述三维人脸模型建模网格进行调整。调整时,可以根据三维人脸模型建模网格中的特征点的距离,按照一定的比例进行调整。比如,人 脸美化参数包括脸型参数时,可以选择两组或两组以上的,用于表征脸宽的特征点对,并且特征点对的距离符合预定的比值关系。根据预先设定的特征点对的距离的比值关系,对当前的三维人脸模型建模网格中相应的特征点对的距离的比值关系进行调整,使其与预设的比值关系相符,从而实现对人脸的美化,比如调整下巴相对于人脸的宽度,使得美化后得到瓜子脸型等。Exemplarily, when an electronic device receives a user's beautification request, it can select preset eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, and face shape according to the beautification request. One or more of the parameters and the wing size parameters are used as the face beautification parameters corresponding to the current beautification request. The modeling grid of the three-dimensional face model is adjusted according to the face beautification parameters. When adjusting, the distance between the feature points in the 3D face model modeling grid can be adjusted according to a certain ratio. For example, when the face beautification parameters include face shape parameters, two or more than two sets of feature point pairs can be selected to characterize the face width, and the distance of the feature point pairs conforms to a predetermined ratio relationship. According to the pre-set ratio of the distance between the feature point pairs, adjust the ratio of the distance between the corresponding feature point pairs in the current three-dimensional face model modeling grid to make it consistent with the preset ratio relationship. Realize the beautification of the face, such as adjusting the width of the chin relative to the face, so that the face shape of melon seeds can be obtained after beautification.
在一种实现方式中,所述电子设备结合所述边界点与控制点的对应关系,对所述三维网格模型进行变形处理的步骤包括:所述电子设备获取边界点位于所述基准网格中的三维人脸模型基准网格上的第一位置,以及边界点位于所述三维网格模型中的三维人脸模型建模网格上的第二位置;在第二位置与第一位置的距离大于预定值时,所述电子设备查找所述边界点对应的控制点;所述电子设备根据所查找的控制点对所述背景平面建模网格进行变形处理。In an implementation manner, the step of performing deformation processing on the three-dimensional mesh model by the electronic device in combination with the corresponding relationship between the boundary points and the control points includes: the electronic device acquires that the boundary points are located in the reference grid The first position on the reference grid of the three-dimensional face model, and the boundary point is located at the second position on the three-dimensional face model modeling grid in the three-dimensional grid model; the difference between the second position and the first position When the distance is greater than a predetermined value, the electronic device searches for a control point corresponding to the boundary point; the electronic device performs deformation processing on the background plane modeling grid according to the searched control point.
在一种可能的实现方式中,所述电子设备根据所查找的控制点对所述背景平面建模网格进行变形处理的步骤包括:所述电子设备获取所述边界点的坐标位置在背景平面的坐标变化量;根据所述边界点的坐标位置在背景平面的坐标变化量,所述电子设备确定所述控制点的目标位置;根据所述目标位置,所述电子设备对背景平面建模网格进行拉普拉斯变形处理。In a possible implementation manner, the step of the electronic device performing deformation processing on the background plane modeling grid according to the searched control point includes: the electronic device obtains the coordinate position of the boundary point on the background plane According to the coordinate change of the coordinate position of the boundary point in the background plane, the electronic device determines the target position of the control point; according to the target position, the electronic device models the background plane Grid performs Laplace deformation processing.
可以看出,在对三维人脸模型基准网格进行变形处理时,包括拟合或姿态调整等处理方式,背景平面基准网格可以根据边界点与控制点的对应关系,快速的确定目标变换位置,从而快速的对背景平面基准网格完成调整,因而提高图像处理的响应速度。It can be seen that when the reference grid of the 3D face model is deformed, it includes processing methods such as fitting or posture adjustment. The background plane reference grid can quickly determine the target transformation position according to the corresponding relationship between the boundary points and the control points. , Thereby quickly completing the adjustment to the background plane reference grid, thereby improving the response speed of image processing.
其中,根据所述边界点的坐标位置确定对应的控制点时,可以获取所述边界点在所述背景平面的垂直投影,或者也可以通过截取所述边界点的三维坐标其中的二维坐标得到对应的控制。Wherein, when the corresponding control point is determined according to the coordinate position of the boundary point, the vertical projection of the boundary point on the background plane can be obtained, or the two-dimensional coordinates can be obtained by intercepting the three-dimensional coordinates of the boundary point The corresponding control.
在一种可能的实现方式中,根据所述目标位置,所述电子设备对背景平面建模网格进行拉普拉斯变形处理的步骤包括:所述电子设备获取所述背景平面建模网格上设置的控制点;根据所设置的控制点,以及控制点的目标位置,所述电子设备对背景平面建模网格进行拉普拉斯变形处理。In a possible implementation manner, according to the target position, the step of the electronic device performing Laplace deformation processing on the background plane modeling grid includes: the electronic device obtains the background plane modeling grid According to the set control point and the target position of the control point, the electronic device performs Laplace deformation processing on the background plane modeling grid.
可以看出,通过对背景平面建模网格中的控制点的目标位置,对所述背景平面建模网格进行拉普拉斯变形处理,可以使得背景平面建模网格与三维人脸模型建模网格有效的融合,提高变换后的图像的真实性,避免出现图像间隙。It can be seen that by performing Laplacian deformation processing on the background plane modeling grid with the target position of the control point in the background plane modeling grid, the background plane modeling grid can be combined with the three-dimensional face model. The modeling grid is effectively fused to improve the authenticity of the transformed image and avoid image gaps.
在一种可能的实现方式中,在所述电子设备获取待处理的二维图像的步骤之前,所述方法还包括:所述电子设备构建三维人脸模型基准网格和背景平面基准网格;所述电子设备获取三维人脸模型基准网格中的脸部区域;根据所述脸部区域的可见边界,所述电子设备确定边界点和控制点的位置。In a possible implementation manner, before the step of acquiring the two-dimensional image to be processed by the electronic device, the method further includes: the electronic device constructing a three-dimensional face model reference grid and a background plane reference grid; The electronic device obtains the face area in the reference grid of the three-dimensional face model; according to the visible boundary of the face area, the electronic device determines the positions of the boundary points and the control points.
第二方面,本申请提供了一种电子设备,所述电子设备包括存储器、处理屏和计算机程序,所述显示屏用于处理后的图像,所述计算机程序存储在所述存储器中,所述计算机程序包括指令,当所述指令被所述电子设备执行时,使得所述电子设备执行如第一方面任一项所述人脸图像处理方法。In a second aspect, the present application provides an electronic device that includes a memory, a processing screen, and a computer program. The display screen is used for processed images. The computer program is stored in the memory. The computer program includes instructions, which when executed by the electronic device, cause the electronic device to execute the face image processing method according to any one of the first aspect.
第三方面,本申请提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如第一方面任一项所述人脸图 像处理方法。In a third aspect, the present application provides a computer-readable storage medium that stores a computer program that, when executed by a processor, realizes the face image described in any one of the first aspect Approach.
第四方面,本申请提供了一种包含指令的计算机程序产品,所述计算机程序产品在电子设备上运行时,使得电子设备执行如第一方面任一项所述的人脸图像处理方法。In a fourth aspect, this application provides a computer program product containing instructions that, when the computer program product runs on an electronic device, causes the electronic device to execute the face image processing method described in any one of the first aspect.
可以理解地,上述提供的第二方面所述的电子设备、第三方面所述的计算机存储介质,以及第四方面所述的计算机程序产品均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。Understandably, the electronic equipment described in the second aspect, the computer storage medium described in the third aspect, and the computer program product described in the fourth aspect provided above are all used to execute the corresponding methods provided above. For the beneficial effects that can be achieved, please refer to the beneficial effects in the corresponding method provided above, which will not be repeated here.
附图说明Description of the drawings
图1为本申请实施例提供的一种隐藏式摄像头的结构示意图;FIG. 1 is a schematic structural diagram of a hidden camera provided by an embodiment of the application;
图2为本申请实施例提供的一种使用隐藏式摄像头进行视频通话的示意图;2 is a schematic diagram of using a hidden camera to make a video call according to an embodiment of the application;
图3为本申请实施例提供的一种通过隐藏式摄像头拍摄的图像的效果示意图;FIG. 3 is a schematic diagram of the effect of an image captured by a hidden camera provided by an embodiment of the application;
图4为本申请实施例提供的一种基于目标图像匹配的方式进行人脸图像处理的对比效果示意图;4 is a schematic diagram of the comparison effect of face image processing based on a target image matching method provided by an embodiment of the application;
图5为本申请实施例提供的一种人脸图像处理的流程示意图;FIG. 5 is a schematic flowchart of a face image processing provided by an embodiment of the application;
图6为本申请实施例提供的一种通用人脸模型示意图;Fig. 6 is a schematic diagram of a general face model provided by an embodiment of the application;
图7为本申请实施例提供的一种三维变形模型示意图;FIG. 7 is a schematic diagram of a three-dimensional deformation model provided by an embodiment of the application;
图8为本申请实施例提供的一种基准网格示意图;FIG. 8 is a schematic diagram of a reference grid provided by an embodiment of this application;
图9为本申请实施例提供的一种在基准网格右前方视角标记边界点的示意图;FIG. 9 is a schematic diagram of marking boundary points at the front right perspective of a reference grid according to an embodiment of the application;
图10为本申请实施例提供的一种在基准网格正面标记边界点的示意图;FIG. 10 is a schematic diagram of marking boundary points on the front of a reference grid according to an embodiment of the application;
图11为本申请实施例提供的一种经过变形处理后的建模网格示意图;11 is a schematic diagram of a modeling mesh after deformation processing provided by an embodiment of the application;
图12为本申请实施例提供的一种三维人脸模型网格纹理图的示意图;12 is a schematic diagram of a mesh texture map of a three-dimensional face model provided by an embodiment of the application;
图13为本申请实施例提供的一种背景平面网格纹理图的示意图;FIG. 13 is a schematic diagram of a background plane grid texture map provided by an embodiment of this application;
图14a和图14b分别为本申请实施例提供的一种三维人脸模型建模网格变形处理后的侧面视图和正面视图;14a and 14b are respectively a side view and a front view of a three-dimensional face model modeling grid after deformation processing provided by an embodiment of the application;
图15为本申请实施例提供的一种通过姿态调整和渲染后的图像示意图;15 is a schematic diagram of an image after posture adjustment and rendering provided by an embodiment of the application;
图16a和图16b分别为本申请实施例提供的一种背景平面建模网格调整后的三维网格模型的正面视图和侧面视图;16a and 16b are respectively a front view and a side view of a three-dimensional grid model after adjusting the background plane modeling grid according to an embodiment of the application;
图17为本申请实施例提供的一种图像处理装置的结构示意图;FIG. 17 is a schematic structural diagram of an image processing device provided by an embodiment of this application;
图18为本申请实施例提供的一种电子设备的结构示意图;FIG. 18 is a schematic structural diagram of an electronic device provided by an embodiment of this application;
图19为本申请实施例提供的电子设备的软件结构框图。FIG. 19 is a block diagram of the software structure of an electronic device provided by an embodiment of the application.
具体实施方式detailed description
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,本申请省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, for the purpose of illustration rather than limitation, specific details such as a specific system structure and technology are proposed for a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, this application omits detailed descriptions of well-known systems, devices, circuits, and methods, so as to avoid unnecessary details from obstructing the description of this application.
以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形 式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请实施例中,“一个或多个”是指一个、两个或两个以上;“和/或”,描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。The terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to limit the application. As used in the specification and appended claims of this application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to also This includes expressions such as "one or more" unless the context clearly indicates to the contrary. It should also be understood that in the embodiments of the present application, "one or more" refers to one, two, or more than two; "and/or" describes the association relationship of associated objects, indicating that three relationships may exist; for example, A and/or B can mean: A alone exists, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character "/" generally indicates that the associated objects are in an "or" relationship.
本申请实施例的主要目的是用于解决现有的人脸图像处理时,对实时采集的人脸图像进行处理时,变换效果不佳、响应速度较慢的问题,具体介绍如下:The main purpose of the embodiments of the present application is to solve the problems of poor transformation effect and slow response speed when processing face images collected in real time in the existing face image processing. The details are as follows:
本申请所述人脸图像处理方式,可包括对图像中的人脸姿态或角度进行变换,或者对图像中的人脸进行特效处理,包括对人脸采集美颜、变胖、变瘦、哈哈镜等人脸图像处理方式。The face image processing methods described in this application may include transforming the pose or angle of the face in the image, or performing special effects processing on the face in the image, including collecting facial beauty, fattening, thinning, and mirroring. And other face image processing methods.
在对图像中的人脸姿态进行变换的应用场景中,为了提高屏幕占比,解决防偷拍问题,出现了一种隐藏式摄像头的笔记本,其摄像头可能为设置在屏幕下方键盘的隐藏式摄像头。如图1所示,所述隐藏式摄像头可以选择键盘中部位置设置一个专门的按键,通过该按键来安装摄像头。在按键上设置摄像头时,可以通过按压式结构,将所述摄像头设置在按键的侧面,比如将摄像头设置在按键的前侧,或者当按键是可以旋转的按压式按键时,则可以设置在任意侧面。In the application scenario of transforming the face posture in the image, in order to increase the screen ratio and solve the problem of anti-candid shooting, a notebook with a hidden camera appears. The camera may be a hidden camera with a keyboard set at the bottom of the screen. As shown in Figure 1, the hidden camera can choose to set a special button in the middle of the keyboard, and install the camera through this button. When the camera is set on the button, the camera can be set on the side of the button through a pressing structure, for example, the camera is set on the front side of the button, or when the button is a push button that can be rotated, it can be set at any side.
当用户需要使用摄像头时,可以按压所述按键,所述按键的后侧可以为通过转轴固定,所述按键的前侧可以通过弹性部件的弹力向上弹出,使得摄像头所在的键盘侧面,与该键盘的前方的键盘平面之间的夹角大于90度,比如可以为120度、135度等,使得摄像头可以采集到正常使用所述笔记本的用户的完整的人脸图像。When the user needs to use the camera, he can press the button. The rear side of the button can be fixed by a rotating shaft. The front side of the button can be popped up by the elastic force of the elastic member, so that the side of the keyboard where the camera is located is in line with the keyboard. The angle between the front keyboard planes is greater than 90 degrees, such as 120 degrees, 135 degrees, etc., so that the camera can collect a complete face image of the user who normally uses the notebook.
当然,所述摄像头也可以设置为可以灵活调整为多个角度。可以根据当前检测到的到人脸图像的完整性,来调整所述摄像头的旋转角度。比如,当用户距离屏幕较近时,如果根据摄像头采集的图像仅能检测到用户的人脸图像的下部,则可以控制摄像头向上旋转,直到获取完整的人脸图像,或者用户距离屏幕较远时,如果采集的图像中人脸位于图像中的下部,则可以调整所述摄像头的角度,使人脸图像位于图像中部。Of course, the camera can also be set to be flexibly adjustable to multiple angles. The rotation angle of the camera can be adjusted according to the integrity of the face image currently detected. For example, when the user is close to the screen, if only the lower part of the user's face image can be detected according to the image collected by the camera, the camera can be controlled to rotate upward until the complete face image is obtained, or the user is far away from the screen If the face of the collected image is located in the lower part of the image, the angle of the camera can be adjusted so that the face image is located in the middle of the image.
当用户使用该笔记本进行视频通话时,如图2所示,用户在视频通话过程中,眼睛注视方向通常在屏幕区域所对应的方向,隐藏式摄像头拍摄人脸的角度为仰角,从而使得用户在视频通话或拍照时,摄像头的拍摄角度,与用户的注视角度之间出现一定的夹角β,所拍摄的人脸图像会呈现出如图3所示的“大下巴”、“朝天鼻”等图像效果,达不到用户所期望的拍摄视角的要求。并且,在视频通话过程中,所拍摄的图像中的人脸所注视的角度,通常会呈现出没有注视或留意通话对方的假象(实际上用户正在注视屏幕中的通话对方),不利于提高用户沟通使用体验。When the user uses the notebook to make a video call, as shown in Figure 2, the user’s eye gaze direction is usually in the direction corresponding to the screen area during the video call. The hidden camera captures the face at an elevation angle, so that the user is in When making a video call or taking a photo, there is a certain angle β between the camera's shooting angle and the user's gaze angle, and the captured face image will show a "big chin", "upward nose", etc. as shown in Figure 3 The image effect does not meet the requirements of the shooting angle of view desired by the user. In addition, during a video call, the gaze angle of the face in the captured image usually shows the illusion of not looking at or paying attention to the other party (actually the user is looking at the other party on the screen), which is not conducive to improving users Communication experience.
又或者,台式机通过外接摄像头的方式获取用户人脸图像,或者平板、笔记本通过设置在屏幕上方或下方的摄像头采集用户人脸图像时,由于摄像头的位置与屏幕中心位置存在差异,使得采集的图像的角度存在一定的俯角或者仰角,同样需要通过人脸图像处理方法对人脸进行变换,使得图像能够显示所期望的拍摄视角的样式,在视频通话时提高用户通话使用体验。Or, when a desktop computer acquires a user's face image through an external camera, or a tablet or a laptop acquires a user's face image through a camera set above or below the screen, the difference between the position of the camera and the center of the screen makes the captured image The angle of the image has a certain depression or elevation angle, and it is also necessary to transform the face through the face image processing method, so that the image can display the desired shooting angle of view, and improve the user's call experience during video calls.
在对图像中的人脸进行特效处理的应用场景中,智能终端在采集包括用户人脸图 像的照片或者视频时,为了得到更佳的拍摄效果,可以对拍摄图像中的人脸五官进行调整,或者对身材进行调整等。从而便于用户将调整后的照片或视频进行发布,包括如用户通过小视频应用程序(包括如抖音、快手等应用程序)发布短视频,或者通过微信、微博、博客等平台发布照片或者小视频等。In the application scenario of special effects processing on the face in the image, the smart terminal can adjust the facial features in the captured image in order to obtain a better shooting effect when collecting photos or videos that include the user's face image. Or adjust the figure and so on. This is convenient for users to publish adjusted photos or videos, including, for example, users publishing short videos through small video applications (including applications such as Douyin, Kuaishou, etc.), or publishing photos or small videos through platforms such as WeChat, Weibo, and blogs. Video etc.
为了实现对采集的二维图像进行变换处理,使采集的人脸图像变换为正脸图像,或者使采集的人脸图像变换为经特效处理后的图像,可以包括如下人脸变换方式:In order to transform the collected two-dimensional image, transform the collected face image into a positive face image, or transform the collected face image into an image processed by special effects, the following face transformation methods can be included:
对采集的人脸图像进行二维变换的方式进行处理,可包括:首先获取一张用户的正脸照片,作为后续图片或视频处理的参考数据,并检测该正脸照片的特征点。在获取到待变换的照片时,对待变换的照片中的特征点进行识别。对采集的图像,按照预存的正脸照片为目标进行变形,变形后的人脸图像中的视线方向、五官朝向没有发生变化。Processing the collected face image in a two-dimensional transformation manner may include: first obtaining a face photo of the user as reference data for subsequent image or video processing, and detecting feature points of the face photo. When the photo to be transformed is obtained, the feature points in the photo to be transformed are recognized. The captured image is deformed according to the pre-stored front face photo, and the sight direction and the orientation of the facial features in the deformed face image remain unchanged.
如图4所示,左图为待变换的照片。所述待变换的照片可能是用户在使用电子设备,比如使用带隐藏式摄像头功能的笔记本进行视频通话时,或者使用带隐藏式摄像头功能的笔记本拍摄视频,或者其它的摄像头与电子设备的屏幕位置不匹配的电子设备时,由于用户一般注视在屏幕区域,摄像头设置在人脸前下方,摄像头的采集角度为仰视角度,所采集的图像的下巴和鼻孔较大,用户的使用体验不佳。当然,该图示意为摄像头设置在屏幕下方的效果示意,当摄像头设置在屏幕之外的其它位置,同样所得到的图像也并非用户所期望的正脸图像。图4中的中图为通过预存的正脸照片为目标进行变形后的照片,虽然整个脸形有所改变,但人脸的视线方向、五官朝向没有发生改变,而图4中右图中的目标效果图可以看出,为了能够对人脸图像进行有效的处理,需要对人脸中的眼睛的视线进行变换,需要对人脸中的鼻子的显示视角变换。As shown in Figure 4, the picture on the left is the photo to be transformed. The photo to be converted may be the user using an electronic device, for example, when using a laptop with a hidden camera function to make a video call, or using a laptop with a hidden camera function to take a video, or the screen position of other cameras and electronic devices In the case of mismatched electronic devices, since the user generally looks at the screen area, the camera is set in front of and below the face, and the camera's collection angle is the upward viewing angle. The chin and nostrils of the collected images are large, and the user experience is not good. Of course, this figure shows the effect of the camera set at the bottom of the screen. When the camera is set at a position other than the screen, the image obtained is also not the frontal image expected by the user. The middle image in Figure 4 is a deformed photo using the pre-stored front face photo as the target. Although the entire face shape has changed, the sight direction and facial features of the face have not changed, while the target in the right image in Figure 4 It can be seen from the renderings that, in order to be able to effectively process the face image, it is necessary to change the line of sight of the eyes in the face, and it is necessary to change the display perspective of the nose in the face.
其次,通过目标图像对人脸进行变换时,通常使用特征点在图片上建立网格,对网格中的每个三角面片,根据变换矩阵或函数对图像进行映射,在变换过程中需要遍历每个像素位置,通过插值计算像素颜色,变形处理范围越大,需要耗费的处理时间也越大,通常情况下,仅对五官局部进行变形时所耗费的时间为4-6ms,仅对面部进行变形时所耗费的时间通常为20-40ms,对于所采集的图像进行全图变换所需要的时间为130-170ms。因此,如果为了得到较好的图像效果,则会产生较大的处理时延。Secondly, when transforming the face through the target image, the feature points are usually used to create a grid on the picture, and for each triangle in the grid, the image is mapped according to the transformation matrix or function, and it needs to be traversed during the transformation process. For each pixel position, the pixel color is calculated by interpolation. The larger the deformation processing range, the greater the processing time that needs to be spent. Under normal circumstances, it takes 4-6ms to deform only the facial features and only the face The time spent in deformation is usually 20-40ms, and the time required for full image transformation of the collected image is 130-170ms. Therefore, if in order to obtain a better image effect, a larger processing delay will occur.
而采用三维变形+背景二维融合的方式,根据采集的图像进行三维重建,将重建好的人脸在三维空间进行变形,然后将变形后的人脸重新投影为二维人脸目标图像,并将二维人脸目标图像与背景图像整合时,如果仅仅对人脸进行重建、变形和投影,则一般通过30-40ms即可完成,但是,人脸图像与背景图像之间会存在缝隙,影响图像的真实效果。而对投影后的二维人脸目标图像与背景图像融合时,需要耗费较长时间,将人脸图像与背景图像融合通常需要35-55ms。生成校正后的二维人脸模型与融合的流程则需要65-95ms,不能达到对视频实时处理的要求。The three-dimensional deformation + background two-dimensional fusion method is used to perform three-dimensional reconstruction according to the collected images, deform the reconstructed face in three-dimensional space, and then reproject the deformed face into a two-dimensional face target image, and When integrating a two-dimensional face target image with a background image, if only the face is reconstructed, deformed and projected, it usually takes 30-40ms to complete. However, there will be a gap between the face image and the background image, which will affect The real effect of the image. When fusing the projected two-dimensional face target image with the background image, it takes a long time, and it usually takes 35-55ms to fuse the face image with the background image. The process of generating a corrected two-dimensional face model and fusion requires 65-95ms, which cannot meet the requirements for real-time video processing.
为了解决现有技术中对人脸图像进行处理时,人脸五官视角未进行相应的变换,或者完成人脸图像处理时需要的时间较长的问题,本申请实施例通过构建三维人脸模型基准网格和背景平面基准网格,对三维人脸模型基准网格进行变换时,通过三维人脸模型基准网格的边界点与背景平面基准网格控制点,相应的调整背景平面基准网格,从而提高人脸图像处理效率。In order to solve the problem in the prior art that when the face image is processed, the perspective of the facial features is not changed correspondingly, or the time required to complete the face image processing is long, the embodiment of the present application constructs a three-dimensional face model benchmark Grid and background plane datum grid, when transforming the 3D face model datum grid, adjust the background plane datum grid accordingly through the boundary points of the 3D face model datum grid and the background plane datum grid control point, Thereby improving the efficiency of face image processing.
其中,所述三维人脸模型基准网格,可以为通过多边形(包括三角形、四边形等)所构成的三维人脸模型的网格模型。所述三维人脸基准网格所选用的三维人脸模型,可以为通用的人脸模型,也可以为使用图像处理设备的用户本人的三维人脸模型。Wherein, the reference grid of the three-dimensional face model may be a grid model of the three-dimensional face model formed by polygons (including triangles, quadrilaterals, etc.). The three-dimensional face model selected by the three-dimensional face reference grid may be a general face model, or may be a three-dimensional face model of the user who uses the image processing device.
所述背景平面基准网格,即待处理的图像的大小所对应的平面网格。所述背景平面网格可以由均匀的网格所构成,也可以由非均匀网格构成。The background plane reference grid is a plane grid corresponding to the size of the image to be processed. The background plane grid can be composed of a uniform grid or a non-uniform grid.
根据本申请所述人脸图像处理方法处理待调整的图像时,通常可以如图5所示,主要包括以下三个处理步骤:S1基准网格预处理、S2当前图像建模和S3当前图像处理。下面结合附图,对各个处理过程作进一步描述。When processing the image to be adjusted according to the face image processing method described in this application, it can usually be shown in Figure 5, which mainly includes the following three processing steps: S1 reference grid preprocessing, S2 current image modeling, and S3 current image processing . The respective processing procedures are further described below in conjunction with the drawings.
S1、基准网格预处理:S1. Preprocessing of reference grid:
S11构建基准网格S11 builds a reference grid
所需要构建的基准网格可以包括三维人脸模型基准网格和背景平面基准网格。The reference grid to be constructed may include a three-dimensional face model reference grid and a background plane reference grid.
所述三维人脸模型基准网格可以为通用人脸模型、三维变形模型(3DMM,3D Morphable Models)或其变种模型等。The reference grid of the three-dimensional face model may be a general face model, a three-dimensional deformable model (3DMM, 3D Morphable Models), or a variant model thereof.
其中,所述通用人脸模型为根据通用的人脸所建立的三维人脸模型网格,可以包括如CANDIDE-3模型、CANDIDE模型等。如图6所示,CANDIDE-3模型包括113个顶点,168个面,通过对这些点和面的操作调节,使得通用人脸模型中的特征点与摄像头采集的二维图像(需要三维人脸模型重建的图像)中的人脸特征相匹配。使用通用人脸模型的优点是计算量较小,可以快速的响应三维人脸图像的重建。Wherein, the general face model is a three-dimensional face model grid established based on a general face, and may include, for example, a CANDIDE-3 model, a CANDIDE model, and the like. As shown in Figure 6, the CANDIDE-3 model includes 113 vertices and 168 faces. Through the operation and adjustment of these points and faces, the feature points in the general face model and the two-dimensional image collected by the camera (requires three-dimensional face The facial features in the reconstructed image) are matched. The advantage of using a general face model is that the amount of calculation is small, and it can quickly respond to the reconstruction of the three-dimensional face image.
所述通用人脸模型可以通过三维扫描仪获取所述通用人脸模型的数据,或者也可以通过计算机图形技术创建,或者也可以商业的建模软件生成所述通用人脸模型。The general face model may be obtained by using a three-dimensional scanner to obtain the data of the general face model, or may be created by computer graphics technology, or the general face model may be generated by commercial modeling software.
一种可选的实施方式中,所述通用人脸模型可以获取图像处理设备的用户,建立所述用户对应的通用人脸模型。In an optional implementation manner, the universal face model may acquire a user of the image processing device, and establish a universal face model corresponding to the user.
比如,可以通过扫描该用户的人脸模型,作为所述通用人脸模型。当所述电子设备有多个用户时,则可以存储多个用户对应的通用人脸模型,并根据当前使用电子设备的用户,选择该用户对应的通用人脸模型。For example, the user's face model can be scanned as the general face model. When the electronic device has multiple users, the general face models corresponding to the multiple users can be stored, and the general face models corresponding to the users can be selected according to the user currently using the electronic device.
例如,当手机用户通过指纹或者账号登录电子设备时,可以获知当前使用设备的用户。根据预先存储的用户与通用人脸模型的对应关系,查找当前用户所对应的通用人脸模型。如果在使用过程中,当前用户与通用人脸模型的匹配度低于预定的匹配度时,比如新用户使用图像处理设备中存储的少量用户的通用人脸模型时。可以根据用户的人脸特征,选择对应于用户所在群体的通用人脸模型,比如用户所在群体可以为中年男性、青年女生等群体所确定的人群。For example, when a mobile phone user logs in to an electronic device with a fingerprint or account, he can learn the user who is currently using the device. According to the pre-stored correspondence between the user and the general face model, search for the general face model corresponding to the current user. If during use, the matching degree between the current user and the general face model is lower than the predetermined matching degree, such as when a new user uses the general face model of a small number of users stored in the image processing device. A general face model corresponding to the user's group may be selected according to the user's facial features. For example, the user's group may be a group determined by middle-aged men, young girls, etc.
如果分别为用户建立各自的通用人脸模型,可以在后续的三维人脸模型重建时,提高采集的图像与三维人脸模型基准网格拟合的效率更高,有利于提高设备的响应速度。比如用户在使用摄像头隐藏功能的笔记本电脑进行视频通话,或者拍摄视频时,可以将笔记本所拍摄的大下巴、大鼻孔、仰视视角的实时图像进行拟合处理,可以提高拟合处理后的响应速度,提高视频显示的实时性。If you build their own general face models for users, you can improve the efficiency of fitting the collected images to the reference grid of the three-dimensional face model during subsequent reconstruction of the three-dimensional face model, which is beneficial to improve the response speed of the device. For example, when a user uses a laptop computer with hidden camera function to make a video call, or when shooting a video, the real-time images of the big chin, big nostril, and upward viewing angle taken by the laptop can be fitted for processing, which can improve the response speed after fitting processing , Improve the real-time performance of video display.
当然,如果当前用户不存在预先设定的通用人脸模型,则可以采用预先设定的对应于用户群体的通用人脸模型。在用户使用次数达到预定次时,则可以采集该用户的脸部特征,在系统中增加该用户与通用人脸模型的对应关系。Of course, if the current user does not have a preset universal face model, a preset universal face model corresponding to the user group can be used. When the user has used the user for a predetermined number of times, the facial features of the user can be collected, and the corresponding relationship between the user and the general face model can be added to the system.
在选用三维变形模型3DMM作为三维人脸模型基准网格时,所述三维变形模型3DMM可以建立在三维人脸数据库的基础上,以人脸形状和人脸纹理统计为约束,并可以考虑到人脸的姿态和光照因素的影响,因而所述三维变形模型可调节的精度更高。如图7所示为三维变形模型的示意图,基于三维变形模型的三维人脸模型基准网格与通用人脸模型相比,三角面的个数、顶点的个数大大的增加,三维变形模型包括更多的特征与细节。When the three-dimensional deformed model 3DMM is selected as the reference grid of the three-dimensional face model, the three-dimensional deformed model 3DMM can be established on the basis of the three-dimensional face database, with the face shape and face texture statistics as constraints, and can take into account the human Due to the influence of the posture of the face and illumination factors, the three-dimensional deformation model can be adjusted with higher precision. Figure 7 is a schematic diagram of the 3D deformed model. Compared with the general face model, the reference grid of the 3D face model based on the 3D deformed model has greatly increased the number of triangles and vertices. The 3D deformed model includes More features and details.
假设所述三维变形模型由m个人脸模型组成,其中每一个人脸模型都包含相应的人脸3D坐标形状向量Si,新的3D人脸模型可以表示为:Assuming that the three-dimensional deformed model is composed of m face models, each face model includes a corresponding face 3D coordinate shape vector Si, the new 3D face model can be expressed as:
Figure PCTCN2020105873-appb-000001
Figure PCTCN2020105873-appb-000001
其中,S new为新的脸部形状模型,
Figure PCTCN2020105873-appb-000002
表示脸部平均形状模型,s i表示新的人脸部形状的主要成分,也即新的人脸区别于其它人脸的特征,α i为脸部形状系数。
Among them, S new is a new face shape model,
Figure PCTCN2020105873-appb-000002
Represents the average face shape model, si represents the main component of the new face shape, that is, the feature of the new face that is different from other faces, and α i is the face shape coefficient.
可选的实施方式中,在所述三维变形模型的基础上,还可以进一步包括人脸表情数据,使得三维变形模型进一步扩充为:In an optional implementation manner, on the basis of the three-dimensional deformation model, facial expression data may be further included, so that the three-dimensional deformation model is further expanded to:
Figure PCTCN2020105873-appb-000003
Figure PCTCN2020105873-appb-000003
其中,e i表示脸部表情的主要成分,即区别于其它脸部表情的特征部分,β i为脸部表情系数。其中,所述脸部形状系数α i、脸部表情系数β i可以使用最小二乘法进行求解。 Among them, e i represents the main components of facial expressions, that is, the characteristic parts that are different from other facial expressions, and β i is the facial expression coefficient. Wherein, the facial shape coefficient α i and the facial expression coefficient β i can be solved using the least square method.
当然,也可以根据所采集的电子设备的用户图像数据,建立所述用户对应的3D变形模型,根据当前使用电子设备的用户调用对应的3D变形模型。如果根据当前用户调用的3D变形模型与当前获取的图像的匹配度低于预定值,则可以采用通过用户群体所确定的3D变形模型。Of course, it is also possible to establish a 3D deformed model corresponding to the user based on the collected user image data of the electronic device, and call the corresponding 3D deformed model according to the user currently using the electronic device. If the matching degree between the 3D deformed model called by the current user and the currently acquired image is lower than the predetermined value, the 3D deformed model determined by the user group may be used.
在构建三维人脸模型基准网格的同时,可以根据所采集的图像的大小,构建背景平面基准网格。如图8所示的基准网格示意图中,在三维人脸模型基准网格覆盖在背景平面基准网格之上。所构建的背景平面基准网格可以按照预定大小和形状的网格来构建。预定形状的网格可以包括三角网格、正方形网格等。所述背景平面基准网格中的三角网格可以为全部相同的三角网格,也可以仅仅在人脸周围的预定范围内设定相同形状的三角网格,可以在人脸区域之外,且在头部区域之内的预定范围内设置较为密集的三角网格,以便于在对人脸图像进行变形处理进,对所述预定范围的头部图像进行更为精确的适应性调整。While constructing the reference grid of the three-dimensional face model, the background plane reference grid can be constructed according to the size of the collected image. In the schematic diagram of the reference grid shown in FIG. 8, the reference grid of the three-dimensional face model is overlaid on the background plane reference grid. The constructed background plane reference grid can be constructed according to a grid of a predetermined size and shape. The predetermined shape of the grid may include a triangular grid, a square grid, and the like. The triangular grids in the background plane reference grid can be all the same triangular grids, or can only set the triangular grids of the same shape within a predetermined range around the face, and can be outside the face area, and A denser triangular grid is set in a predetermined range within the head area, so that the face image can be deformed and more accurate and adaptive adjustment can be made to the predetermined range of the head image.
S12标记边界点和控制点S12 marking boundary points and control points
在构建完成了三维人脸模型基准网格和背景平面基准网格后,还需要对所构建的基准网格作进一步的标记处理,包括标记所述三维人脸模型基准网格的边界点、背景平面基准网格的固定点和控制点。所述边界点为预定的视角下,所述三维人脸模型基准网格的脸部的可见边界上的点。如图9所示为基准网格右前方视角所标记的边界点示意图,在右前方视角下,人脸模型的右侧可见部分较多,可见边界上的边界点距人脸正面中心线的距离较远。After constructing the reference grid of the 3D face model and the background plane reference grid, it is necessary to further mark the constructed reference grid, including marking the boundary points and background of the reference grid of the 3D face model. Fixed points and control points of the plane datum grid. The boundary point is a point on the visible boundary of the face of the reference grid of the three-dimensional face model under a predetermined viewing angle. Figure 9 is a schematic diagram of the boundary points marked by the front right perspective of the reference grid. In the front right perspective, there are more visible parts on the right side of the face model, and the distance between the boundary points on the visible boundary and the front center line of the face Far away.
所述边界点可以根据图像处理的精度,选择不同数量的边界点。比如,图像处理要求的精度越高,则可以选择数量更多的边界点。所述边界点可以均匀分布在所述相交线上,也可以根据人脸的轮廓线发生变形处理较为频繁的部位分布较为密集的边界点。如图9所示,可以在人脸的嘴部附近设置较多的边界点。The boundary points may select different numbers of boundary points according to the accuracy of image processing. For example, the higher the accuracy required for image processing, the more boundary points can be selected. The boundary points may be evenly distributed on the intersection line, or the boundary points may be densely distributed in the parts where the contour line of the human face is deformed more frequently. As shown in Figure 9, more boundary points can be set near the mouth of the face.
当可见视角为基准网格的正面时,如图10所示,根据所述三维人脸模型基准网格的脸部可见区域,确定所述脸部的可见边界,根据所述可见边界,即可确定正面视角所对应的边界点。When the visible angle of view is the front of the reference grid, as shown in FIG. 10, the visible boundary of the face is determined according to the visible area of the face of the reference grid of the three-dimensional face model. According to the visible boundary, Determine the boundary point corresponding to the frontal perspective.
在确定所述三维人脸模型基准网格的边界点后,还可以根据所述边界点确定背景平面基准网格的控制点。如图10所示,根据三维人脸模型基准网格的正面视角所确定的边界点,以及根据所述边界点确定的背景平面基准网格的控制点可以完全重合,当然,不应局限于此,所述边界点与所述控制点之间的距离可以设置为小于预定的距离。After determining the boundary points of the reference grid of the three-dimensional face model, the control points of the background plane reference grid may also be determined according to the boundary points. As shown in Figure 10, the boundary points determined according to the frontal perspective of the reference grid of the three-dimensional face model and the control points of the background plane reference grid determined according to the boundary points can completely overlap, but of course, it should not be limited to this , The distance between the boundary point and the control point may be set to be less than a predetermined distance.
S13标记固定点S13 marking fixed point
另外,为了能够使得背景平面基准网格在实施拉伸或者压缩时影响图像的整体大小,本申请还可以对背景平面基准网格设定固定点,通过固定点使得背景平面基准网格的整体大小不会发生改变,另一方面也有利于保证画面整体的稳定性。In addition, in order to make the background plane reference grid affect the overall size of the image when it is stretched or compressed, this application can also set a fixed point for the background plane reference grid, and the fixed point makes the overall size of the background plane reference grid Will not change, on the other hand, it is also helpful to ensure the overall stability of the picture.
在确定了背景平面基准网格的控制点后,还可以进一步设定背景平面基准网格的固定点。如图10所示,所述固定点的位置可以设置在背景平面基准网格的外边界处,通过外边界上的固定点,使得变形处理后的图像大小不会发生改变。当然,也可以通过对图像的背景区域的目标对象进行智能识别,根据所识别的目标对象,在背景平面基准网格所对应的图像中的目标对象所在的位置设定固定点。After the control points of the background plane reference grid are determined, the fixed points of the background plane reference grid can be further set. As shown in FIG. 10, the position of the fixed point may be set at the outer boundary of the background plane reference grid, and the fixed point on the outer boundary is used to prevent the image size after the deformation process from changing. Of course, it is also possible to intelligently recognize the target object in the background area of the image, and according to the recognized target object, set a fixed point at the position of the target object in the image corresponding to the background plane reference grid.
所述边界点位于所述三维人脸模型基准网格,当所述三维人脸模型基准网格发生变形处理时,位于所述三维人脸模型基准网格上的边界点的位置也会发生相应的变化,包括边界点在平面方向上的向左移动、向右移动、向下移动或者向上移动,还可能包括向左上前方、左上后方、左下前方等。根据所述边界点的位置的改变,相应的由控制点确定背景平面基准网格的变形,可以根据拉普拉斯变形方法,对所述背景平面基准网格进行压缩或者拉伸。The boundary point is located on the reference grid of the three-dimensional face model. When the reference grid of the three-dimensional face model undergoes deformation processing, the position of the boundary point on the reference grid of the three-dimensional face model will also be corresponding The changes include the leftward, rightward, downward or upward movement of the boundary point in the plane direction, and may also include the upper left forward, the upper left rear, and the lower left forward. According to the change of the position of the boundary point, the corresponding control point determines the deformation of the background plane reference grid, and the background plane reference grid may be compressed or stretched according to the Laplace deformation method.
假设背景平面基准网格所在的平面为直角坐标系的X轴和Y轴所确定的平面,在边界点的位置发生改变后,可以根据所述边界点的x坐标,y坐标的变化,对齐控制所对应的控制点的x坐标,y坐标的变化。Assuming that the plane where the background plane reference grid is located is the plane determined by the X-axis and Y-axis of the Cartesian coordinate system, after the position of the boundary point changes, the alignment control can be performed according to the changes in the x-coordinate and y-coordinate of the boundary point Changes in the x-coordinate and y-coordinate of the corresponding control point.
比如,可以获取边界点在变形前的坐标位置、变形后的坐标位置,提取变化前后的坐标位置中的x坐标和y坐标的变化,根据所提取的x坐标和y坐标的变化,控制该边界点所对应的控制点的坐标的变化。For example, the coordinate position of the boundary point before the deformation and the coordinate position after the deformation can be obtained, and the change of the x coordinate and the y coordinate in the coordinate position before and after the change can be extracted, and the boundary can be controlled according to the change of the extracted x coordinate and y coordinate The coordinate change of the control point corresponding to the point.
也就是说,如果控制点和边界点重合时,则可以直接根据变化后的边界点的坐标位置中的x坐标和y坐标,确定所述控制点所需要变形的目标位置。That is to say, if the control point and the boundary point overlap, the target position of the control point that needs to be deformed can be determined directly according to the x coordinate and the y coordinate in the coordinate position of the boundary point after the change.
当所述控制点与边界点的之间的对应关系为相隔预定的距离时,则可以根据所述边界点的位置在xoy平面中的位置的变化量,相应的确定该边界点所对应的控制点的位置的变化量。When the corresponding relationship between the control point and the boundary point is a predetermined distance apart, the control point corresponding to the boundary point can be determined according to the amount of change in the position of the boundary point in the xoy plane. The amount of change in the position of the point.
比如边界点的位置在xoy平面中的位置的变化量,可以分解为水平方向变化量和竖直方向,根据该水平方向变化量和竖直方向变化量,来确定所述控制点的移动,使 其与三维人脸模型建模网格上的边界点对应。或者,所述边界点的变化量,又可以分解为移动距离和移动方向,根据所述移动距离和移动方向,确定所述控制点的移动。For example, the change in the position of the boundary point in the xoy plane can be decomposed into the horizontal change and the vertical change, and the movement of the control point is determined according to the horizontal change and the vertical change, so that It corresponds to the boundary points on the 3D face model modeling grid. Or, the change amount of the boundary point can be decomposed into a moving distance and a moving direction, and the movement of the control point is determined according to the moving distance and the moving direction.
作为本申请可选的实施方式中,可以识别所述背景平面基准网格所对应的图像中的物品,对背景平面基准网格所对应的图像中的物品进行全局的拉伸或压缩。即通过所识别的背景平面基准网格所对应的二维图像中的物品,确定物品的等比例调整控制点,当物品中的任意部分需要进行变形处理时,则根据该变形位置的变形处理方式,对该物体的其它控制点实施相同的变形处理,使得变形处理后的物品的形状仍然处于正常的状态,避免因融合引起的背景图像变形的瑕疵问题。As an optional implementation manner of the present application, the items in the image corresponding to the background plane reference grid can be identified, and the items in the image corresponding to the background plane reference grid can be globally stretched or compressed. That is, through the recognized object in the two-dimensional image corresponding to the background plane reference grid, the equal-proportion adjustment control point of the object is determined. When any part of the object needs to be deformed, the deformation processing method according to the deformed position , Perform the same deformation processing on other control points of the object, so that the shape of the deformed object is still in a normal state, avoiding the defect of background image deformation caused by fusion.
比如,当三维人脸模型附近有目标对象A,在识别目标对象A的整体轮廓后,并设定所述目标对象A的边界位置的等比例缩放的控制点。如果位于边界点的控制点进行了拉伸或者压缩处理,使得目标对象A的局部发生改变,比如局部受到拉伸或者挤压,则根据识别的目标对象A对应的等比例缩放的控制点进行变形处理,使得目标对象A实现整体的拉伸或压缩,从而避免因背景平面基准网格发生变形得到背景平面建模网格时,影响背景图像的真实性。For example, when there is a target object A near the three-dimensional face model, after recognizing the overall outline of the target object A, the control points of the boundary position of the target object A are set. If the control point located at the boundary point is stretched or compressed, so that the part of the target object A is changed, such as the part is stretched or squeezed, it will be deformed according to the scaled control point corresponding to the recognized target object A The processing enables the target object A to achieve overall stretching or compression, so as to avoid affecting the authenticity of the background image when the background plane reference grid is deformed to obtain the background plane modeling grid.
值得注意的是,上述基准网格的构建过程可以在人脸处理之前的任意时间执行,可以非实时的构建基准网格。即基准网格的构建可以拍摄图像之前完成即可,并且一经构建,可以重复应用于所拍摄的照片处理,或者重复应用于所拍摄的视频图像的视频帧的图像处理。It is worth noting that the construction process of the aforementioned reference grid can be executed at any time before face processing, and the reference grid can be constructed in non-real-time. That is, the construction of the reference grid can be completed before the image is taken, and once constructed, it can be repeatedly applied to the taken photo processing, or repeatedly applied to the image processing of the video frame of the taken video image.
S2、当前图像建模:S2, current image modeling:
S21人脸模型拟合,以及拍摄参数获取S21 face model fitting and acquisition of shooting parameters
在所述基准网格预处理完成后,则可以根据预先构建的基准网格进行图像的多次建模使用。比如在完成一次基准网格预处理后,在任意时刻需要启用人脸变换处理时,可以随时调用预先构建的基准网格进行图像建模。并且,所述基准网格可以在离线的状态下构建,即所述基准网格可以不需要对图像进行人脸图像处理过程中构建。After the preprocessing of the reference grid is completed, the image can be modeled and used for multiple times according to the pre-built reference grid. For example, after completing a reference grid preprocessing, when the face transformation processing needs to be activated at any time, the pre-built reference grid can be called for image modeling at any time. In addition, the reference grid may be constructed in an offline state, that is, the reference grid may not be constructed in the process of performing face image processing on the image.
当用户使用摄像头进行拍照,或者使用摄像头拍摄视频时,如果接收到用户开启人像处理的指令,则实时的对所拍摄的照片进行人脸图像处理,或者对拍摄的视频进行视频帧的人脸图像处理。结合预先构建的三维人脸模型基准网格和背景平面基准网格,恢复所拍摄的照片或视频帧中的人脸图像所对应的三维人脸图像。When the user uses the camera to take a picture or uses the camera to take a video, if the user receives an instruction to turn on the portrait processing, the captured photo is processed in real time, or the captured video is processed with the face image of the video frame deal with. Combining the pre-built three-dimensional face model reference grid and the background plane reference grid to restore the three-dimensional face image corresponding to the face image in the captured photo or video frame.
具体的,将所采集的二维图像(拍摄的照片或者拍摄的视频中的视频帧)进行建模时,可以采用模型拟合的方法得到二维图像对应的三维网格模型,所述三维人脸网格可以包括三维人脸模型。即可以利用图像中的人脸的特征点,以及预先构建的三维人脸模型基准网格中的特征点进行模型的拟合,得到与采集的二维图像的特征点匹配三维人脸模型建模网格。并且可以根据所述二维图像的特征点的位置,确定所述二维图像的拍摄参数,所述拍摄参数可以包括模型视图矩阵和投影矩阵。Specifically, when modeling the collected two-dimensional image (photographed or video frame in the captured video), a model fitting method can be used to obtain a three-dimensional mesh model corresponding to the two-dimensional image. The face grid may include a three-dimensional face model. That is, the feature points of the face in the image and the feature points in the pre-built reference grid of the three-dimensional face model can be used to fit the model, and the three-dimensional face model modeling can be matched with the feature points of the collected two-dimensional image grid. And the shooting parameters of the two-dimensional image may be determined according to the positions of the feature points of the two-dimensional image, and the shooting parameters may include a model view matrix and a projection matrix.
在将所述图像与预先构建的三维人脸模型基准网格进行拟合时,可以通过改变三维人脸模型基准网格的顶点的位置,以及对所述三维人脸模型基准网格进行变形等处理,使得三维人脸模型建模网格中的特征点位置映射至所采集的图像时,与所采集的图像中的特征点的位置匹配。即由三维人脸模型建模网格所映射的特征点位置,与所 采集的图像中的特征点的位置一致。When fitting the image to the pre-built three-dimensional face model reference grid, the position of the vertex of the three-dimensional face model reference grid can be changed, and the three-dimensional face model reference grid can be deformed, etc. Processing, so that when the feature point positions in the three-dimensional face model modeling grid are mapped to the collected image, they match with the feature point positions in the collected image. That is, the location of the feature points mapped by the 3D face model modeling grid is consistent with the location of the feature points in the collected image.
比如,在拟合过程中,可以先通过调整所述三维人脸型模型基准网格的姿态,包括对三维人脸模型基准网格的偏航角、俯仰角或翻滚角的调整,然后再对姿态调整后的三维人脸模型基准网格的细节图像处的顶点进行拟合变形,使得所采集的图像中的特征点,与调整后的三维人脸模型建模网格所投影映射的图像中的对应的特征点之间的距离之和最小,或者采集的图像中的特征点,调整后的三维人脸模型建模网格所投影映射的图像中对应的特征点完全匹配。For example, in the fitting process, the attitude of the reference grid of the three-dimensional face model can be adjusted first, including the adjustment of the yaw angle, pitch angle or roll angle of the reference grid of the three-dimensional face model, and then the attitude The vertices at the detailed image of the adjusted three-dimensional face model reference grid are fitted and deformed, so that the feature points in the collected image are different from those in the image projected and mapped by the adjusted three-dimensional face model modeling grid. The sum of the distances between the corresponding feature points is the smallest, or the feature points in the collected image, and the corresponding feature points in the image projected and mapped by the adjusted three-dimensional face model modeling grid are completely matched.
在将所述三维人脸模型建模网格与所采集的图像进行拟合后,可以根据两组特征点的对应关系,以及三维人脸模型网格(包括三维人脸模基准网格,以及根据所述三维人脸模型基准网格进行拟合得到的三维人脸模型建模网格)的特征点在拟合前后的变化,确定所述三维人脸模型基准网格变换为所采集的图像时,所对应的姿态的模型视图(MV,model view)矩阵和投影矩阵。其中,根据特征点的对应关系和特征点的变化,来确定由所述三维人脸模型建模网格变换为所采集的图像的MV矩阵和投影矩阵的技术为公知技术,在此不再具体描述。After fitting the three-dimensional face model modeling grid to the collected image, the corresponding relationship between the two sets of feature points and the three-dimensional face model grid (including the three-dimensional face model reference grid, and According to the changes of the feature points of the three-dimensional face model modeling grid obtained by fitting the three-dimensional face model reference grid before and after fitting, it is determined that the three-dimensional face model reference grid is transformed into the collected image When, the corresponding posture model view (MV, model view) matrix and projection matrix. Among them, the technology of determining the MV matrix and the projection matrix of the collected image from the three-dimensional face model modeling grid according to the corresponding relationship of the feature points and the change of the feature points is a well-known technology, and will not be detailed here. description.
比如,通过摄像头采集到仰视视角的二维图像后,可以通过分析所述二维图像中的人脸的特征点的位置,结合预设的三维人脸模型基准网格中的特征点,将所述二维图像中的人脸的特征点与所述三维人脸模型基准网格拟合,即对所述三维人脸模型基准网格中的顶点的位置进行调整,使得调整后的网格匹配所述二维图像中的人脸的特征。For example, after collecting a two-dimensional image from the upward-looking perspective by a camera, the position of the feature points of the face in the two-dimensional image can be analyzed, combined with the feature points in the preset reference grid of the three-dimensional face model, and the The feature points of the face in the two-dimensional image are fitted to the reference grid of the three-dimensional face model, that is, the positions of the vertices in the reference grid of the three-dimensional face model are adjusted so that the adjusted grid matches The features of the human face in the two-dimensional image.
S22三维人脸模型变形处理S22 3D face model deformation processing
其中,所述MV矩阵可以提取其中的旋转分量,根据所提取的旋转分量对所述三维人脸模型建模网格进行相同角度的旋转,从而能够将三维人脸模型建模网格的姿态变换为所采集的图像所对应的姿态。其中,若所述MV矩阵为:Wherein, the MV matrix can extract the rotation component, and rotate the three-dimensional face model modeling grid at the same angle according to the extracted rotation component, so as to transform the pose of the three-dimensional face model modeling grid It is the posture corresponding to the collected image. Wherein, if the MV matrix is:
Figure PCTCN2020105873-appb-000004
Figure PCTCN2020105873-appb-000004
那么,根据所述MV矩阵提取其中的旋转分量R为:Then, the rotation component R extracted from the MV matrix is:
Figure PCTCN2020105873-appb-000005
Figure PCTCN2020105873-appb-000005
其中,I0、I1和I2分别为MV矩阵的第0列、第1列、第2列所构成的向量的模。并且移动参数m30,m31和m32与旋转参数互不相关。Among them, I0, I1, and I2 are the modulus of the vector formed by column 0, column 1, and column 2 of the MV matrix, respectively. And the movement parameters m30, m31 and m32 are not related to the rotation parameters.
根据拟合过程所确定的MV矩阵,可以对所述三维人脸模型基准网格进行姿态调整。根据所述模型视图矩阵中的旋转分量,可对所述三维人脸模型基准网格进行旋转变换,还原所采集的图像所对应的人脸姿态。According to the MV matrix determined in the fitting process, the posture of the reference grid of the three-dimensional face model can be adjusted. According to the rotation component in the model view matrix, the reference grid of the three-dimensional face model can be rotated and transformed to restore the face pose corresponding to the collected image.
可选的实施方式中,当所述三维人脸模型基准网格为通用人脸模型网格,使用所述通用人脸模型网格进行重建时,可以包括对所述人脸模型网格的整体性调整和局部性调整:In an optional implementation manner, when the reference grid of the three-dimensional face model is a general face model grid, when the general face model grid is used for reconstruction, it may include the entirety of the face model grid. Sexual adjustment and local adjustment:
所述整体性调整可以针对模型的轮廓进行调整。可以通过包括如特征点对应的方式,使得通用人脸模型的整体布局,包括如眼睛、耳朵、鼻子、嘴巴、眉毛等部位,与待恢复的图片的五官布局尽量一致。The overall adjustment can be adjusted for the contour of the model. The overall layout of the universal face model, including parts such as eyes, ears, nose, mouth, and eyebrows, can be made consistent with the five senses layout of the picture to be restored by including the corresponding feature points.
所述局部性调整可以针对局部细节,尤其是人脸五官进行微调整,使得局部细节更为准确。The local adjustment may be fine-tuned for local details, especially facial features, so that local details are more accurate.
通过调整后,可以使用基于顶点的插值运算重建人脸。After adjustment, the face can be reconstructed using vertex-based interpolation.
当所述三维人脸模型基准网格为三维变形模型网格时,在对三维变形模型网格进行人脸重建时,可以根据所述MV矩阵中的旋转分量,控制所述三维人脸模型基准网格进行旋转。比如,通过所述MV矩阵中的旋转分量R,将所述三维人脸模型基准网格调整为所采集的图像所对应的姿态,可以进一步根据二维人脸模型中的五官中的特征点的位置,来确定三维人脸模型基准网格的脸部特征的变化,可以包括如对眼睛、眉毛、嘴巴、鼻子、耳朵或脸型等脸部样式进行调整,从而使得调整后的三维人模型网格与采集的图像中的人脸更为匹配。When the three-dimensional face model reference grid is a three-dimensional deformed model grid, when performing face reconstruction on the three-dimensional deformed model grid, the three-dimensional face model reference may be controlled according to the rotation component in the MV matrix The grid is rotated. For example, through the rotation component R in the MV matrix, the reference grid of the three-dimensional face model is adjusted to the pose corresponding to the collected image, which can be further based on the feature points in the five senses in the two-dimensional face model. Position, to determine the changes in facial features of the reference grid of the 3D face model, which can include adjusting facial styles such as eyes, eyebrows, mouth, nose, ears, or face shape, so as to make the adjusted 3D face model grid It more closely matches the face in the captured image.
对于拟合后的三维人脸模型建模网格,与所采集的二维图像中的人脸的姿态不一致。包括如二维图像中人脸为仰视视角,而三维人脸模型建模网格为正面视角,为便于渲染得到三维人脸模型网格纹理图,需要将所述三维人脸模型建模网格进行旋转,使得旋转后的三维人脸模型建模网格与所采集的二维图像中的人脸的视角一致。The modeling mesh of the fitted 3D face model is inconsistent with the pose of the face in the collected 2D image. Including, for example, the human face in the two-dimensional image is from the upward perspective, while the three-dimensional face model modeling grid is the frontal perspective. In order to facilitate rendering to obtain the three-dimensional face model mesh texture map, the three-dimensional face model modeling grid needs to be Rotate so that the rotated 3D face model modeling grid is consistent with the angle of view of the face in the collected 2D image.
S23背景网格变形S23 background grid deformation
在完成所述三维人脸模型建模网格的重建后,由于在对所述三维人脸模型进行变换时,旋转后的三维人脸模型的边界点位置可能会发生改变,根据预先设定的三维人脸模型的边界点的位置是否发生改变,来确定是否需要相应的调整背景平面基准网格中的控制点的位置。当三维人脸模型建模网格的边界点的位置发生改变,则查找与该边界点对应的控制点,并根据所述边界点的x坐标和y坐标的变化,使所述背景平面基准网格中与所述边界点对应的控制点与所述边界点对齐,从而完成对所述背景平面基准网格进行变形处理得到背景平面建模网格。After completing the reconstruction of the three-dimensional face model modeling grid, the position of the boundary points of the rotated three-dimensional face model may change when the three-dimensional face model is transformed, according to the preset Whether the position of the boundary point of the three-dimensional face model is changed to determine whether the position of the control point in the background plane reference grid needs to be adjusted accordingly. When the position of the boundary point of the three-dimensional face model modeling grid changes, the control point corresponding to the boundary point is searched, and the background plane reference network is set according to the change of the x-coordinate and y-coordinate of the boundary point. The control points corresponding to the boundary points in the grid are aligned with the boundary points, thereby completing the deformation processing of the background plane reference grid to obtain a background plane modeling grid.
在确定位置发生变化后的边界点所对应的控制点后,可以根据边界点在变形前后的坐标的变化,比如根据所述边界点的x坐标和y坐标的变化,确定所述控制点的变形幅度,使得控制点在x方向和y方向与所述边界点对齐。根据对齐操作相应的调整控制点,对所述背景平面基准网格进行变形处理,使得变形处理后的控制点的位置与其对应的边界点的位置之间的距离小于预定值,或者使得处理后的控制点的位置与其对应的边界点的位置重合。After determining the control point corresponding to the boundary point after the position change, the deformation of the control point can be determined according to the change of the coordinate of the boundary point before and after the deformation, for example, according to the change of the x coordinate and the y coordinate of the boundary point Amplitude such that the control point is aligned with the boundary point in the x direction and the y direction. According to the corresponding adjustment control points of the alignment operation, the background plane reference grid is deformed, so that the distance between the position of the deformed control point and the position of the corresponding boundary point is less than a predetermined value, or the processed The position of the control point coincides with the position of the corresponding boundary point.
可选的实施方式中,在对背景平面基准网格所对应的图像中的物体有进行识别,并根据所识别的物体设定有等比例调整控制点时,如果物体中的任意一个控制点需要调整,即其中任意一个控制点移动时,该物体的其它控制点也相应的移动,其中任意一个缩放调整时,相应的控制其它等比例控制点进行缩放。In an alternative embodiment, when the object in the image corresponding to the background plane reference grid is recognized, and the proportional adjustment control point is set according to the recognized object, if any control point in the object needs Adjustment, that is, when any one of the control points moves, the other control points of the object also move correspondingly, and when any one of them is scaled and adjusted, the other proportional control points are correspondingly controlled to scale.
通过控制点对背景平面基准网格进行变形处理时,还可以与背景平面基准网格的固定点相结合,从而使得变形处理后的图像大小不发生改变。所述固定点可以设置在背景平面基准网格的四周,也可以设置在某些物体的位置。When performing deformation processing on the background plane reference grid through the control points, it can also be combined with the fixed points of the background plane reference grid, so that the image size after the deformation processing does not change. The fixed point may be set around the background plane reference grid, or may be set at the position of some objects.
所述背景平面网格(包括背景平面基准网格和背景平面建模网格)的变形处理方式,可以包括拉普拉斯变换。不应该局限于此,还可以包括如骨骼蒙皮动画算法等其它网格变形处理方式。The deformation processing method of the background plane grid (including the background plane reference grid and the background plane modeling grid) may include Laplace transform. It should not be limited to this, it can also include other mesh deformation processing methods such as bone skin animation algorithm.
图11为经过变形处理后的建模网格示意图。所述建模网格示意图包括三维人脸模型建模网格和背景平面建模网格。根据图8所示的基准网格,经过模型视图矩阵的变形处理,并根据边界点的位置的改变,由控制点和固定点对背景平面基准网格进行变形处理后得到背景平面建模网格的图像的示意图。由图11可以看出,通过拟合,以及结合模型视图矩阵对所述三维人脸模型基准网格进行变形处理,包括对三维人脸模型基准网格进行旋转变形和/或缩放变形后,得到的三维人脸模型建模网格的可见边界的边界点的位置发生改变,根据边界点的位置的改变,相应的调整背景平面基准网格的控制点的位置,对背景平面基准网格进行变形处理,变形后得到的三维人脸模型建模网格与背景平面建模网格仍然可以有效的融合。Figure 11 is a schematic diagram of the modeling mesh after deformation processing. The modeling grid schematic diagram includes a three-dimensional face model modeling grid and a background plane modeling grid. According to the reference grid shown in Figure 8, after the deformation processing of the model view matrix, and according to the change of the position of the boundary points, the background plane reference grid is deformed by the control points and fixed points to obtain the background plane modeling grid Schematic of the image. It can be seen from Figure 11 that through fitting and combining the model view matrix to deform the reference grid of the three-dimensional face model, including rotating and deforming the reference grid of the three-dimensional face model and/or scaling and deforming, the result is The position of the boundary point of the visible boundary of the three-dimensional face model modeling grid changes. According to the change of the position of the boundary point, the position of the control point of the background plane reference grid is adjusted accordingly, and the background plane reference grid is deformed After processing, the 3D face model modeling grid and the background plane modeling grid obtained after deformation can still be effectively integrated.
S24纹理图像渲染S24 texture image rendering
得到与采集的二维图像的姿态相同的三维人脸模型建模网格后,可以根据MV矩阵及投影矩阵对所采集的图像进行渲染处理,得到三维人脸模型网格纹理图;提取所述MV矩阵中的平移分量和缩放分量,构成新的矩阵,并使用和三维人脸模型相同的投影矩阵,渲染得到背景平面网格纹理图。After obtaining the three-dimensional face model modeling grid with the same pose as the collected two-dimensional image, the collected image can be rendered according to the MV matrix and the projection matrix to obtain the three-dimensional face model grid texture map; extract the The translation component and zoom component in the MV matrix form a new matrix, and use the same projection matrix as the three-dimensional face model to render the background plane grid texture map.
其中,在获取三维人脸模型网格纹理图时,可以设定用于标注所述三维人脸模型建模网格上的顶点位置的直角坐标系OXYZ,所述三维人脸模型建模网格上的任意顶点的坐标位置可以表示为(x,y,z)。在所述直角坐标系中的XOY平面设定UV坐标系,所采集的图像可以通过所述UV坐标系表示为(u,v)。可以将三维人脸模型建模网格上所有网格的顶点坐标(x,y,z)中的z坐标设置为0,将x,y坐标设置成该顶点的二维u,v坐标,渲染得到第一平面,然后确定该平面上的每个第一像素点的颜色:可以根据该像素的位置乘以MV矩阵和投影矩阵,确定该第一像素点在所采集的图片上对应第二像素点,根据所对应的第二像素点对第一平面上的第一像素点的颜色进行取值。Wherein, when acquiring a three-dimensional face model mesh texture map, a rectangular coordinate system OXYZ for marking the vertex positions on the three-dimensional face model modeling grid may be set, and the three-dimensional face model modeling grid The coordinate position of any vertex on can be expressed as (x, y, z). A UV coordinate system is set on the XOY plane in the rectangular coordinate system, and the collected image can be expressed as (u, v) through the UV coordinate system. You can set the z coordinate in the vertex coordinates (x, y, z) of all meshes on the 3D face model modeling grid to 0, set the x, y coordinates to the two-dimensional u, v coordinates of the vertex, and render Obtain the first plane, and then determine the color of each first pixel on the plane: According to the position of the pixel, multiply the MV matrix and the projection matrix to determine that the first pixel corresponds to the second pixel on the collected picture Point, the color of the first pixel on the first plane is taken according to the corresponding second pixel.
同样,在获取背景平面网格纹理图时,由背景平面建模网格确定第二平面,所述第二平面可以通过缩放比例与待处理的二维图像对应。由于背景平面网格是建模成一个平面,不应该有姿态的变化,因此,对平面上的每个第三像素点的颜色,只需要获取MV矩阵中的平移分量和缩放分量,不需要考虑旋转分量,乘以投影矩阵,以及MV矩阵中的平移分量和缩放分量,确定该第三像素点在所获取的待处理的二维图像,比如所采集的图片上对应第四像素点,根据所对应的第四像素点对第二平面上的第三像素点的颜色进行取值。Similarly, when acquiring the background plane grid texture map, the background plane modeling grid determines the second plane, and the second plane may correspond to the two-dimensional image to be processed by a scaling ratio. Since the background plane grid is modeled as a plane, there should be no posture changes. Therefore, for the color of each third pixel on the plane, only the translation component and the zoom component in the MV matrix need to be obtained without consideration. The rotation component is multiplied by the projection matrix, and the translation component and zoom component in the MV matrix to determine that the third pixel is in the acquired two-dimensional image to be processed, such as the fourth pixel corresponding to the acquired picture. The corresponding fourth pixel takes a value on the color of the third pixel on the second plane.
比如,在提取所述MV矩阵中的平移分量和缩放分量时,对于给定的MV矩阵:For example, when extracting the translation component and the scaling component in the MV matrix, for a given MV matrix:
Figure PCTCN2020105873-appb-000006
Figure PCTCN2020105873-appb-000006
可以提取其平移分量T为:The translation component T can be extracted as:
Figure PCTCN2020105873-appb-000007
Figure PCTCN2020105873-appb-000007
其缩放分量S为:The scaling component S is:
Figure PCTCN2020105873-appb-000008
Figure PCTCN2020105873-appb-000008
其中,I0、I1和I2分别为MV矩阵的第0列、第1列、第2列所构成的向量的模。Among them, I0, I1, and I2 are the modulus of the vector formed by column 0, column 1, and column 2 of the MV matrix, respectively.
根据渲染得到的三维人脸模型网格纹理图和背景平面网格纹理图,便于在对三维人脸模型建模网格的视角调整后,对整个网格进行渲染,得到处理后的图像。According to the rendered 3D face model mesh texture map and the background plane mesh texture map, it is convenient to render the entire mesh after adjusting the perspective of the 3D face model modeling mesh to obtain a processed image.
比如,对于图3所示的仰视视角的二维图像,通过生成该二维图像中的人脸所对应的三维人脸模型建模网格后,根据投影矩阵和MV矩阵,确定渲染平面上的像素点的像素值与所述二维图像的对应关系,得到如图12所示的三维人脸模型网格纹理图,以及图13所示的背景平面网格纹理图。For example, for the two-dimensional image of the upward viewing angle shown in Figure 3, after generating the three-dimensional face model modeling grid corresponding to the human face in the two-dimensional image, the projection matrix and the MV matrix are used to determine the rendering plane The corresponding relationship between the pixel value of the pixel and the two-dimensional image results in the three-dimensional face model grid texture map shown in FIG. 12 and the background plane grid texture map shown in FIG. 13.
S3、当前图像处理S3, current image processing
S31人脸模型变形S31 face model deformation
对还原后的三维人脸模型建模网格,需要根据实际使用情况对三维人脸模型建模网格进行变形处理。For the restored 3D face model modeling mesh, the 3D face model modeling mesh needs to be deformed according to actual usage.
比如,当用户使用隐藏式摄像头的笔记本电脑,或者使用外接摄像头的台式电脑进行视频时,为了提升视频通话体验,使得视频画面中的人像的姿态,由注视屏幕的姿态变换为注视摄像头的姿态,需要对还原后的三维人脸模型建模网格进行姿态变换,比如对于隐藏式摄像头的笔记本,调整三维人脸模型的俯视角度等,当摄像头设置在台式电脑的显示器的左侧或右侧时,调整所述三维人脸模型建模网格的偏航角度,即将所述三维人脸模型向左旋转,或者向右旋转一定角度。For example, when the user uses a laptop computer with a hidden camera or a desktop computer with an external camera for video, in order to enhance the video call experience, the posture of the portrait in the video screen is transformed from the posture of looking at the screen to the posture of looking at the camera. It is necessary to transform the posture of the restored 3D face model modeling grid, for example, for a notebook with a hidden camera, adjust the top view angle of the 3D face model, etc., when the camera is set on the left or right side of the desktop computer monitor , Adjusting the yaw angle of the three-dimensional face model modeling grid, that is, rotating the three-dimensional face model to the left or to the right by a certain angle.
其中,所述三维人脸模型建模网格所需要旋转的角度,可以根据所述三维人脸模型基准网格在建模时所获取的MV矩阵中所提取的旋转分量来确定。Wherein, the required rotation angle of the three-dimensional face model modeling grid can be determined according to the rotation component extracted from the MV matrix obtained during the modeling of the three-dimensional face model reference grid.
比如,隐藏式摄像头的笔记本所采集的二维人脸图像的姿态角度为水平向上20度,为了使得视频画面中的人像的姿态,由注视屏幕的姿态变换为注视摄像头的姿态,通过将将三维人脸模型建模网格向下旋转20度,得到如图14a所示的网格正面视图和图14b网格侧面视图中。此时,根据图14b可以看出,所述三维人脸模型建模网格的边界点的位置发生了改变,而与边界点对应的控制点未发生相应的变形处理,背景平面建模网格与变形处理后的所述三维人脸模型建模网格之间出现间隙。For example, the posture angle of a two-dimensional face image collected by a notebook with a hidden camera is 20 degrees upwards horizontally. In order to make the posture of the portrait in the video screen, the posture of looking at the screen is transformed into the posture of looking at the camera. The face model modeling grid is rotated downward by 20 degrees to obtain a front view of the grid as shown in Fig. 14a and a side view of the grid in Fig. 14b. At this time, according to Figure 14b, it can be seen that the position of the boundary points of the three-dimensional face model modeling grid has changed, but the control points corresponding to the boundary points have not undergone corresponding deformation processing, and the background plane modeling grid A gap appears between the deformed three-dimensional face model modeling grid.
对还原二维图像中的人脸所对应的姿态后的三维人脸模型建模网格进行变形处 理时,根据实际应用场景的不同,可以包括多种不同的变形处理方式。比如,可以包括人脸姿态变形处理、人脸局部变形处理等。When performing deformation processing on the 3D face model modeling grid after restoring the pose corresponding to the human face in the 2D image, a variety of different deformation processing methods can be included according to different application scenarios. For example, it may include face posture deformation processing, face partial deformation processing, and so on.
对于人脸姿态变形处理时,可应用于采集图像的摄像头与屏幕中心位置不匹配的设备,包括如带隐藏摄像头功能的笔记本、台式电脑等。For facial posture deformation processing, it can be applied to devices where the image capturing camera does not match the center of the screen, including notebooks and desktop computers with hidden camera functions.
比如,用户在使用隐藏式摄像头的笔记本电脑进行拍照、进行视频通话或者录制视频时,如果用户当前正在注视屏幕画面,则所采集的图像则会如图3所示,摄像头位于人脸所注视的方向的下方,所采集的图像会呈现出大下巴、朝天鼻的非用户所期待的图像。For example, when a user uses a laptop with a hidden camera to take photos, make a video call, or record a video, if the user is currently looking at the screen, the captured image will be as shown in Figure 3. The camera is located where the face is looking at. Below the direction, the collected images will show images with a big chin and nose facing upwards that are not what the user expects.
当用户使用所述隐藏式摄像头的笔记本之前,可以预先离线对基准网格进行构建,包括三维人脸模型基准网格和背景平面基准网格的构建。对构建的基准网格进行标记时,通过识别所述基准网格中的三维人脸模型基准网格中的脸部位置,确定脸部的边界点,根据所述边界点确定用于对背景平面网格(包括背景平面基准网格和背景平面建模网格)进行变换的控制点,并可根据图像变换的幅度,确定背景平面网格中的固定点,比如可以设置固定点为图像的边缘处。Before the user uses the notebook with the hidden camera, the reference grid can be constructed offline in advance, including the construction of the reference grid of the three-dimensional face model and the background plane reference grid. When marking the constructed reference grid, by identifying the position of the face in the reference grid of the three-dimensional face model in the reference grid, the boundary points of the face are determined, and the boundary points are used to determine the background plane The grid (including the background plane reference grid and the background plane modeling grid) is the control point for transformation, and the fixed point in the background plane grid can be determined according to the magnitude of the image transformation. For example, the fixed point can be set as the edge of the image Place.
当摄像头采集到用户的人脸图像时,可以获取所述人脸图像的特征点,基于三维重建算法将所采集的人脸图像与三维人脸模型基准网格进行拟合,在拟合时根据特征点的对应关系,以及三维人脸模型建模网格的特征点在拟合前后的变化,确定模型视图矩阵和投影矩阵,并将拟合后的三维人脸模型基准网格按照模型视图矩阵中的旋转分量进行旋转,得到拍摄的图像所对应的人脸姿态的模型,并根据旋转后得到的三维人脸模型建模网格的边界点的位置的改变,确定需要调整的控制点,根据控制点对背景平面基准网格进行变形处理,使背景平面建模网格与三维人脸模型建模网格融合,并根据包括图像拍摄参数的MV矩阵,以及包括成像参数的投影矩阵,确定采集的图像所对应的三维人脸模型网格纹理图和背景平面网格纹理图。When the camera collects the user's face image, it can obtain the feature points of the face image, and fit the collected face image with the reference grid of the 3D face model based on the 3D reconstruction algorithm. The correspondence between the feature points and the changes of the feature points of the 3D face model modeling grid before and after fitting, determine the model view matrix and the projection matrix, and use the fitted 3D face model reference grid according to the model view matrix Rotate the rotation component in the image to obtain the face pose model corresponding to the captured image, and determine the control points that need to be adjusted according to the changes in the position of the boundary points of the three-dimensional face model modeling grid obtained after the rotation. The control points deform the background plane reference grid to fuse the background plane modeling grid with the 3D face model modeling grid, and determine the acquisition according to the MV matrix including the image shooting parameters and the projection matrix including the imaging parameters 3D face model grid texture map and background plane grid texture map corresponding to the image.
根据用户的使用要求,比如,根据拍摄视角的大小,对人脸姿态进行变换,使得调整后的视角向下调整一定角度,比如向下调整20度,并对调整后的三维模型网格进行渲染,得到如图15所示的调整后的图像效果,得到用户的正脸图像。从而能够得到视频聊天时与用户对视的图像,并且通过控制点和边界点的对应关系来控制背景变形,有利于提高背景图像的整合效率。According to the user's requirements, for example, according to the size of the shooting angle of view, the face pose is transformed so that the adjusted angle of view is adjusted downward to a certain angle, such as 20 degrees downward, and the adjusted 3D model grid is rendered , The adjusted image effect as shown in Figure 15 is obtained, and the user's front face image is obtained. In this way, it is possible to obtain an image that the user is looking at in a video chat, and to control the background deformation through the corresponding relationship between the control point and the boundary point, which is beneficial to improve the integration efficiency of the background image.
当用户使用外接摄像头的台式电脑,或者使用普通笔记本进行拍照、进行视频通话或者录制视频时,如果用户当前正在注视屏幕画面,则所采集的图像则可能采集到用户人侧脸图像,或者采集到用户的俯视图像,不利于提高用户通话体验。When the user uses a desktop computer with an external camera, or uses an ordinary notebook to take pictures, make a video call, or record a video, if the user is currently looking at the screen, the captured image may capture the user’s profile image or capture The user's overhead image is not conducive to improving the user's call experience.
根据所采集的图像对三维人脸模型基准网格进行旋转处理时,根据所识别的人脸姿态,当所述摄像头设置在显示器左边时,将所述三维人脸模型基准网格向反方向旋转,以还原二维人脸图像所对应的三维人脸模型的姿态。当所述摄像头设置在显示器右边时,将所述三维人脸模型基准网格向反方向旋转,以还原二维人脸图像所对应的三维人脸图像的姿态,完成当前所采集的图像的建模。When the reference grid of the 3D face model is rotated according to the collected images, the reference grid of the 3D face model is rotated in the opposite direction when the camera is set on the left side of the display according to the recognized face posture , To restore the pose of the three-dimensional face model corresponding to the two-dimensional face image. When the camera is set on the right side of the display, the reference grid of the three-dimensional face model is rotated in the opposite direction to restore the posture of the three-dimensional face image corresponding to the two-dimensional face image, and complete the construction of the currently collected image. mold.
在对当前建模后的人脸模型进行变形处理时,根据人脸三维模型建模网格的边界点的位置的改变,对所述背景平面基准网格进行变形处理得到背景平面建模网格,使得背景平面建模网格与背景平面建模网格有效的整合。并根据拟合时所获取的MV矩阵 和投影矩阵,得到三维人脸模型网格纹理图和背景平面网格纹理图。根据二维平面图像中的视角,对建模后的人脸模型进行变形处理,包括向左旋转或向右旋转等,并对旋转后的背景平面基准网格进行变形处理,通过所获取的三维人脸模型网格纹理图和背景平面网格纹理图,对变形后的整个网格进行渲染,得处理后的二维图像,且处理后的二维图像中的人脸的注视方向与摄像头位置相匹配,使得用户在视频通话时,能够获得更好的关注体验。并且变换过程需要的时间相对较短,有利于提高视频图像显示的实时性,有利于提高用户使用体验。When performing deformation processing on the currently modeled face model, according to the change of the position of the boundary point of the three-dimensional face model modeling grid, deform the background plane reference grid to obtain the background plane modeling grid , So that the background plane modeling grid and the background plane modeling grid are effectively integrated. And according to the MV matrix and the projection matrix obtained during fitting, the three-dimensional face model grid texture map and the background plane grid texture map are obtained. According to the perspective in the two-dimensional plane image, the modeled face model is deformed, including rotating left or right, etc., and the rotated background plane reference grid is deformed, and the obtained three-dimensional The face model grid texture map and the background plane grid texture map are used to render the entire deformed grid to obtain a processed two-dimensional image, and the gaze direction and camera position of the face in the processed two-dimensional image Matching enables users to get a better attention experience during video calls. In addition, the time required for the conversion process is relatively short, which helps to improve the real-time performance of video image display and to improve the user experience.
在应用于人脸局部变形处理时,用户在使用任意智能设备采集到图像后,包括照片或者视频等图像,用户可能需要将所采集的图像发送给其它用户,或者需要将采集的图像发送至社交服务平台,为了提高用户使用的满意度,需要对采集的图像进行局部调整,比如包括瘦脸、瘦下巴等操作。When applied to the local deformation processing of human face, after the user uses any smart device to collect images, including images such as photos or videos, the user may need to send the collected images to other users, or send the collected images to social media In order to improve the satisfaction of users, the service platform needs to make partial adjustments to the collected images, such as thinning the face and thinning the chin.
在这种应用场景下,得到由摄像头所采集的图像后,可以基于预设的基准网格模型,对将采集的图像中的人脸与三维人脸模型基准网格进行拟合并还原图像中人脸所对应的姿态,根据拟合过程确定MV矩阵和投影矩阵,并根据三维人脸模型建模网格中的边界点、背景平面基准网格中的控制点进行融合变换,根据MV矩阵和投影矩阵得到三维人脸模型网格纹理图和背景平面网格纹理图,根据预先设定的人脸变换要求,比如可以根据预先设定的人脸美化参数,对所述三维人脸模型建模网格进行变形处理。所述人脸美化参数可以包括眼睛大小参数、眼睛间距参数、人脸胖瘦参数、嘴巴大小参数、去眼袋参数、脸型参数和鼻翼大小参数中的一种或者多种。根据所述人脸美化参数对所述三维人脸模型建模网格进一步变形调整。在三维人脸模型建模网格调整后进一步对背景平面建模网格进行变换融合,通过渲染得到变换后的图像,比如,通过变换后得到瘦脸或瘦下巴后的图像。In this application scenario, after the image collected by the camera is obtained, the face in the collected image can be fitted with the reference grid of the three-dimensional face model based on the preset reference grid model and restored to the image The pose corresponding to the face is determined by the MV matrix and projection matrix according to the fitting process, and the fusion transformation is performed according to the boundary points in the 3D face model modeling grid and the control points in the background plane reference grid. According to the MV matrix and The projection matrix obtains the three-dimensional face model grid texture map and the background plane grid texture map. According to the preset face transformation requirements, for example, the three-dimensional face model can be modeled according to preset face beautification parameters The mesh is deformed. The face beautification parameters may include one or more of eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, face shape parameters, and nose wing size parameters. The modeling grid of the three-dimensional face model is further deformed and adjusted according to the face beautification parameters. After the three-dimensional face model modeling grid is adjusted, the background plane modeling grid is further transformed and fused, and a transformed image is obtained through rendering, for example, an image with a thin face or a thin chin is obtained after transformation.
S32背景网格变形S32 background grid deformation
根据所述三维人脸模型建模网格的边界点所对应的控制点,结合背景平面建模网格中的固定点,对所述背景平面建模网格进行变换,比如进行拉普拉斯变形,使得如图16a所示的完成了背景平面建模网格变形后的网格正面视图和图16b所示的完成了变形处理后的网格侧面视图。通过所述MV矩阵中的旋转向量,控制与采集的二维图像中的人脸的视角一致的所述三维人脸模型建模网格,向相反方向旋转,从而使得旋转后的三维人脸模型建模网格转移为正面视角,便于根据所述正面视角的三维人脸模型建模网格生成正面的二维图像。According to the control points corresponding to the boundary points of the three-dimensional face model modeling grid, combined with the fixed points in the background plane modeling grid, transform the background plane modeling grid, such as performing Laplace Deformation, so that the front view of the mesh after the background plane modeling mesh is deformed as shown in FIG. 16a and the side view of the mesh after the deformation is completed as shown in FIG. 16b. Through the rotation vector in the MV matrix, the three-dimensional face model modeling grid that is consistent with the perspective of the face in the acquired two-dimensional image is controlled to rotate in the opposite direction, so that the rotated three-dimensional face model The modeling grid is transferred to a frontal perspective, which is convenient for generating a frontal two-dimensional image based on the three-dimensional face model modeling grid of the frontal perspective.
S33渲染至图像S33 render to image
根据渲染产生的三维人脸模型网格纹理图,以及背景平面网格纹理图,对变换得到的三维人脸模型建模网格和背景平面建模网格进行渲染,得到渲染后的三维人脸图像和背景平面图像,对所述三维人脸图像进行投影,即可得到处理后的二维图像。According to the 3D face model mesh texture map and background plane mesh texture map generated by the rendering, the transformed 3D face model modeling grid and background plane modeling grid are rendered to obtain the rendered 3D face The image and the background plane image are projected on the three-dimensional face image to obtain a processed two-dimensional image.
当用户为智能设备的用户时,为了获取更佳的拍摄图像,需要对摄像头采集的照片或者采集的视频中的视频帧进行人脸变形处理。对所述人脸变形处理方式,包括对人脸进行瘦脸处理或瘦下巴等变形处理。When the user is a user of a smart device, in order to obtain a better captured image, it is necessary to perform face deformation processing on the photo or video frame in the video captured by the camera. The method for deforming the face includes deforming the face such as thinning the face or thinning the chin.
可以根据预先设定三维人脸模型标准网格(用于美化的三维人脸模型网格)的方式,或者预先设定的美化参数,将当前所采集的图像所还原的三维人脸模型建模网格 进行变换,可以在所述三维人脸模型建模网格上设置控制点和固定点的方式,控制所述三维人脸模型建模网格按照标准的三维人脸模型或美化参数进行变形处理,得到变形处理后的三维人脸模型建模网格。The 3D face model restored from the currently collected image can be modeled according to the way of pre-setting the standard grid of the 3D face model (3D face model grid for beautification), or preset beautification parameters The grid is transformed, and control points and fixed points can be set on the 3D face model modeling grid, and the 3D face model modeling grid can be controlled to deform according to the standard 3D face model or beautification parameters After processing, the deformed three-dimensional face model modeling mesh is obtained.
对变换后得到的三维人脸模型建模网格上的边界点的位置进行检测,如果变换后得到的三维人脸模型建模网格上的边界点的位置,相对于变换前的三维人脸模型基准网格的边界点的位置发生了改变,则可以根据变换后的所述边界点确定相应的背景平面建模网格的控制点,对所述背景平面建模网格进行变换,得到变换后得到的背景平面建模网格。或者在对所述背景平面建模网格进行变换时,还可以设定背景平面建模网格的固定点,通过固定点来控制背景平面建模网格的保留属性。比如,所述固定点可以设置在所述背景平面建模网格的四周。The position of the boundary point on the 3D face model modeling grid obtained after transformation is detected. If the position of the boundary point on the 3D face model modeling grid obtained after transformation is relative to the 3D face before transformation If the position of the boundary point of the model reference grid is changed, the control point of the corresponding background plane modeling grid can be determined according to the transformed boundary point, and the background plane modeling grid can be transformed to obtain the transformation The resulting background plane modeling grid. Or when transforming the background plane modeling grid, the fixed points of the background plane modeling grid can also be set, and the retention properties of the background plane modeling grid can be controlled by the fixed points. For example, the fixed point may be set around the background plane modeling grid.
可以根据变换前的三维网格模型的纹理特征,或者还可以结合当前的光线,对变换得到的三维人脸模型建模网格和背景平面建模网格进行渲染,得到渲染后的网格模型,结合当前的姿态角对渲染后的网格模型投影,可得到处理后的图像。The 3D face model modeling mesh and background plane modeling mesh obtained by the transformation can be rendered according to the texture characteristics of the 3D mesh model before the transformation, or combined with the current light, to obtain the rendered mesh model , Combined with the current posture angle to project the rendered grid model, the processed image can be obtained.
由于本申请在构建基准网格的同时,设定位于人脸的边界点和位于背景的控制点,通过背景点与控制点的对应关系,快速的对背景进行变形处理,在采用相同配置的前提下,能够生成无间隙效果的图像的同时,还能够显著的提高图像的处理效率。Since this application sets the boundary points of the face and the control points in the background while constructing the reference grid, the background is quickly deformed through the correspondence between the background points and the control points, and the same configuration is used. Next, while generating images with no gap effect, it can also significantly improve image processing efficiency.
比如,所采用的设备配置信息为:CPU为i7-8550,内存为16GB,摄像头所采集的图像的分辨率为1280*720时,采用本申请实施例所述的人脸图像处理方法,根据预设的基准网格,对三维人脸模型基准网格进行重建,重建后得到人脸三维模型建模网格,并渲染得到三维人脸模型网格纹理图和背景平面网格纹理图,该过程通常需要25-35ms,对重建得到的三维人脸模型建模网格和背景平面建模网格进行变形处理,该过程通常耗时2-3ms即可,对变形处理后的图像进行渲染,得到人脸变形处理后的图像的过程通常为4-6ms,因而,整个过程耗时约为31-45ms,而现有的采用目标图像进行二维变换的方式则需要130-170ms,通过三维变形+背景融合的方式需要65-95ms,本申请实施例所述人脸图像处理方法,在保证人脸图像与背景图像融合较好的同时,有效的减少了图像处理的时间。For example, when the device configuration information used is: CPU is i7-8550, memory is 16GB, and the resolution of the image captured by the camera is 1280*720, the face image processing method described in this Set the reference grid, reconstruct the reference grid of the 3D face model, obtain the 3D face model modeling grid after reconstruction, and get the 3D face model mesh texture map and background plane grid texture map. This process It usually takes 25-35ms to deform the reconstructed 3D face model modeling mesh and background plane modeling mesh. This process usually takes 2-3ms. Render the deformed image to get The process of the face deformed image is usually 4-6ms. Therefore, the entire process takes about 31-45ms, while the existing method of using the target image for two-dimensional transformation requires 130-170ms. Through the three-dimensional deformation+ The background fusion mode requires 65-95 ms. The face image processing method described in the embodiment of the present application ensures a good fusion of the face image and the background image while effectively reducing the image processing time.
应理解,上述实施例中各步骤并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the steps in the foregoing embodiments do not mean the order of execution, and the execution order of the processes should be determined by their functions and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
对应于上文实施例所述的人脸图像处理方法,图17示出了本申请实施例提供的一种人脸图像处理装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the face image processing method described in the above embodiment, FIG. 17 shows a structural block diagram of a face image processing device provided by an embodiment of the present application. For ease of description, only the same as the embodiment of the present application is shown. The relevant part.
图17本申请实施例提供的一种人脸图像处理装置的结构示意图,所述人脸图像处理装置包括:FIG. 17 is a schematic structural diagram of a face image processing device provided by an embodiment of the present application, and the face image processing device includes:
图像建模单元1701,用于由电子设备获取待处理的二维图像,根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型,根据所述待处理的二维图像的拍摄参数获取所述三维网格模型的纹理图,根据所述基准网格的脸部的可见边界确定边界点,以及与所述边界点对应的控制点;The image modeling unit 1701 is configured to obtain a two-dimensional image to be processed by an electronic device, construct a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid, and according to the two-dimensional image to be processed Acquiring the texture map of the three-dimensional grid model by taking the shooting parameters of the three-dimensional image, and determining the boundary point according to the visible boundary of the face of the reference grid, and the control point corresponding to the boundary point;
模型变形单元1702,用于由所述电子设备根据预设的变形要求,结合所述边界点与控制点的对应关系,对所述三维网格模型进行变形处理,将所述纹理图像渲染至变 形处理后的三维网格模型,根据渲染后的三维网格模型生成处理后的图像。The model deformation unit 1702 is configured to perform deformation processing on the three-dimensional mesh model by the electronic device according to preset deformation requirements in combination with the corresponding relationship between the boundary points and the control points, and render the texture image to deform The processed 3D mesh model generates a processed image according to the rendered 3D mesh model.
图17所述人脸图像处理装置,与上述人脸处理方法对应。The face image processing device described in FIG. 17 corresponds to the aforementioned face processing method.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and conciseness of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned functions can be allocated to different functional units and modules as required. Module completion, that is, divide the internal structure of the device into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist alone physically, or two or more units can be integrated into one unit. The above-mentioned integrated units can be hardware-based Formal realization can also be realized in the form of software functional units. In addition, the specific names of the functional units and modules are only used to facilitate distinguishing each other, and are not used to limit the protection scope of the present application. For the specific working process of the units and modules in the foregoing system, reference may be made to the corresponding process in the foregoing method embodiment, which is not repeated here.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the foregoing embodiments, the description of each embodiment has its own focus. For parts that are not detailed or recorded in a certain embodiment, reference may be made to related descriptions of other embodiments.
本申请实施例提供的人脸图像处理方法可以应用于笔记本、台式电脑、平板电脑、手机、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等具有摄像头的电子设备,本申请实施例对电子设备的具体类型不作任何限制。The face image processing method provided in the embodiments of this application can be applied to notebooks, desktop computers, tablet computers, mobile phones, wearable devices, vehicle-mounted devices, augmented reality (AR)/virtual reality (VR) devices, Ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (personal digital assistants, PDAs) and other electronic devices with cameras, the embodiments of this application do not impose any restrictions on the specific types of electronic devices.
图18示出的是与本申请实施例提供的电子设备1800的部分结构的框图。参考图18,电子设备1800包括:存储器1810、摄像头1820、显示单元1830、电源140以及处理器1850等部件。本领域技术人员可以理解,图18中示出的电子设备1800结构并不构成对电子设备1800的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。FIG. 18 shows a block diagram of a part of the structure of an electronic device 1800 provided in an embodiment of the present application. Referring to FIG. 18, the electronic device 1800 includes: a memory 1810, a camera 1820, a display unit 1830, a power supply 140, a processor 1850 and other components. Those skilled in the art can understand that the structure of the electronic device 1800 shown in FIG. 18 does not constitute a limitation on the electronic device 1800, and may include more or fewer components than shown, or a combination of certain components, or different components Layout.
下面结合图18对电子设备100的各个构成部件进行具体的介绍:The components of the electronic device 100 are specifically introduced below in conjunction with FIG. 18:
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2. , Mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 may include pressure sensor 180A, gyroscope sensor 180B, air pressure sensor 180C, magnetic sensor 180D, acceleration sensor 180E, distance sensor 180F, proximity light sensor 180G, fingerprint sensor 180H, temperature sensor 180J, touch sensor 180K, ambient light Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing  unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc. Among them, the different processing units may be independent devices or integrated in one or more processors.
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 to store instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can store instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, and a universal asynchronous transmitter (universal asynchronous transmitter) interface. receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / Or Universal Serial Bus (USB) interface, etc.
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a two-way synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple sets of I2C buses. The processor 110 may be coupled to the touch sensor 180K, charger, flash, camera 193, etc. through different I2C bus interfaces. For example, the processor 110 may couple the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through an I2C bus interface to implement the touch function of the electronic device 100.
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal is processed by the baseband processor and then passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极 管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can adopt liquid crystal display (LCD), organic light-emitting diode (OLED), active-matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode). AMOLED, flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, and N is a positive integer greater than one.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back from the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transfers the electrical signal to the ISP for processing and is converted into an image visible to the naked eye. ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193.
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it to the photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. ISP outputs digital image signals to DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats. In some embodiments, the electronic device 100 may include 1 or N cameras 193, and N is a positive integer greater than 1.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects the frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in a variety of encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, and so on.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, for example, the transfer mode between human brain neurons, it can quickly process input information and can continuously learn by itself. The NPU can realize applications such as intelligent cognition of the electronic device 100, such as image recognition, face recognition, voice recognition, text understanding, and so on.
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiment of the present invention takes an Android system with a layered architecture as an example to exemplify the software structure of the electronic device 100.
图2是本发明实施例的电子设备100的软件结构框图。FIG. 2 is a software structure block diagram of an electronic device 100 according to an embodiment of the present invention.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管 理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in a virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。The system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
2D图形引擎是2D绘图的绘图引擎。The 2D graphics engine is a drawing engine for 2D drawing.
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
所述应用程序层用于运行所安装的应用程序或系统中的应用程序,包括如相机、日历、地图、WLAN、音乐、短信息、图库、通话、导航、蓝牙和视频等。The application layer is used to run installed applications or applications in the system, including, for example, camera, calendar, map, WLAN, music, short message, gallery, call, navigation, Bluetooth, and video.
下面结合捕获拍照场景,示例性说明电子设备100软件以及硬件的工作流程。In the following, the workflow of the software and hardware of the electronic device 100 will be exemplified in conjunction with capturing a photo scene.
当触摸传感器180K接收到触摸操作,相应的硬件中断被发给内核层。内核层将触摸操作加工成原始输入事件(包括触摸坐标,触摸操作的时间戳等信息)。原始输入事件被存储在内核层。应用程序框架层从内核层获取原始输入事件,识别该输入事件所对应的控件。以该触摸操作是触摸单击操作,该单击操作所对应的控件为相机应用图标的控件为例,相机应用调用应用框架层的接口,启动相机应用,进而通过调用内核层启动摄像头驱动,通过摄像头193捕获静态图像或视频。When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes touch operations into original input events (including touch coordinates, time stamps of touch operations, etc.). The original input events are stored in the kernel layer. The application framework layer obtains the original input event from the kernel layer, and identifies the control corresponding to the input event. Taking the touch operation as a touch click operation, and the control corresponding to the click operation is the control of the camera application icon as an example, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer. The camera 193 captures still images or videos.
最后应说明的是:以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。Finally, it should be noted that the above are only specific implementations of this application, but the scope of protection of this application is not limited to this. Any changes or substitutions within the technical scope disclosed in this application should be covered by this application. Within the scope of protection applied for. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims (19)

  1. 一种人脸图像处理方法,其特征在于,所述人脸图像处理方法包括:A face image processing method, characterized in that the face image processing method includes:
    电子设备获取待处理的二维图像,根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型,根据所述待处理的二维图像的拍摄参数获取所述三维网格模型的纹理图,根据所述基准网格的脸部的可见边界确定边界点,以及与所述边界点对应的控制点;The electronic device obtains the two-dimensional image to be processed, constructs a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid, and obtains the three-dimensional image according to the shooting parameters of the two-dimensional image to be processed. The texture map of the grid model, determining the boundary points according to the visible boundary of the face of the reference grid, and the control points corresponding to the boundary points;
    所述电子设备根据预设的变形要求,结合所述边界点与控制点的对应关系,对所述三维网格模型进行变形处理,将所述纹理图像渲染至变形处理后的三维网格模型,根据渲染后的三维网格模型生成处理后的图像。The electronic device performs deformation processing on the three-dimensional mesh model according to preset deformation requirements and in combination with the corresponding relationship between the boundary points and the control points, and renders the texture image to the deformed three-dimensional mesh model, Generate a processed image according to the rendered 3D mesh model.
  2. 根据权利要求1所述的人脸图像处理方法,其特征在于,所述基准网格包括三维人脸模型基准网格和背景平面基准网格,所述三维网格模型包括三维人脸模型建模网格和背景平面建模网格,电子设备根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型的步骤包括:The face image processing method according to claim 1, wherein the reference grid includes a three-dimensional face model reference grid and a background plane reference grid, and the three-dimensional grid model includes a three-dimensional face model modeling Grid and background plane modeling grid. The step of constructing a three-dimensional grid model corresponding to the two-dimensional image to be processed by the electronic device according to a preset reference grid includes:
    电子设备将三维人脸模型基准网格与所述待处理的二维图像拟合,并根据拟合后的三维人脸模型基准网格,获取所述待处理的二维图像的拍摄参数;The electronic device fits the reference grid of the three-dimensional face model with the two-dimensional image to be processed, and obtains the shooting parameters of the two-dimensional image to be processed according to the fitted reference grid of the three-dimensional face model;
    根据所述拍摄参数,电子设备对所述三维人脸模型基准网格进行姿态调整,得到三维人脸模型建模网格,所述三维人脸模型建模网格与所述二维图像中的人脸姿态一致。According to the shooting parameters, the electronic device adjusts the posture of the reference grid of the three-dimensional face model to obtain a three-dimensional face model modeling grid. The three-dimensional face model modeling grid and the two-dimensional image The faces are consistent.
  3. 根据权利要求2所述的人脸图像处理方法,其特征在于,所述拍摄参数包括模型视图矩阵和投影矩阵,所述根据所述拍摄参数,所述电子设备对所述三维人脸模型基准网格进行姿态调整的步骤包括:The face image processing method according to claim 2, wherein the shooting parameters include a model view matrix and a projection matrix, and according to the shooting parameters, the electronic device compares the three-dimensional face model reference net The steps to adjust the posture of the grid include:
    根据所述模型视图矩阵,电子设备提取旋转分量;According to the model view matrix, the electronic device extracts the rotation component;
    根据所提取的旋转分量,电子设备控制拟合后的三维人脸模型基准网格旋转至所述待处理的二维图像所对应的人脸姿态。According to the extracted rotation component, the electronic device controls the fitted three-dimensional face model reference grid to rotate to the face pose corresponding to the two-dimensional image to be processed.
  4. 根据权利要求2所述的人脸图像处理方法,其特征在于,所述电子设备根据预先设定的基准网格构建所述待处理的二维图像对应的三维网格模型的步骤还包括:The face image processing method according to claim 2, wherein the step of the electronic device constructing a three-dimensional grid model corresponding to the two-dimensional image to be processed according to a preset reference grid further comprises:
    确定姿态调整后的三维人脸模型建模网格中发生位置改变的边界点;Determine the boundary point where the position changes in the 3D face model modeling grid after the pose adjustment;
    根据发生位置改变的边界点查找对应的控制点,根据所查找的控制点对所述背景平面基准网格进行变形控制。The corresponding control point is searched for according to the boundary point where the position has changed, and the background plane reference grid is deformed and controlled according to the searched control point.
  5. 根据权利要求2所述的人脸图像处理方法,其特征在于,所述纹理图包括三维人脸模型网格纹理图和背景平面网格纹理图,所述电子设备根据所述待处理的二维图像的拍摄参数获取所述三维网格模型的纹理图的步骤包括:The face image processing method according to claim 2, wherein the texture map comprises a three-dimensional face model grid texture map and a background plane grid texture map, and the electronic device is based on the two-dimensional face model to be processed. The step of obtaining the texture map of the three-dimensional mesh model by the shooting parameters of the image includes:
    根据所述模型视图矩阵和投影矩阵,所述电子设备获取所述三维人脸模型网格纹理图;According to the model view matrix and the projection matrix, the electronic device obtains the three-dimensional face model grid texture map;
    根据投影矩阵,以及所述模型视图矩阵中的平移向量和缩放向量,所述电子设备获取所述背景平面网格纹理图。According to the projection matrix, and the translation vector and the zoom vector in the model view matrix, the electronic device obtains the background plane grid texture map.
  6. 根据权利要求5所述的人脸图像处理方法,其特征在于,所述根据所述模型视图矩阵和投影矩阵,所述电子设备获取所述三维人脸模型网格纹理图的步骤包括:The face image processing method according to claim 5, wherein the step of obtaining the three-dimensional face model grid texture map by the electronic device according to the model view matrix and the projection matrix comprises:
    所述电子设备获取所述三维人脸模型建模网格中的顶点在空间直角坐标系中的 坐标,在所述顶点坐标中的z坐标为0时渲染得到第一平面;The electronic device obtains the coordinates of the vertices in the three-dimensional face model modeling grid in the spatial rectangular coordinate system, and renders the first plane when the z coordinate in the vertices coordinates is 0;
    所述电子设备根据第一平面的第一像素点的位置与模型视图矩阵、投影矩阵的乘积,确定第一像素点在待处理的二维图像上所对应的第二像素点,根据第二像素点的颜色确定第一像素点的颜色。The electronic device determines the second pixel corresponding to the first pixel on the two-dimensional image to be processed according to the product of the position of the first pixel on the first plane, the model view matrix and the projection matrix, and according to the second pixel The color of the dot determines the color of the first pixel.
  7. 根据权利要求5所述的人脸图像处理方法,其特征在于,所述根据投影矩阵,以及所述模型视图矩阵中的平移向量和缩放向量,所述电子设备获取所述背景平面网格纹理图的步骤包括:The face image processing method according to claim 5, wherein the electronic device obtains the background plane grid texture map according to the projection matrix, and the translation vector and the zoom vector in the model view matrix The steps include:
    所述电子设备根据背景平面建模网格确定第二平面,并提取模型视图矩阵中的平移矩阵和缩放矩阵;The electronic device determines the second plane according to the background plane modeling grid, and extracts the translation matrix and the zoom matrix in the model view matrix;
    所述电子设备根据第二平面的每一个第三像素点的位置与平移矩阵、缩放矩阵和投影矩阵的乘积,确定第三像素点在待处理的二维图像上所对应的第四像素点,根据第四像素点的颜色确定第三像素点的颜色。The electronic device determines the fourth pixel corresponding to the third pixel on the two-dimensional image to be processed according to the position of each third pixel in the second plane and the product of the translation matrix, the zoom matrix and the projection matrix, The color of the third pixel is determined according to the color of the fourth pixel.
  8. 根据权利要求1-7任一项所述的人脸图像处理方法,其特征在于,所述电子设备对所述三维网格模型进行变形处理的步骤包括:7. The face image processing method according to any one of claims 1-7, wherein the step of deforming the three-dimensional mesh model by the electronic device comprises:
    所述电子设备获取所构建的三维网格模型中的三维人脸模型建模网格的姿态;Acquiring, by the electronic device, the posture of the three-dimensional face model modeling grid in the constructed three-dimensional grid model;
    所述电子设备根据所构建的三维人脸模型建模网格的姿态与目标姿态的角度关系,旋转所述三维人脸模型建模网格。The electronic device rotates the three-dimensional face model modeling grid according to the angle relationship between the posture of the constructed three-dimensional face model modeling grid and the target posture.
  9. 根据权利要求1-7任一项所述的人脸图像处理方法,其特征在于,所述电子设备根据预设的变形要求,对所述三维人脸模型建模网格进行变形处理的步骤包括:7. The face image processing method according to any one of claims 1-7, wherein the step of deforming the three-dimensional face model modeling grid by the electronic device according to preset deformation requirements comprises :
    所述电子设备获取预设的人脸美化参数;The electronic device acquires preset face beautification parameters;
    根据所述人脸美化参数,所述电子设备对所述三维网格模型中的三维人脸模型建模网格进行调整。According to the face beautification parameter, the electronic device adjusts the three-dimensional face model modeling mesh in the three-dimensional mesh model.
  10. 根据权利要求9所述的人脸图像处理方法,其特征在于,所述人脸美化参数包括眼睛大小参数、眼睛间距参数、人脸胖瘦参数、嘴巴大小参数、去眼袋参数、脸型参数和鼻翼大小参数中的一种或者多种。The face image processing method according to claim 9, wherein the face beautification parameters include eye size parameters, eye spacing parameters, face fatness and thinness parameters, mouth size parameters, eye bag removal parameters, face shape parameters, and nose wings One or more of the size parameters.
  11. 根据权利要求1-7任一项所述的人脸图像处理方法,其特征在于,所述电子设备结合所述边界点与控制点的对应关系,对所述三维网格模型进行变形处理的步骤包括:The face image processing method according to any one of claims 1-7, wherein the electronic device combines the corresponding relationship between the boundary points and the control points to deform the three-dimensional mesh model include:
    所述电子设备获取边界点位于所述基准网格中的三维人脸模型基准网格上的第一位置,以及边界点位于所述三维网格模型中的三维人脸模型建模网格上的第二位置;The electronic device acquires the first position where the boundary point is located on the reference grid of the three-dimensional face model in the reference grid, and the boundary point is located on the three-dimensional face model modeling grid in the three-dimensional grid model. Second position
    在第二位置与第一位置的距离大于预定值时,所述电子设备查找所述边界点对应的控制点;When the distance between the second position and the first position is greater than a predetermined value, the electronic device searches for the control point corresponding to the boundary point;
    所述电子设备根据所查找的控制点对所述背景平面建模网格进行变形处理。The electronic device performs deformation processing on the background plane modeling grid according to the searched control points.
  12. 根据权利要求11所述的人脸图像处理方法,其特征在于,所述电子设备根据所查找的控制点对所述背景平面建模网格进行变形处理的步骤包括:The face image processing method according to claim 11, wherein the step of deforming the background plane modeling grid by the electronic device according to the searched control point comprises:
    所述电子设备获取所述边界点的坐标位置在背景平面的坐标变化量;Acquiring, by the electronic device, the coordinate variation of the coordinate position of the boundary point on the background plane;
    根据所述边界点的坐标位置在背景平面的坐标变化量,所述电子设备确定所述控制点的目标位置;The electronic device determines the target position of the control point according to the coordinate change amount of the coordinate position of the boundary point on the background plane;
    根据所述目标位置,所述电子设备对背景平面建模网格进行拉普拉斯变形处理。According to the target position, the electronic device performs Laplace deformation processing on the background plane modeling grid.
  13. 根据权利要求12所述的人脸图像处理方法,其特征在于,根据所述目标位置,所述电子设备对背景平面建模网格进行拉普拉斯变形处理的步骤包括:The face image processing method according to claim 12, wherein the step of performing Laplace deformation processing on the background plane modeling grid by the electronic device according to the target position comprises:
    所述电子设备获取所述背景平面建模网格上设置的控制点;Acquiring, by the electronic device, control points set on the background plane modeling grid;
    根据所设置的控制点,以及控制点的目标位置,所述电子设备对背景平面建模网格进行拉普拉斯变形处理。According to the set control points and the target positions of the control points, the electronic device performs Laplace deformation processing on the background plane modeling grid.
  14. 根据权利要求1所述的所述的人脸图像处理方法,其特征在于,所述基准网格中的三维人脸模型基准网格为通用人脸模型或三维变形模型。The face image processing method according to claim 1, wherein the three-dimensional face model reference grid in the reference grid is a general face model or a three-dimensional deformed model.
  15. 根据权利要求1所述的所述的人脸图像处理方法,其特征在于,在所述电子设备获取待处理的二维图像的步骤之前,所述方法还包括:The face image processing method according to claim 1, wherein before the step of obtaining the two-dimensional image to be processed by the electronic device, the method further comprises:
    所述电子设备构建三维人脸模型基准网格和背景平面基准网格;The electronic device constructs a three-dimensional face model reference grid and a background plane reference grid;
    所述电子设备获取三维人脸模型基准网格中的脸部区域;Acquiring, by the electronic device, a face area in a reference grid of a three-dimensional face model;
    根据所述脸部区域的可见边界,所述电子设备确定边界点和控制点的位置。According to the visible boundary of the face area, the electronic device determines the position of the boundary point and the control point.
  16. 根据权利要求1所述的人脸图像处理方法,其特征在于,所述电子设备获取待处理的二维图像的步骤包括:The face image processing method according to claim 1, wherein the step of obtaining the two-dimensional image to be processed by the electronic device comprises:
    所述电子设备根据摄像头所采集的视频中实时提取视频帧,将所提取的视频帧作为待处理的二维图像;The electronic device extracts video frames in real time from the video collected by the camera, and uses the extracted video frames as a two-dimensional image to be processed;
    或者,所述电子设备将摄像头所拍摄的照片作为待处理的二维图像。Or, the electronic device uses the photo taken by the camera as the two-dimensional image to be processed.
  17. 一种电子设备,其特征在于,所述电子设备包括存储器、处理屏和计算机程序,所述显示屏用于处理后的图像,所述计算机程序存储在所述存储器中,所述计算机程序包括指令,当所述指令被所述电子设备执行时,使得所述电子设备执行权利要求1至16任一项所述人脸图像处理方法。An electronic device, wherein the electronic device includes a memory, a processing screen, and a computer program, the display screen is used for processed images, the computer program is stored in the memory, and the computer program includes instructions When the instruction is executed by the electronic device, the electronic device is caused to execute the face image processing method according to any one of claims 1 to 16.
  18. 一种计算机存储介质,所述计算机存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至16任一项所述人脸图像处理方法。A computer storage medium storing a computer program, wherein the computer program is executed by a processor to implement the face image processing method according to any one of claims 1 to 16.
  19. 一种包含指令的计算机程序产品,其特征在于,所述计算机程序产品在电子设备上运行时,使得电子设备执行如权利要求1-16任一项所述的人脸图像处理方法。A computer program product containing instructions, wherein when the computer program product runs on an electronic device, the electronic device executes the face image processing method according to any one of claims 1-16.
PCT/CN2020/105873 2019-08-09 2020-07-30 Human face image processing method and electronic device WO2021027585A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910735963.9A CN112348937A (en) 2019-08-09 2019-08-09 Face image processing method and electronic equipment
CN201910735963.9 2019-08-09

Publications (1)

Publication Number Publication Date
WO2021027585A1 true WO2021027585A1 (en) 2021-02-18

Family

ID=74366971

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/105873 WO2021027585A1 (en) 2019-08-09 2020-07-30 Human face image processing method and electronic device

Country Status (2)

Country Link
CN (1) CN112348937A (en)
WO (1) WO2021027585A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114866706A (en) * 2022-06-01 2022-08-05 北京字跳网络技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
WO2023086694A1 (en) * 2021-11-11 2023-05-19 Qualcomm Incorporated Image modification techniques
CN117808943A (en) * 2024-02-29 2024-04-02 天度(厦门)科技股份有限公司 Three-dimensional cartoon face reconstruction method, device, equipment and storage medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113223188B (en) * 2021-05-18 2022-05-27 浙江大学 Video face fat and thin editing method
CN113628322B (en) * 2021-07-26 2023-12-05 阿里巴巴(中国)有限公司 Image processing, AR display and live broadcast method, device and storage medium
CN115223022B (en) * 2022-09-15 2022-12-09 平安银行股份有限公司 Image processing method, device, storage medium and equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101739719A (en) * 2009-12-24 2010-06-16 四川大学 Three-dimensional gridding method of two-dimensional front view human face image
CN103208133A (en) * 2013-04-02 2013-07-17 浙江大学 Method for adjusting face plumpness in image
CN104978764A (en) * 2014-04-10 2015-10-14 华为技术有限公司 Three-dimensional face mesh model processing method and three-dimensional face mesh model processing equipment
CN108305312A (en) * 2017-01-23 2018-07-20 腾讯科技(深圳)有限公司 The generation method and device of 3D virtual images
WO2019045714A1 (en) * 2017-08-31 2019-03-07 Sony Mobile Communications Inc. Methods, devices and computer program products for generation of mesh in constructed 3d images
CN109697688A (en) * 2017-10-20 2019-04-30 虹软科技股份有限公司 A kind of method and apparatus for image procossing

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100372811B1 (en) * 2000-12-19 2003-02-26 (주) 웹씨인터미디어 Method for Making 3D Face Model by Using a 2D Human Face Image
US9020241B2 (en) * 2011-03-03 2015-04-28 Panasonic Intellectual Property Management Co., Ltd. Image providing device, image providing method, and image providing program for providing past-experience images
CN107392984B (en) * 2017-07-26 2020-09-15 厦门美图之家科技有限公司 Method for generating animation based on face image and computing equipment
CN109377557B (en) * 2018-11-26 2022-12-27 中山大学 Real-time three-dimensional face reconstruction method based on single-frame face image

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101739719A (en) * 2009-12-24 2010-06-16 四川大学 Three-dimensional gridding method of two-dimensional front view human face image
CN103208133A (en) * 2013-04-02 2013-07-17 浙江大学 Method for adjusting face plumpness in image
CN104978764A (en) * 2014-04-10 2015-10-14 华为技术有限公司 Three-dimensional face mesh model processing method and three-dimensional face mesh model processing equipment
CN108305312A (en) * 2017-01-23 2018-07-20 腾讯科技(深圳)有限公司 The generation method and device of 3D virtual images
WO2019045714A1 (en) * 2017-08-31 2019-03-07 Sony Mobile Communications Inc. Methods, devices and computer program products for generation of mesh in constructed 3d images
CN109697688A (en) * 2017-10-20 2019-04-30 虹软科技股份有限公司 A kind of method and apparatus for image procossing

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023086694A1 (en) * 2021-11-11 2023-05-19 Qualcomm Incorporated Image modification techniques
US11810256B2 (en) 2021-11-11 2023-11-07 Qualcomm Incorporated Image modification techniques
CN114866706A (en) * 2022-06-01 2022-08-05 北京字跳网络技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN117808943A (en) * 2024-02-29 2024-04-02 天度(厦门)科技股份有限公司 Three-dimensional cartoon face reconstruction method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN112348937A (en) 2021-02-09

Similar Documents

Publication Publication Date Title
WO2021027585A1 (en) Human face image processing method and electronic device
US11989350B2 (en) Hand key point recognition model training method, hand key point recognition method and device
CN111738220B (en) Three-dimensional human body posture estimation method, device, equipment and medium
WO2021249053A1 (en) Image processing method and related apparatus
EP3992919B1 (en) Three-dimensional facial model generation method and apparatus, device, and medium
WO2020034785A1 (en) Method and device for processing three-dimensional model
US9135678B2 (en) Methods and apparatus for interfacing panoramic image stitching with post-processors
JP7483301B2 (en) Image processing and image synthesis method, device, and computer program
CN111652796A (en) Image processing method, electronic device, and computer-readable storage medium
WO2022007627A1 (en) Method and apparatus for implementing image special effect, and electronic device and storage medium
CN109961496B (en) Expression driving method and expression driving device
TW202112138A (en) Method and system for processing input video
WO2024021742A1 (en) Fixation point estimation method and related device
WO2024031879A1 (en) Method for displaying dynamic wallpaper, and electronic device
CN115661912B (en) Image processing method, model training method, electronic device, and readable storage medium
WO2022021782A1 (en) Method and system for automatically generating six-dimensional posture data set, and terminal and storage medium
WO2020154000A1 (en) Pose correction
CN111242273A (en) Neural network model training method and electronic equipment
CN111612723B (en) Image restoration method and device
CN113536866A (en) Character tracking display method and electronic equipment
WO2020155984A1 (en) Facial expression image processing method and apparatus, and electronic device
US20210279928A1 (en) Method and apparatus for image processing
CN117132515A (en) Image processing method and electronic equipment
CN116452745A (en) Hand modeling, hand model processing method, device and medium
WO2022261856A1 (en) Image processing method and apparatus, and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20852068

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20852068

Country of ref document: EP

Kind code of ref document: A1