Image processing method, device, electronic device and storage medium

Through three-dimensional reconstruction and pixel-by-pixel adjustment technology, the problem of large face image adjustment errors is solved, more accurate face direction and perspective adjustment is achieved, and the accuracy and authenticity of image processing are improved.

CN113240814BActive Publication Date: 2024-10-01BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110518186.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-12
Publication Date
2024-10-01
Estimated Expiration
2041-05-12

AI Technical Summary

Technical Problem

There are large errors in face image adjustment in the existing technology, mainly due to the difference in orthogonal projection and real-world imaging rules that lead to inaccurate acquisition of the three-dimensional direction of the face.

Method used

By acquiring the original image and the target image, three-dimensional reconstruction is performed respectively to obtain the original three-dimensional face mesh and the target three-dimensional face mesh, and are adjusted pixel by pixel according to parameters such as focal length and direction to ensure the accuracy of face direction and perspective.

Benefits of technology

The accuracy of face image adjustment is improved, making the facial features layout of the adjusted target face image more reasonable and realistic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113240814B_ABST
    Figure CN113240814B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an image processing method, device, electronic device and storage medium, and relates to the field of image processing technology. The method includes: after obtaining an original image and a target image, three-dimensionally reconstructing the first face image contained in the original image and the second face image contained in the target image, respectively, to obtain the original three-dimensional face mesh of the first face image, and the first focal length and first direction of the face in the second face image, reconstructing the target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image, and adjusting the first face image pixel by pixel according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain the target face image. Thus, the direction and perspective of the face in the original image are adjusted according to the face in the target image based on the three-dimensional reconstruction method, so that the facial features layout of the adjusted target face image is more reasonable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art

[0002] In face-changing applications, it is very important to align the direction and perspective of the source face with the target face. However, in related technologies, a relatively simple orthogonal projection is basically assumed, and then the 3D direction of the face under the orthogonal projection is reconstructed, and the face orientation is adjusted according to the target direction. As a result, the acquisition of the 3D direction of the face is very inaccurate due to the different imaging rules of the orthogonal projection and the real world. Summary of the invention

[0003] The present disclosure provides a method, device and electronic device for adjusting a face image, so as to at least solve the problem of large errors in adjusting a face image in the related art. The technical solution of the present disclosure is as follows:

[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing method, including:

[0005] Acquire an original image and a target image; the original image includes a first face image, and the target image includes a second face image;

[0006] Reconstructing the first face image and the second face image in three dimensions respectively to obtain an original three-dimensional face mesh of the first face image and a first focal length and a first direction of the face in the second face image;

[0007] reconstructing a target three-dimensional face mesh of the first face image according to the first focal length, the first direction, and the first face image;

[0008] The first face image is adjusted pixel by pixel according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image.

[0009] As a first possible scenario of an embodiment of the present disclosure, reconstructing a target three-dimensional face mesh of the first face image according to the first focal length, the first direction, and the first face image includes:

[0010] Performing three-dimensional reconstruction on the first facial image to obtain a second focal length and a second direction of the first facial image;

[0011] The first facial image is rotated from the second direction to the first direction, the second focal length of the first facial image is adjusted to the first focal length, and the Z direction of the camera coordinate system corresponding to the first facial image is scaled to a first distance to obtain the target three-dimensional facial mesh; wherein the Z direction of the camera coordinate system is the distance between the lens of the acquisition device used to acquire the original image and the face in the first facial image; and the first distance is the ratio of the second focal length to the first focal length.

[0012] As a second possible scenario of the embodiment of the present disclosure, the pixel-by-pixel adjustment of the first face image according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain the target face image includes:

[0013] Projecting the original three-dimensional face mesh and the target three-dimensional face mesh to obtain corresponding original two-dimensional face mesh and target two-dimensional face mesh respectively;

[0014] Each pixel point in the original two-dimensional face grid is moved to a pixel point position corresponding to the target two-dimensional face grid to obtain the target face image.

[0015] As a third possible situation of the embodiment of the present disclosure, it also includes:

[0016] Performing facial key point detection on the original image to obtain a first facial key point;

[0017] Performing facial key point detection on the original two-dimensional face grid to obtain second facial key points;

[0018] Adjusting three-dimensional reconstruction parameters during three-dimensional reconstruction of the first face image until the position difference between the first face key point and the second face key point is minimized;

[0019] The first facial image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters.

[0020] As a fourth possible situation of the embodiment of the present disclosure, it also includes:

[0021] Perform facial key point detection on the target image to obtain the third facial key point

[0022] Performing facial key point detection on the target two-dimensional face grid to obtain a fourth facial key point;

[0023] Adjusting the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the second facial image until the position difference between the third facial key point and the fourth facial key point is minimized;

[0024] The second facial image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters.

[0025] As a fifth possible situation of the embodiment of the present disclosure, the three-dimensional reconstruction parameters include at least one of a focal length, a face shape coefficient, a displacement parameter and a rotation angle.

[0026] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:

[0027] An acquisition unit is configured to acquire an original image and a target image; the original image includes a first face image, and the target image includes a second face image;

[0028] a three-dimensional reconstruction unit, configured to perform three-dimensional reconstruction on the first face image and the second face image respectively, to obtain an original three-dimensional face mesh of the first face image, and a first focal length and a first direction of the face in the second face image;

[0029] a face mesh reconstruction unit, configured to reconstruct a target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image;

[0030] The processing unit is configured to perform pixel-by-pixel adjustment on the first face image according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image.

[0031] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0032] processor;

[0033] a memory for storing instructions executable by the processor;

[0034] The processor is configured to execute the instructions to implement the image processing method described in the first aspect.

[0035] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image processing method described in the first aspect.

[0036] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program / instruction, wherein the computer program / instruction implements the image processing method described in the first aspect when executed by a processor.

[0037] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: after obtaining the original image and the target image, the original image contains the first face image and the target image contains the second face image, respectively, and three-dimensional reconstruction is performed to obtain the original three-dimensional face mesh of the first face image, and the first focal length and first direction of the face in the second face image; according to the first focal length, the first direction and the first face image, the target three-dimensional face mesh of the first face image is reconstructed; according to the original three-dimensional face mesh and the target three-dimensional face mesh, the first face image is adjusted pixel by pixel to obtain the target face image. Thus, the direction and perspective of the face in the original image are adjusted according to the face in the target image based on the three-dimensional reconstruction method, so that the facial features layout of the adjusted target face image is more reasonable.

[0038] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0040] Figure 1 is a flowchart of an image processing method according to an exemplary embodiment;

[0041] Figure 2 is a flowchart of another image processing method according to an exemplary embodiment;

[0042] Figure 3 is a block diagram of an image processing device according to an exemplary embodiment;

[0043] Figure 4 The invention is a block diagram of an electronic device for image processing according to an exemplary embodiment. DETAILED DESCRIPTION

[0044] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0045] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0046] Figure 1 is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 As shown, the image processing method is used in an electronic device and includes the following steps.

[0047] In step S11, an original image and a target image are obtained;

[0048] The original image includes a first face image, and the target image includes a second face image.

[0049] The embodiment of the present disclosure is illustrated by an example in which the image processing method is configured in an image processing device. The image processing device can be applied to any electronic device so that the electronic device can perform an image processing function.

[0050] Among them, the electronic devices may be personal computers (PCs), cloud devices, mobile devices, etc. The mobile devices may be, for example, mobile phones, tablet computers, personal digital assistants, wearable devices, vehicle-mounted devices, and other hardware devices with various operating systems.

[0051] It is understandable that the original image is taken by the electronic device without any processing, and includes the first face image. The original image can be any one of RGB (Red, Green, Blue) image, grayscale image, depth image, etc.

[0052] The target image may be a preset image including a second facial image, and the second facial image needs to be used to replace the first facial image in the original image.

[0053] An electronic device may be provided with a camera, and the number of cameras provided may be one or more. For example, 1, 2, 3, 5, etc. may be provided, and this is not limited here. The form in which the camera is provided in the electronic device is not limited, for example, it may be a camera built into the electronic device, or it may be a camera external to the electronic device; it may be a front camera or a rear camera.

[0054] The camera on the electronic device may be any type of camera, for example, a color camera, a black and white camera, a depth camera, a telephoto camera, a wide-angle camera, etc., which are not limited here.

[0055] In step S12, the first face image and the second face image are respectively reconstructed in three dimensions to obtain an original three-dimensional face mesh of the first face image, and a first focal length and a first direction of the face in the second face image.

[0056] In the embodiment of the present disclosure, after obtaining an original image containing a first facial image and a target image containing a second facial image, the first facial image and the second facial image can be three-dimensionally reconstructed respectively to obtain the original three-dimensional facial mesh of the first facial image, and the first focal length and first direction of the face in the second facial image.

[0057] For the sake of ease of distinction, in the present disclosure, the focal length and direction of the face in the second facial image obtained by three-dimensional reconstruction are named as the first focal length and the first direction, and the focal length and direction obtained by three-dimensional reconstruction of the face in the first facial image are named as the second focal length and the second direction. Of course, other naming methods can also be used, which are not limited here.

[0058] In the embodiment of the present disclosure, when performing three-dimensional reconstruction on the first facial image, during the three-dimensional reconstruction process, it is necessary to adjust the three-dimensional reconstruction coefficients of the first facial image during the three-dimensional reconstruction process, so as to use the optimized and adjusted reconstruction parameters to perform three-dimensional reconstruction on the first facial image, thereby reconstructing a more realistic three-dimensional face.

[0059] In the disclosed embodiment, after acquiring the original image, facial key point detection can be performed on the original image to obtain the first facial key point, and facial key point detection can be performed on the original two-dimensional face mesh to obtain the second facial key point. According to the position difference between the first facial key point and the second facial key point, the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the first facial image are adjusted until the position difference between the first facial key point and the second facial key point is minimized, and then the first facial image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters. Therefore, in the process of three-dimensional reconstruction of the first facial image, the three-dimensional reconstruction parameters are adjusted, and the first facial image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters, which is conducive to improving the accuracy of the three-dimensional reconstruction of the first facial image, so as to obtain the original three-dimensional face mesh with higher accuracy.

[0060] The three-dimensional reconstruction parameters include at least one of focal length, face shape coefficient, displacement parameter and rotation angle. The goal of optimizing the three-dimensional reconstruction parameters is to minimize the error between the two-dimensional face mesh and the projection point of the reconstructed three-dimensional face mesh, so that when the face image is three-dimensionally reconstructed according to the optimized three-dimensional reconstruction parameters, a more realistic three-dimensional face can be obtained.

[0061] In the embodiment of the present disclosure, when performing three-dimensional reconstruction on the second facial image, during the three-dimensional reconstruction process, it is also necessary to adjust the three-dimensional reconstruction coefficient of the second facial image during the three-dimensional reconstruction process, so as to use the optimized and adjusted reconstruction parameters to perform three-dimensional reconstruction on the second facial image, thereby reconstructing a more realistic three-dimensional face.

[0062] In the disclosed embodiment, after acquiring the target image, facial key point detection can be performed on the target image to obtain the third facial key point, and facial key point detection can be performed on the target two-dimensional face grid to obtain the fourth facial key point. According to the position difference between the third facial key point and the fourth facial key point, the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the second face image are adjusted until the position difference between the third facial key point and the fourth facial key point is minimized, and then the second face image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters. Thus, the second face image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters, which is conducive to improving the accuracy of the three-dimensional reconstruction of the second face image.

[0063] When performing facial key point detection on the original image and the target image, the original image and the target image may be input into a trained three-dimensional facial key point detection model to determine the first facial key point and the third facial key point according to the output of the model.

[0064] When performing facial key point detection on the original two-dimensional face mesh and the target two-dimensional face mesh, the original two-dimensional face mesh and the target two-dimensional face mesh can also be input into the trained two-dimensional face key point detection module respectively to determine the second facial key point and the fourth facial key point according to the model output.

[0065] The method for detecting facial key points in the embodiments of the present disclosure is not limited to the above-mentioned implementation method. Any achievable facial key point detection method can be applied to the present disclosure and is not limited here.

[0066] In step S13, a target three-dimensional face mesh of the first face image is reconstructed according to the first focal length, the first direction and the first face image.

[0067] In the disclosed embodiment, after performing three-dimensional reconstruction on the first facial image, the original three-dimensional facial mesh and the second focal length and second direction of the first facial image can be obtained. After performing three-dimensional reconstruction on the second facial image, the first focal length and first direction of the second facial image can be obtained. The first facial image can be three-dimensionally reconstructed based on the first focal length, the first direction and the first facial image to reconstruct the target three-dimensional facial mesh of the first facial image.

[0068] Optionally, after performing three-dimensional reconstruction on the first face image and the second face image respectively to obtain the second focal length and the second direction of the first face image, and the first focal length and the first direction of the second face image, the first face image can be rotated from the second direction to the first direction, the second focal length of the first face image can be adjusted to the first focal length, and the Z direction of the camera coordinate system corresponding to the first face image can be scaled to the first distance to obtain the target three-dimensional face network. The Z direction of the camera coordinate system is the distance between the lens of the acquisition device used to acquire the original image and the face in the first face image; the first distance is the ratio of the second focal length to the first focal length.

[0069] It should be explained that adjusting the second focal length of the first face image to the first focal length and scaling the Z direction of the camera coordinate system corresponding to the first face image to the first distance can ensure that the size of the face in the first face image remains unchanged after the focal length is adjusted. Thus, the target three-dimensional face mesh is reconstructed according to the adjusted first focal length and the first direction and the first face image, and the first face image is adjusted according to the original three-dimensional face mesh and the reconstructed target three-dimensional face mesh, so as to achieve the purpose of adjusting the direction and focal length together to obtain more realistic facial features.

[0070] As an example, assume that the second face image in the target image is reconstructed in three dimensions, and the focal length of the obtained second face image is F1 and the direction is R1, and the first face image in the original image is reconstructed in three dimensions, and the focal length of the obtained first face image is F2 and the direction is R2. The focal length of the face in the first face image is adjusted to F1, and the lens direction of the camera coordinate system corresponding to the first face image is brought closer to F2 / F1 to ensure that the size of the face remains unchanged after the focal length is adjusted. The direction of the face in the first face image is adjusted to R1, so as to reconstruct the target three-dimensional face mesh of the first face image according to the adjusted focal length F1, direction R1 and the first face image.

[0071] In step S14, the first face image is adjusted pixel by pixel according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image.

[0072] The target face image is a face image obtained by adjusting the first face image in the original image.

[0073] In the embodiment of the present disclosure, after reconstructing the original three-dimensional face mesh and the target three-dimensional face mesh corresponding to the first face image, the first face image can be adjusted pixel by pixel based on the difference between the original three-dimensional face mesh and the target three-dimensional face mesh to obtain the target face image.

[0074] The image processing method of the disclosed embodiment, after acquiring the original image and the target image, respectively performs three-dimensional reconstruction on the first face image contained in the original image and the second face image contained in the target image, obtains the original three-dimensional face mesh of the first face image, and the first focal length and first direction of the face in the second face image, reconstructs the target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image, and adjusts the first face image pixel by pixel according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain the target face image. Thus, based on the three-dimensional reconstruction method, the direction and perspective of the face in the original image are adjusted according to the face in the target image, so that the facial features layout of the adjusted target face image is more reasonable.

[0075] On the basis of the above-mentioned embodiment, when the first face image is adjusted pixel by pixel according to the original three-dimensional face grid and the target three-dimensional face grid, the original two-dimensional face grid and the target two-dimensional face grid corresponding to the original three-dimensional face grid and the target three-dimensional face grid can be obtained respectively, and each pixel point in the original two-dimensional face grid is adjusted according to the position difference of the pixel points of the original two-dimensional face grid and the target two-dimensional face grid. Figure 2 Provide a detailed introduction.

[0076] Figure 2 FIG. 1 is a flow chart of another image processing method according to an exemplary embodiment. Figure 2 As shown, the image processing method may include the following steps.

[0077] In step S21, an original image and a target image are acquired; the original image includes a first face image, and the target image includes a second face image.

[0078] In step S22, the first face image and the second face image are respectively reconstructed in three dimensions to obtain an original three-dimensional face mesh of the first face image, and a first focal length and a first direction of the face in the second face image.

[0079] In step S23, a target three-dimensional face mesh of the first face image is reconstructed according to the first focal length, the first direction and the first face image.

[0080] It should be noted that the implementation process of the above steps S21 to S23 can refer to the implementation process of steps S11 to S13 in the above embodiment, which will not be repeated here.

[0081] In step S24, the original three-dimensional face mesh and the target three-dimensional face mesh are projected to obtain the corresponding original two-dimensional face mesh and the target two-dimensional face mesh respectively.

[0082] In the disclosed embodiment, after reconstructing the original three-dimensional face mesh and the target three-dimensional face mesh, the original three-dimensional face mesh and the target three-dimensional face mesh can be projected to obtain the corresponding original two-dimensional face mesh and target two-dimensional face mesh, respectively.

[0083] Optionally, when projecting the original three-dimensional face mesh and the target three-dimensional face mesh, a projection method such as parallel projection, perspective projection, orthogonal projection, etc. may be used, which is not limited in the embodiments of the present disclosure.

[0084] Step S25, moving each pixel point in the original two-dimensional face grid to the pixel point position corresponding to the target two-dimensional face grid to obtain the target face image.

[0085] In the disclosed embodiment, after the original three-dimensional face mesh and the target three-dimensional face mesh are projected to obtain the corresponding original two-dimensional face mesh and target two-dimensional face mesh respectively, each pixel point in the original two-dimensional face mesh can be moved to the corresponding pixel point position of the target two-dimensional face mesh according to the position difference of the corresponding pixel points in the original two-dimensional face mesh and the target two-dimensional face mesh to obtain the target face image.

[0086] In the disclosed embodiment, the original three-dimensional face mesh and the target three-dimensional face mesh are projected to obtain the corresponding original two-dimensional face mesh and the target two-dimensional face mesh, respectively, and each pixel point in the original two-dimensional face mesh is moved to the pixel point position corresponding to the target two-dimensional face mesh to obtain the target face image. Thus, according to the position difference of the corresponding pixel points in the original two-dimensional face mesh and the target two-dimensional face mesh, the original two-dimensional face mesh is deformed pixel by pixel, so that the target face image obtained after adjusting the pixels is more realistic and reasonable.

[0087] In order to implement the above embodiments, the present disclosure proposes an image processing device.

[0088] Figure 3 FIG. 1 is a block diagram of an image processing device according to an exemplary embodiment. Figure 3 The device may include: an acquisition unit 310, a three-dimensional reconstruction unit 320, a face mesh reconstruction unit 330 and a processing unit 340.

[0089] The acquisition unit 310 is configured to acquire an original image and a target image; the original image includes a first face image, and the target image includes a second face image;

[0090] A three-dimensional reconstruction unit 320 is configured to perform three-dimensional reconstruction on the first face image and the second face image respectively to obtain an original three-dimensional face mesh of the first face image and a first focal length and a first direction of the face in the second face image;

[0091] A face mesh reconstruction unit 330 is configured to reconstruct a target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image;

[0092] The processing unit 340 is configured to perform pixel-by-pixel adjustment on the first face image according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image.

[0093] Optionally, the face mesh reconstruction unit 330 may also be configured to perform:

[0094] Perform three-dimensional reconstruction on the first facial image to obtain the second focal length and second direction of the first facial image; rotate the first facial image from the second defense line to the first direction, adjust the second focal length of the first facial image to the first focal length, and scale the Z direction of the camera coordinate system corresponding to the first facial image to a first distance to obtain the target three-dimensional facial mesh; wherein the Z direction of the camera coordinate system is the distance between the lens of the acquisition device used to acquire the original image and the face in the first facial image; and the first distance is the ratio of the second focal length to the first focal length.

[0095] Optionally, the processing unit 340 may also be configured to execute:

[0096] Projecting the original three-dimensional face mesh and the target three-dimensional face mesh to obtain corresponding original two-dimensional face mesh and target two-dimensional face mesh respectively;

[0097] Each pixel point in the original two-dimensional face grid is moved to a pixel point position corresponding to the target two-dimensional face grid to obtain the target face image.

[0098] Optionally, the image processing device may further include:

[0099] A first detection unit is configured to perform facial key point detection on the original image to obtain a first facial key point;

[0100] A second detection unit is configured to perform facial key point detection on the original two-dimensional face grid to obtain second facial key points;

[0101] A first adjustment unit is configured to adjust a 3D reconstruction parameter in a 3D reconstruction process of the first face image until a position difference between the first face key point and the second face key point is minimized;

[0102] The first reconstruction unit is configured to perform three-dimensional reconstruction on the first face image according to the adjusted three-dimensional reconstruction parameters.

[0103] Optionally, the image processing device may further include:

[0104] The third detection unit is configured to perform face key point detection on the target image to obtain a third face key point

[0105] A fourth detection unit is configured to perform facial key point detection on the target two-dimensional face grid to obtain fourth facial key points;

[0106] A second adjustment unit is configured to adjust the 3D reconstruction parameters in the 3D reconstruction process of the second face image until the position difference between the third face key point and the fourth face key point is minimized;

[0107] The second reconstruction unit is configured to perform three-dimensional reconstruction on the second face image according to the adjusted three-dimensional reconstruction parameters.

[0108] Optionally, the three-dimensional reconstruction parameters include at least one of a focal length, a face shape coefficient, a displacement parameter and a rotation angle.

[0109] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0110] The image processing device of the disclosed embodiment, after acquiring the original image and the target image, respectively performs three-dimensional reconstruction on the first face image contained in the original image and the second face image contained in the target image, obtains the original three-dimensional face mesh of the first face image, and the first focal length and first direction of the face in the second face image, reconstructs the target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image, and adjusts the first face image pixel by pixel according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain the target face image. Thus, the direction and perspective of the face in the original image are adjusted according to the face in the target image based on the three-dimensional reconstruction method, so that the facial features layout of the adjusted target face image is more reasonable.

[0111] In order to implement the above embodiment, the embodiment of the present disclosure also proposes an electronic device.

[0112] Among them, electronic equipment includes:

[0113] processor;

[0114] a memory for storing instructions executable by the processor;

[0115] The processor is configured to execute the instructions to implement the image processing method as described above.

[0116] As an example, Figure 4 is a block diagram of an electronic device for image processing according to an exemplary embodiment. Figure 4 As shown, the electronic device 200 may further include:

[0117] The memory 210 and the processor 220, a bus 230 connecting different components (including the memory 210 and the processor 220), the memory 210 stores a computer program, and when the processor 220 executes the program, the image processing method described in the embodiment of the present disclosure is implemented.

[0118] Bus 230 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0119] The electronic device 200 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 200, including volatile and non-volatile media, removable and non-removable media.

[0120] The memory 210 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 240 and / or cache memory 250. The electronic device 200 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 260 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 230 via one or more data medium interfaces. The memory 210 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.

[0121] A program / utility 280 having a set (at least one) of program modules 270 may be stored, for example, in the memory 210, such program modules 270 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 270 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0122] The electronic device 200 may also communicate with one or more external devices 290 (e.g., keyboard, pointing device, display 291, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 200, and / or communicate with any device that enables the electronic device 200 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed via an input / output (I / O) interface 292. Furthermore, the electronic device 200 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) via a network adapter 293. As shown, the network adapter 293 communicates with other modules of the electronic device 200 via a bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0123] The processor 220 executes various functional applications and data processing by running the programs stored in the memory 210 .

[0124] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the image processing method of the embodiment of the present disclosure, and will not be repeated here.

[0125] In order to implement the above embodiments, the present disclosure further proposes a computer-readable storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the image processing method described in the above embodiments.

[0126] In order to implement the above embodiments, the present disclosure further proposes a computer program product, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the image processing method described in the above embodiments is implemented.

[0127] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0128] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. An image processing method, characterized in that: include: Acquire an original image and a target image; the original image includes a first face image, and the target image includes a second face image; Reconstructing the first face image and the second face image in three dimensions respectively to obtain an original three-dimensional face mesh of the first face image and a first focal length and a first direction of the face in the second face image; reconstructing a target three-dimensional face mesh of the first face image according to the first focal length, the first direction, and the first face image; Performing pixel-by-pixel adjustment on the first face image according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image; The method of reconstructing a target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image comprises: performing three-dimensional reconstruction on the first face image to obtain a second focal length and a second direction of the first face image, rotating the first face image from the second direction to the first direction, adjusting the second focal length of the first face image to the first focal length, and scaling the Z direction of the camera coordinate system corresponding to the first face image to a first distance to obtain the target three-dimensional face mesh; wherein the Z direction of the camera coordinate system is the distance between the lens of the acquisition device used to acquire the original image and the face in the first face image; and the first distance is the ratio of the second focal length to the first focal length. When performing three-dimensional reconstruction on a first face image, it is necessary to adjust the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the first face image, wherein the three-dimensional reconstruction parameters include at least one of a focal length, a face shape coefficient, a displacement parameter, and a rotation angle. The goal of optimizing the three-dimensional reconstruction parameters is to minimize the error between the two-dimensional face mesh and the projection point of the reconstructed three-dimensional face mesh.

2. The image processing method according to claim 1, characterized in that: The step of adjusting the first face image pixel by pixel according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image includes: Projecting the original three-dimensional face mesh and the target three-dimensional face mesh to obtain corresponding original two-dimensional face mesh and target two-dimensional face mesh respectively; Each pixel point in the original two-dimensional face grid is moved to a pixel point position corresponding to the target two-dimensional face grid to obtain the target face image.

3. The image processing method according to claim 2, characterized in that: Also includes: Performing facial key point detection on the original image to obtain a first facial key point; Performing facial key point detection on the original two-dimensional face grid to obtain second facial key points; Adjusting three-dimensional reconstruction parameters during three-dimensional reconstruction of the first face image until the position difference between the first face key point and the second face key point is minimized; The first facial image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters.

4. The image processing method according to claim 2, characterized in that: Also includes: Performing facial key point detection on the target image to obtain third facial key points; Performing facial key point detection on the target two-dimensional face grid to obtain a fourth facial key point; Adjusting the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the second facial image until the position difference between the third facial key point and the fourth facial key point is minimized; The second facial image is three-dimensionally reconstructed according to the adjusted three-dimensional reconstruction parameters.

5. An image processing device, characterized in that: include: An acquisition unit is configured to acquire an original image and a target image; the original image includes a first face image, and the target image includes a second face image; a three-dimensional reconstruction unit, configured to perform three-dimensional reconstruction on the first face image and the second face image respectively, to obtain an original three-dimensional face mesh of the first face image, and a first focal length and a first direction of the face in the second face image; a face mesh reconstruction unit, configured to reconstruct a target three-dimensional face mesh of the first face image according to the first focal length, the first direction and the first face image; A processing unit is configured to perform pixel-by-pixel adjustment on the first face image according to the original three-dimensional face mesh and the target three-dimensional face mesh to obtain a target face image; Wherein, the face mesh reconstruction unit is further configured to perform: performing three-dimensional reconstruction on the first face image to obtain a second focal length and a second direction of the first face image, rotating the first face image from the second direction to the first direction, adjusting the second focal length of the first face image to the first focal length, and scaling the Z direction of the camera coordinate system corresponding to the first face image to a first distance to obtain the target three-dimensional face mesh; wherein the Z direction of the camera coordinate system is the distance between the lens of the acquisition device used to acquire the original image and the face in the first face image; the first distance is the ratio of the second focal length to the first focal length; When performing three-dimensional reconstruction on a first face image, it is necessary to adjust the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the first face image, wherein the three-dimensional reconstruction parameters include at least one of a focal length, a face shape coefficient, a displacement parameter, and a rotation angle. The goal of optimizing the three-dimensional reconstruction parameters is to minimize the error between the two-dimensional face mesh and the projection point of the reconstructed three-dimensional face mesh.

6. The image processing device according to claim 5, characterized in that: The processing unit is further configured to execute: Projecting the original three-dimensional face mesh and the target three-dimensional face mesh to obtain corresponding original two-dimensional face mesh and target two-dimensional face mesh respectively; Each pixel point in the original two-dimensional face grid is moved to a pixel point position corresponding to the target two-dimensional face grid to obtain the target face image.

7. The image processing device according to claim 5, characterized in that: The device further comprises: A first detection unit is configured to perform facial key point detection on the original image to obtain a first facial key point; A second detection unit is configured to perform facial key point detection on the original two-dimensional face grid to obtain second facial key points; A first adjustment unit is configured to adjust a 3D reconstruction parameter in a 3D reconstruction process of the first face image until a position difference between the first face key point and the second face key point is minimized; The first reconstruction unit is configured to perform three-dimensional reconstruction on the first face image according to the adjusted three-dimensional reconstruction parameters.

8. The image processing device according to claim 5, characterized in that: The device further comprises: The third detection unit is configured to perform face key point detection on the target image to obtain a third face key point A fourth detection unit is configured to perform facial key point detection on the target two-dimensional face grid to obtain fourth facial key points; A second adjustment unit is configured to adjust the three-dimensional reconstruction parameters in the three-dimensional reconstruction process of the second face image until the position difference between the third face key point and the fourth face key point is minimized; The second reconstruction unit is configured to perform three-dimensional reconstruction on the second face image according to the adjusted three-dimensional reconstruction parameters.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image processing method according to any one of claims 1 to 4. 10 . A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image processing method according to any one of claims 1 to 4.