Image processing method, device, electronic device and computer readable storage medium
By obtaining and processing the key point position information of the target object and modification material in the image, and adjusting the shape of the target object to match the modification material, the problem of fitting beauty special effects is solved and the modification effect is improved.
Patent Information
- Application Number
- CN202111051761.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-08
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-09-08
AI Technical Summary
In short videos and live broadcasts, the retouching materials of beauty special effects are not easy to fit with the target objects in the image, resulting in poor retouching effects.
By obtaining the key point position information of the target object and the modified material, determine the position transformation relationship, perform position transformation processing, adjust the shape of the target object to make it consistent with the shape of the modified material, and then paste the modified material onto the adjusted target object.
It improves the fit between the modified material and the target object, maintains the shape of the modified material, and improves the modified effect.
Smart Images

Figure CN113781293B
Abstract
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 computer-readable storage medium. Background Art
[0002] The application of beauty effects is very common in short videos, live broadcasts and other applications. Since beauty effects are to paste the modified materials to the corresponding modified parts of the image, beauty effects can also be called makeup.
[0003] Take eyebrow makeup as an example. The goal is to paste the eyebrow material to the eyebrow position of the face in the image. In related technologies, the eyebrow material is directly pasted to the eyebrow position in the image. However, the eyebrow shape of the eyebrow in the image is usually inconsistent with that of the eyebrow material, so it is easy to cause the eyebrow material to not fit the eyebrow in the image. Other beauty special effects also have similar problems. Summary of the invention
[0004] The present disclosure provides an image processing method, device, electronic device and computer-readable storage medium to at least solve the problem of poor modification effect of modified materials in the related art. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing method, including:
[0006] Acquire modification material information of a target object in an image, wherein the modification material information includes modification material and key point position information of the modification material;
[0007] Determining a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material;
[0008] Based on the position transformation relationship, position transformation processing is performed on the key point position information of the modified material to obtain target key point position information;
[0009] Using the target key point position information as new key point position information of the target object, adjusting the shape of the target object;
[0010] The modified material is pasted onto the target object after shape adjustment to obtain a processed image.
[0011] In some possible implementations, determining a position transformation relationship between the modified material and the target object based on key point position information of the target object and key point position information of the modified material includes:
[0012] Based on the key point position information of the target object, N first preset key points are determined, and region division is performed based on the N first preset key points to obtain at least two first regions, where N is an integer not less than 4;
[0013] Based on the key point position information of the modified material, N second preset key points are determined, and region division is performed based on the N second preset key points to obtain at least two second regions, where the at least two second regions correspond one-to-one to the at least two first regions;
[0014] Determining a position transformation relationship between each second area and the corresponding first area;
[0015] The position transformation relationship between each second area and the corresponding first area is determined as the position transformation relationship between the modified material and the target object.
[0016] In some possible implementations, based on the position transformation relationship, performing position transformation processing on the key point position information of the modified material to obtain the target key point position information includes:
[0017] Determine a second area corresponding to each key point information of the modified material;
[0018] Based on the position transformation relationship between the second area and the corresponding first area, the key point information is subjected to position transformation processing to obtain the target key point position information.
[0019] In some possible implementations, determining a position transformation relationship between the modified material and the target object based on key point position information of the target object and key point position information of the modified material includes:
[0020] Based on the key point position information of the target object, M third preset key points are determined, and a region is constructed based on the M third preset key points to obtain a third region, where M is an integer not less than 3;
[0021] Based on the key point position information of the modified material, M fourth preset key points are determined, and a region is constructed based on the M fourth preset key points to obtain a fourth region;
[0022] The position transformation relationship between the fourth area and the third area is determined as the position transformation relationship between the modified material and the target object.
[0023] In some possible implementations, using the target key point position information as new key point position information of the target object and adjusting the shape of the target object includes:
[0024] Based on the correspondence between each subdivided grid of the target object and the key point of the target object, select first key point position information corresponding to the subdivided grid from the key point position information of the target object, and select second key point position information corresponding to the subdivided grid from the target key point position information;
[0025] Based on the first key point position information, a first grid corresponding to the subdivided grid is generated; based on the second key point position information, a second grid corresponding to the subdivided grid is generated;
[0026] A portion of the target object corresponding to the first grid is pasted onto the second grid to obtain the target object after the shape is adjusted.
[0027] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:
[0028] An acquisition unit is configured to acquire modified material information of a target object in an image, wherein the modified material information includes the modified material and key point position information of the modified material;
[0029] A determining unit is configured to determine a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material;
[0030] A transformation unit is configured to perform position transformation processing on the key point position information of the modified material based on the position transformation relationship to obtain target key point position information;
[0031] An adjusting unit is configured to adjust the shape of the target object by using the target key point position information as new key point position information of the target object;
[0032] The mapping unit is configured to paste the modified material onto the target object after shape adjustment to obtain a processed image.
[0033] In some possible implementations, the determining unit is specifically configured to execute:
[0034] Based on the key point position information of the target object, N first preset key points are determined, and region division is performed based on the N first preset key points to obtain at least two first regions, where N is an integer not less than 4;
[0035] Based on the key point position information of the modified material, N second preset key points are determined, and region division is performed based on the N second preset key points to obtain at least two second regions, where the at least two second regions correspond one-to-one to the at least two first regions;
[0036] Determining a position transformation relationship between each second area and the corresponding first area;
[0037] The position transformation relationship between each second area and the corresponding first area is determined as the position transformation relationship between the modified material and the target object.
[0038] In some possible implementations, the transform unit is specifically configured to perform:
[0039] Determine a second area corresponding to each key point information of the modified material;
[0040] Based on the position transformation relationship between the second area and the corresponding first area, the key point information is subjected to position transformation processing to obtain the target key point position information.
[0041] In some possible implementations, the determining unit is specifically configured to execute:
[0042] Based on the key point position information of the target object, M third preset key points are determined, and a region is constructed based on the M third preset key points to obtain a third region, where M is an integer not less than 3;
[0043] Based on the key point position information of the modified material, M fourth preset key points are determined, and a region is constructed based on the M fourth preset key points to obtain a fourth region;
[0044] The position transformation relationship between the fourth area and the third area is determined as the position transformation relationship between the modified material and the target object.
[0045] In some possible implementations, the adjustment unit is specifically configured to perform:
[0046] Based on the correspondence between each subdivided grid of the target object and the key point of the target object, select first key point position information corresponding to the subdivided grid from the key point position information of the target object, and select second key point position information corresponding to the subdivided grid from the target key point position information;
[0047] Based on the first key point position information, a first grid corresponding to the subdivided grid is generated; based on the second key point position information, a second grid corresponding to the subdivided grid is generated;
[0048] A portion of the target object corresponding to the first grid is pasted onto the second grid to obtain the target object after the shape is adjusted.
[0049] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0050] processor;
[0051] a memory for storing instructions executable by the processor;
[0052] The processor is configured to execute the instructions to implement any of the above-mentioned image processing methods.
[0053] 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 perform any of the above-mentioned image processing methods.
[0054] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, wherein the computer program product includes a program code. When the program code is run on an electronic device, the program code is used to enable the electronic device to execute any of the above-mentioned image processing methods.
[0055] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0056] The modified material information of the target object in the image is obtained, and the modified material information includes the modified material and the key point position information of the modified material. Based on the key point position information of the target object and the key point position information of the modified material, the position transformation relationship between the modified material and the target object is determined. Based on the position transformation relationship, the key point position information of the modified material is subjected to position transformation processing to obtain the target key point position information. The target key point position information is used as the new key point position information of the target object, and the shape of the target object is adjusted. Then, the modified material is pasted on the target object after the shape adjustment to obtain the processed image. In this way, the shape of the target object is first adjusted so that the shape of the target object is consistent with the shape of the modified material, and then the modified material is pasted on the target object, which can not only better maintain the shape of the modified material, but also improve the fitting effect of the modified material and the target object.
[0057] 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
[0058] 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.
[0059] Figure 1 The figure is a flowchart of an image processing method according to an exemplary embodiment.
[0060] Figure 2The present invention is a flow chart showing a method for determining a position transformation relationship between a modified material and a target object according to an exemplary embodiment.
[0061] Figure 3 A schematic diagram of eyebrow region division provided in an embodiment of the present disclosure.
[0062] Figure 4 It is a flow chart of another method for determining the position transformation relationship between a modified material and a target object according to an exemplary embodiment.
[0063] Figure 5 A schematic diagram of another eyebrow region division provided in an embodiment of the present disclosure.
[0064] Figure 6 The figure is a flow chart of a method for adjusting the shape of a target object according to an exemplary embodiment.
[0065] Figure 7 A schematic diagram of an eyebrow segmentation grid provided in an embodiment of the present disclosure.
[0066] Figure 8 It is a schematic diagram of an eyebrow material according to an exemplary embodiment.
[0067] Fig. 9 is a schematic diagram of eyebrows in an image according to an exemplary embodiment.
[0068] Fig.10 is a schematic diagram showing key points of eyebrows in an image according to an exemplary embodiment.
[0069] Fig.11a The figure is a schematic diagram of dividing the region of eyebrows in an image according to an exemplary embodiment.
[0070] Fig.11b The figure is a schematic diagram of region division of an eyebrow material according to an exemplary embodiment.
[0071] Fig.12 The figure is a schematic diagram showing the positions of key points of an eyebrow according to an exemplary embodiment.
[0072] Fig.13 This is a schematic diagram of eyebrows in an image after the shape is adjusted according to an embodiment of the present disclosure.
[0073] Fig.14 A method for using the embodiment of the present disclosure Figure 8 Eyebrow material pair Fig. 9 Schematic diagram of the effect after mapping the eyebrows.
[0074] Fig.15is a block diagram of an image processing apparatus according to an exemplary embodiment.
[0075] Fig.16 The diagram is a schematic diagram of an electronic device for implementing an image processing method according to an exemplary embodiment. DETAILED DESCRIPTION
[0076] 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.
[0077] 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.
[0078] The solution of the disclosed embodiment is applicable not only to the scenario in which the user uses beauty effects when shooting images or videos, but also to the scenario in which the technicians test the beautifying effect of the beauty effects in the background.
[0079] Next, the solution of the present disclosure is introduced in conjunction with specific embodiments.
[0080] Figure 1 The flowchart of an image processing method according to an exemplary embodiment includes the following steps.
[0081] S101: Acquire modification material information of a target object in an image, where the modification material information includes the modification material and key point position information of the modification material.
[0082] The modified material refers to the material that beautifies the target object. For example, when the target object is eyebrows, the modified material is the eyebrow material; when the target object is lips, the modified material is the lip material; when the target object is nails, the modified material is the nail material.
[0083] S102: Determine a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material.
[0084] In some embodiments, the Figure 2 The process shown determines the position transformation relationship between the modified material and the target object, and the process includes the following steps.
[0085] S201a: Based on the key point position information of the target object, determine N first preset key points, and perform region division based on the N first preset key points to obtain at least two first regions, where N is an integer not less than 4.
[0086] For example, the target object is eyebrows and the modified material is eyebrows. Figure 3 A schematic diagram of eyebrow region division provided in an embodiment of the present disclosure, Figure 3 In the figure, small dots represent the key points of eyebrows (the key points of the eyebrow head and eyebrow tail are covered by large dots). There are 10 key points on one side of the eyebrow.
[0087] In specific implementation, for one eyebrow, 6 key points (i.e., 6 first preset key points) can be selected from the 10 key points of the eyebrow on that side: 1 key point at the beginning of the eyebrow, 4 key points around the middle of the eyebrow, and 1 key point at the end of the eyebrow. Then, region division can be performed based on these 6 key points to obtain two first regions corresponding to the eyebrow on that side.
[0088] Specifically, a vertex can be determined based on two key points above the middle of the eyebrow (for example, the average coordinates of the two key points above the middle of the eyebrow are used as the coordinates of the vertex), a vertex can be determined based on two key points below the middle of the eyebrow (for example, the average coordinates of the two key points below the middle of the eyebrow are used as the coordinates of the vertex), and the key points of the eyebrow head and eyebrow tail are respectively used as vertices, thereby determining four vertices ( Figure 3 Then, divide the area formed by these four vertices into two left and right areas (i.e., two first areas).
[0089] It should be noted that Figure 3 The key points of the eyebrows on one side are only examples. Figure 3 The key points at the positions of the four large dots of the single eyebrow shown can be directly selected, that is, at least four first preset key points can be selected.
[0090] S202a: Based on the key point position information of the modified material, determine N second preset key points, and perform region division based on the N second preset key points to obtain at least two second regions, and the at least two second regions correspond one-to-one to the at least two first regions.
[0091] In specific implementation, the second preset key point determined from the modified material can correspond one-to-one to the first preset key point determined from the target object, and the same area division rule can be used for the second preset key point and the first preset key point, so the final second area also corresponds one-to-one to the first area.
[0092] In addition, the method of dividing the regions of the modified material is similar to the method of dividing the regions of the target object, which will not be described in detail here.
[0093] S203a: Determine a position transformation relationship between each second area and the corresponding first area.
[0094] For example, a position transformation matrix between each second region and the corresponding first region is determined.
[0095] S204a: Determine the position transformation relationship between each second region and the corresponding first region as the position transformation relationship between the modified material and the target object.
[0096] In this way, the target object and the modified material are divided into at least two areas with one-to-one correspondence, and then the position transformation relationship between the modified material and the target object is determined area by area. This allows the key points at different positions in the modified material to be subsequently adjusted using different position transformation relationships, thereby maintaining the shape of the modified material as much as possible, thereby improving the modification effect of the modified material on the target object.
[0097] In some embodiments, the Figure 4 The process shown determines the position transformation relationship between the modified material and the target object, and the process includes the following steps.
[0098] S401a: Based on the key point position information of the target object, M third preset key points are determined, and a region is constructed based on the M third preset key points to obtain a third region, where M is an integer not less than 3.
[0099] For example, the target object is eyebrows and the modified material is eyebrows. Figure 5 A schematic diagram of another eyebrow region division provided in an embodiment of the present disclosure, Figure 5 In the figure, small dots represent the key points of eyebrows (the key points of the eyebrow head and eyebrow tail are covered by large dots). There are 10 key points on one side of the eyebrow.
[0100] In specific implementation, for one eyebrow on one side, 6 key points (i.e., 6 third preset key points) can be selected from the 10 key points of the eyebrow on that side: 1 key point at the beginning of the eyebrow, 4 key points around the middle of the eyebrow, and 1 key point at the end of the eyebrow. Then, a region can be constructed based on these 6 key points to obtain a third region corresponding to the eyebrow on that side.
[0101] Specifically, a vertex can be determined based on the four key points around the center of the eyebrow (for example, the average coordinates of the four key points around the center of the eyebrow are used as the coordinates of the vertex), and the key points of the eyebrow head and eyebrow tail are respectively used as vertices, thereby determining three vertices ( Figure 5 Then, the area formed by these three vertices is used as the third area.
[0102] It should be noted that Figure 5 The key points of the eyebrows on one side are only examples. Figure 5 The key points at the three large dots of the single eyebrow shown can be directly selected from the corresponding key points, that is, at least three third preset key points can be selected.
[0103] S402a: Based on the key point position information of the modified material, M fourth preset key points are determined, and a region is constructed based on the M fourth preset key points to obtain a fourth region.
[0104] In specific implementation, the fourth preset key point determined from the modified material and the third preset key point determined from the target object can be one-to-one corresponding, and the region construction method for the modified material is similar to the region construction method for the target object, which will not be repeated here.
[0105] S403a: Determine the position transformation relationship between the fourth region and the third region as the position transformation relationship between the modified material and the target object.
[0106] In this way, the target object and the modified material each construct an area, and the position transformation relationship between the area corresponding to the modified material and the area corresponding to the target object is determined as the position transformation relationship between the modified material and the target object. This allows the key points at different positions in the modified material to be subsequently adjusted using the same position transformation relationship, which is beneficial to improving the position transformation speed, thereby improving the modification speed of the target object using the modified material.
[0107] S103: Based on the position transformation relationship, position transformation processing is performed on the key point position information of the modified material to obtain target key point position information.
[0108] In some embodiments, there are multiple position transformation relationships between the modified material and the target object. At this time, the second area corresponding to each key point information of the modified material can be determined, and then the key point information is transformed based on the position transformation relationship between the second area and the corresponding first area to obtain the target key point position information.
[0109] In this way, different position transformation relationships are used to perform position transformation processing on key points at different positions in the modified material, which is beneficial to maintaining the shape of the modified material to the greatest extent and improving the modification effect of the modified material on the target object.
[0110] In some embodiments, there is one position transformation relationship between the modified material and the target object. In this case, the one position transformation relationship is directly used to perform position transformation processing on the key point position information of the modified material to obtain the target key point position information.
[0111] In this way, the key points at different positions in the modified material are adjusted using the same position transformation relationship, which is conducive to improving the position transformation speed, thereby improving the modification speed of the modified material on the target object.
[0112] S104: Using the target key point position information as new key point position information of the target object, adjusting the shape of the target object.
[0113] In specific implementation, Figure 6 The process shown adjusts the shape of the target object, and the process includes the following steps:
[0114] S601a: Based on the correspondence between each subdivided grid of the target object and the key point of the target object, select first key point position information corresponding to the subdivided grid from the key point position information of the target object, and select second key point position information corresponding to the subdivided grid from the target key point position information.
[0115] Take eyebrows as an example. Figure 7 A schematic diagram of a subdivided mesh of an eyebrow provided in an embodiment of the present disclosure, wherein each triangle is a subdivided mesh, each subdivided mesh has at least one vertex which is a key point of the eyebrow, and the positional relationship between the vertices which are not key points and the vertices which are key points in each subdivided mesh can be preset by a technician, so for a subdivided mesh whose three vertices are not all key points, the coordinates of another missing vertex can also be successfully determined based on one or two key points corresponding to the subdivided mesh.
[0116] right Figure 7 For each subdivided grid in the image, based on the pre-established correspondence between the subdivided grid and the key points of the target object, the first key point position information corresponding to the subdivided grid can be selected from the key point position information of the target object, and the second key point position information corresponding to the subdivided grid can be selected from the target key point position information.
[0117] S602a: Based on the first key point position information, generate a first grid corresponding to the subdivided grid, and based on the second key point position information, generate a second grid corresponding to the subdivided grid.
[0118] In a specific implementation, based on the first key point position information and the construction rule of the corresponding subdivided grid, the first grid corresponding to the subdivided grid can be generated. Similarly, based on the second key point position information and the construction rule of the subdivided grid, the second grid corresponding to the subdivided grid can be generated.
[0119] S603a: Paste the part of the target object corresponding to the first grid onto the second grid to obtain the target object after the shape is adjusted.
[0120] In this way, the key points corresponding to each subdivided grid are selected from the original key points and the new key points of the target object respectively, and the part of the target object corresponding to the grid constituted by the original key points is pasted onto the grid constituted by the new key points. This is equivalent to using the target object before shape adjustment to map the grid area corresponding to the target object after shape adjustment grid by grid, which is beneficial to improve the real effect and natural effect of the target object obtained after shape adjustment.
[0121] S105: Paste the modified material onto the target object after the shape adjustment to obtain a processed image.
[0122] Since the target object and the modified material have the same shape after the above steps (for example, the shape similarity is higher than a preset value such as 85%), the modified material can be attached to the target object after shape adjustment in step S105 to increase the speed of modifying the target object with the modified material.
[0123] In the disclosed embodiment, the shape of the target object is first adjusted to make it consistent with the shape of the modified material, and then the modified material is pasted onto the target object after the shape adjustment, which can not only better maintain the shape of the modified material, but also improve the fit effect between the modified material and the target object. In addition, the scheme of the disclosed embodiment is relatively simple, and the computing performance requirements of the execution subject are relatively low, so it is also more friendly to the scene of real-time image acquisition on the mobile terminal.
[0124] The following describes the solution of the embodiment of the present disclosure by taking the target object as eyebrows and the modified material as eyebrow material as an example.
[0125] Figure 8 is a schematic diagram of an eyebrow material provided by an embodiment of the present disclosure, Fig. 9 is a schematic diagram of eyebrows in an image provided by an embodiment of the present disclosure. In specific implementation, the following steps can be followed to convert Figure 8 Paste the eyebrow material shown to Fig. 9 Eyebrow position in:
[0126] Step 1: Detect the key points of eyebrows in the image and obtain the key point set P0, see Fig.10 , Fig.10 The 10 white points in the eyebrow material image (the white points at the eyebrow head and eyebrow tail are covered by black points) are the key point set P0. For the convenience of subsequent explanation, the key point set built into the eyebrow material image is recorded as P1.
[0127] Step 2: Determine the affine transformation relationship from the eyebrow material to the eyebrows in the image.
[0128] Execute for each eyebrow separately and select the following from the key point set P0: Fig.11aThe six key points shown are: key point 1 to key point 6, where key point 1 and key point 6 can be directly used as vertices, a vertex is generated based on key point 3 and key point 4, for example, the average value of the coordinates of key point 3 and key point 4 is used as the coordinate of the vertex, a vertex is generated based on key point 2 and key point 5, for example, the average value of the coordinates of key point 2 and key point 5 is used as the coordinate of the vertex, and then, for these four vertices ( Fig.11a The area formed by the four black dots in the figure is divided into two triangular areas: area 1 (the triangular area on the left) and area 2 (the triangular area on the right).
[0129] Similarly, select from the key point set P1 such as Fig.11b The six key points shown are: key point 1' to key point 6', wherein key point 1' and key point 6' can be directly used as vertices, a vertex is generated based on key point 3' and key point 4', for example, the average value of the coordinates of key point 3' and key point 4' is used as the coordinate of the vertex, a vertex is generated based on key point 2' and key point 5', for example, the average value of the coordinates of key point 2' and key point 5' is used as the coordinate of the vertex, and then, the area formed by these four vertices is divided to obtain two triangular areas: area 1' (left triangular area) and area 2' (right triangular area).
[0130] Since the number of key points of the eyebrows in the image and the eyebrow material is the same, and the positions represented by the key points are also the same, the areas divided for the target object and the modified material in the above process also correspond one to one, that is, area 1 corresponds to area 1', and area 2 corresponds to area 2'.
[0131] Furthermore, based on the position information of the vertices of region 1' and the position information of the vertices of region 1, the affine transformation matrix M1 between region 1' and region 1 is calculated (M1 is used to characterize the affine transformation relationship between region 1' and region 1), and based on the position information of the vertices of region 2' and the position information of the vertices of region 2, the affine transformation matrix M2 between region 2' and region 2 is calculated (M2 is used to characterize the affine transformation relationship between region 2' and region 2).
[0132] After the above steps, two affine transformation matrices corresponding to the left and right eyebrows can be obtained.
[0133] Step 3: Based on the affine transformation relationship between the eyebrow material and the eyebrows in the image, calculate the new key point set P2 of the eyebrows in the image.
[0134] When implementing it specifically, Fig.11b The key points corresponding to the middle area 1' (i.e., the 5 key points of the left half of the left eyebrow) can be affine transformed using the affine transformation matrix M1. Fig.11bThe key points corresponding to the middle area 2' (ie, the five key points of the right half of the left eyebrow) can be affine transformed using the affine transformation matrix M2, and the key points obtained after the radial transformation are used as a new key point set P2 of the eyebrows in the image.
[0135] In this way, different affine transformation matrices are used to perform affine transformation on the key points at different positions in the eyebrow material, and the key points after the radial transformation are used as the new key points of the eyebrows. The positions of the eyebrow head and eyebrow tail can be kept unchanged as much as possible, and the width of the eyebrows can be kept basically unchanged, so that the subsequent eyebrow material can be better attached to the eyebrow position in the image.
[0136] Fig.12 A schematic diagram of the positions of key points of eyebrows provided for the implementation of the present disclosure, wherein white points represent original key points of eyebrows in an image, and black points represent new key points of eyebrows in the image obtained after affine transformation.
[0137] Step 4: Based on the key point set P0 and the key point set P2, adjust the shape of the eyebrows in the image so that the shape of the eyebrows in the image is consistent with the shape of the eyebrow material.
[0138] In specific implementation, it can be based on Figure 7 The correspondence between each subdivided grid of the eyebrow and the key point of the eyebrow is determined, the first key point corresponding to the subdivided grid is selected from the key point set P0, and the second key point corresponding to the subdivided grid is selected from the key point set P2. Based on the position information of the first key point, the first grid corresponding to the subdivided grid is generated, and based on the position information of the second key point, the second grid corresponding to the subdivided grid is generated. Then, the part of the target object corresponding to the first grid is pasted on the second grid, thereby completing the adjustment of the eyebrow shape in the image.
[0139] Fig.13 This is a schematic diagram of an eyebrow in an image after the shape is adjusted according to an embodiment of the present disclosure, compared with Fig.13 and Fig. 9 It can be seen that the shape of the eyebrows in the image has changed significantly and is consistent with the shape of the eyebrow material.
[0140] Step 5: Paste the eyebrow material to the eyebrow position in the image.
[0141] Since the shape of the eyebrows in the image is consistent with the shape of the eyebrow material after adjustment, the eyebrow material can be directly pasted to the eyebrow position in the image as a whole to increase the modification speed while ensuring the modification effect.
[0142] Fig.14 A method for using the embodiment of the present disclosure Figure 8 Eyebrow material pair Fig. 9It can be seen that the shape of the eyebrows in the image is consistent with the shape of the eyebrow material, and the eyebrow material fits the eyebrows in the image well.
[0143] In the disclosed embodiment, before applying eyebrow makeup, the shape of the eyebrows in the image is adjusted region by region, so that the shape of the eyebrows in the image is consistent with the shape of the eyebrow material, and then the eyebrow material is pasted to the position of the eyebrows in the image, so that the eyebrows in the image can maintain the shape of the eyebrow material and the eyebrow material can be well fitted with the eyebrows in the image. In addition, the scheme of the disclosed embodiment is relatively simple, and the computing performance requirements of the execution subject are relatively low, so it is also suitable for scenes shot on a mobile terminal.
[0144] Fig.15 15 is a block diagram of an image processing device according to an exemplary embodiment, which includes an acquisition unit 1501, a determination unit 1502, a transformation unit 1503, an adjustment unit 1504 and a mapping unit 1505.
[0145] An acquiring unit 1501 is configured to acquire modified material information of a target object in an image, wherein the modified material information includes the modified material and key point position information of the modified material;
[0146] A determining unit 1502 is configured to determine a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material;
[0147] The transformation unit 1503 is configured to perform position transformation processing on the key point position information of the modified material based on the position transformation relationship to obtain target key point position information;
[0148] An adjusting unit 1504 is configured to adjust the shape of the target object by using the target key point position information as new key point position information of the target object;
[0149] The pasting unit 1505 is configured to paste the modified material onto the target object after the shape adjustment to obtain a processed image.
[0150] In some possible implementations, the determining unit 1502 is specifically configured to execute:
[0151] Based on the key point position information of the target object, N first preset key points are determined, and region division is performed based on the N first preset key points to obtain at least two first regions, where N is an integer not less than 4;
[0152] Based on the key point position information of the modified material, N second preset key points are determined, and region division is performed based on the N second preset key points to obtain at least two second regions, where the at least two second regions correspond one-to-one to the at least two first regions;
[0153] Determining a position transformation relationship between each second area and the corresponding first area;
[0154] The position transformation relationship between each second area and the corresponding first area is determined as the position transformation relationship between the modified material and the target object.
[0155] In some possible implementations, the transform unit 1503 is specifically configured to perform:
[0156] Determine a second area corresponding to each key point information of the modified material;
[0157] Based on the position transformation relationship between the second area and the corresponding first area, the key point information is subjected to position transformation processing to obtain the target key point position information.
[0158] In some possible implementations, the determining unit 1502 is specifically configured to execute:
[0159] Based on the key point position information of the target object, M third preset key points are determined, and a region is constructed based on the M third preset key points to obtain a third region, where M is an integer not less than 3;
[0160] Based on the key point position information of the modified material, M fourth preset key points are determined, and a region is constructed based on the M fourth preset key points to obtain a fourth region;
[0161] The position transformation relationship between the fourth area and the third area is determined as the position transformation relationship between the modified material and the target object.
[0162] In some possible implementations, the adjusting unit 1504 is specifically configured to perform:
[0163] Based on the correspondence between each subdivided grid of the target object and the key point of the target object, select first key point position information corresponding to the subdivided grid from the key point position information of the target object, and select second key point position information corresponding to the subdivided grid from the target key point position information;
[0164] Based on the first key point position information, a first grid corresponding to the subdivided grid is generated; based on the second key point position information, a second grid corresponding to the subdivided grid is generated;
[0165] A portion of the target object corresponding to the first grid is pasted onto the second grid to obtain the target object after the shape is adjusted.
[0166] Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment of the relevant method, and will not be elaborated here.
[0167] Fig.16 A schematic diagram of the structure of an electronic device 1600 provided in an embodiment of the present disclosure includes physical devices such as a transceiver 1601 and a processor 1602, wherein the processor 1602 may be a central processing unit (CPU), a microprocessor, a dedicated integrated circuit, a programmable logic circuit, a large-scale integrated circuit, or a digital processing unit, etc. The transceiver 1601 is used for electronic devices to send and receive data with other devices.
[0168] The electronic device may further include a memory 1603 for storing software instructions executed by the processor 1602, and of course, may also store some other data required by the electronic device, such as identification information of the electronic device, encryption information of the electronic device, user data, etc. The memory 1603 may be a volatile memory, such as a random access memory (RAM); the memory 1603 may also be a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 1603 may be any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 1603 may be a combination of the above memories.
[0169] The specific connection medium between the processor 1602, the memory 1603 and the transceiver 1601 is not limited in the embodiments of the present disclosure. Fig.16 In the example, the memory 1603, the processor 1602 and the transceiver 1601 are connected via the bus 1604. Fig.16 The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.16Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0170] The processor 1602 can be dedicated hardware or a processor that runs software. When the processor 1602 can run software, the processor 1602 reads the software instructions stored in the memory 1603 and, driven by the software instructions, executes the image processing method involved in the aforementioned embodiment.
[0171] In an exemplary embodiment, the present disclosure further provides a computer-readable storage medium, and when the instructions in the computer-readable storage medium are executed by a processor such as the processor 1602 of the electronic device 1600, any of the above-mentioned image processing methods can be executed. Optionally, the storage medium may be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0172] In some possible implementations, various aspects of the image processing method provided by the present disclosure may also be implemented in the form of a program product, which includes a program code. When the program product runs on an electronic device, the electronic device can execute the image processing method involved in the aforementioned embodiments.
[0173] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure 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 description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0174] 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 modification material information of a target object in an image, wherein the modification material information includes modification material and key point position information of the modification material, and the target object is an eyebrow or a lip; Determining a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material; Based on the position transformation relationship, position transformation processing is performed on the key point position information of the modified material to obtain target key point position information; Using the target key point position information as new key point position information of the target object, adjusting the shape of the target object; Pasting the modified material onto the target object after shape adjustment to obtain a processed image; Determining a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material includes: Based on the key point position information of the target object, M third preset key points are determined, and a region is constructed based on the M third preset key points to obtain a third region, where M is an integer not less than 3; Based on the key point position information of the modified material, M fourth preset key points are determined, and a region is constructed based on the M fourth preset key points to obtain a fourth region; The position transformation relationship between the fourth area and the third area is determined as the position transformation relationship between the modified material and the target object.
2. The method according to claim 1, characterized in that Using the target key point position information as new key point position information of the target object, adjusting the shape of the target object, includes: Based on the correspondence between each subdivided grid of the target object and the key point of the target object, select first key point position information corresponding to the subdivided grid from the key point position information of the target object, and select second key point position information corresponding to the subdivided grid from the target key point position information; Based on the first key point position information, a first grid corresponding to the subdivided grid is generated; based on the second key point position information, a second grid corresponding to the subdivided grid is generated; A portion of the target object corresponding to the first grid is pasted onto the second grid to obtain the target object after the shape is adjusted.
3. An image processing device, characterized in that: include: An acquisition unit is configured to acquire modification material information of a target object in an image, wherein the modification material information includes the modification material and key point position information of the modification material, and the target object is an eyebrow or a lip; A determining unit is configured to determine a position transformation relationship between the modified material and the target object based on the key point position information of the target object and the key point position information of the modified material; A transformation unit is configured to perform position transformation processing on the key point position information of the modified material based on the position transformation relationship to obtain target key point position information; An adjusting unit is configured to adjust the shape of the target object by using the target key point position information as new key point position information of the target object; A pasting unit, configured to paste the modified material onto the target object after shape adjustment to obtain a processed image; The determining unit is specifically configured to execute: determining M third preset key points based on the key point position information of the target object, and constructing a region based on the M third preset key points to obtain a third region, where M is an integer not less than 3; Based on the key point position information of the modified material, M fourth preset key points are determined, and a fourth region is obtained by region construction based on the M fourth preset key points; the position transformation relationship between the fourth region and the third region is determined as the position transformation relationship between the modified material and the target object.
4. The device according to claim 3, characterized in that The adjustment unit is specifically configured to perform: Based on the correspondence between each subdivided grid of the target object and the key point of the target object, select first key point position information corresponding to the subdivided grid from the key point position information of the target object, and select second key point position information corresponding to the subdivided grid from the target key point position information; Based on the first key point position information, a first grid corresponding to the subdivided grid is generated; based on the second key point position information, a second grid corresponding to the subdivided grid is generated; A portion of the target object corresponding to the first grid is pasted onto the second grid to obtain the target object after the shape is adjusted.
5. 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 as claimed in claim 1 or 2.
6. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the image processing method as claimed in claim 1 or 2.
