WO2023066120A1 - Image processing method and apparatus, electronic device, and storage medium - Google Patents

Image processing method and apparatus, electronic device, and storage medium Download PDF

Info

Publication number
WO2023066120A1
WO2023066120A1 PCT/CN2022/125036 CN2022125036W WO2023066120A1 WO 2023066120 A1 WO2023066120 A1 WO 2023066120A1 CN 2022125036 W CN2022125036 W CN 2022125036W WO 2023066120 A1 WO2023066120 A1 WO 2023066120A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
adjustment
point
dimensional
processed
Prior art date
Application number
PCT/CN2022/125036
Other languages
French (fr)
Chinese (zh)
Inventor
杨瑞健
陶然
赵代平
许亲亲
Original Assignee
上海商汤智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海商汤智能科技有限公司 filed Critical 上海商汤智能科技有限公司
Publication of WO2023066120A1 publication Critical patent/WO2023066120A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks

Definitions

  • the present disclosure relates to the technical field of image processing, and in particular, to an image processing method, device, electronic equipment, and storage medium.
  • an image processing method including: acquiring an image to be processed, wherein the image to be processed includes a target object; extracting 3D key points of the target object, and determining the 3D A first correspondence between key points and vertices in the three-dimensional adjustment model; determining an adjustment result of the three-dimensional key points according to an adjustment instruction, preset deformation data of vertices in the three-dimensional adjustment model, and the first correspondence; A target image is determined according to the adjustment result of the three-dimensional key points and the image to be processed.
  • an image processing device including: an acquisition module, configured to acquire an image to be processed, wherein the image to be processed includes a target object; a first corresponding module, configured to extract the The three-dimensional key points of the target object, and determine the first corresponding relationship between the three-dimensional key points and the vertices in the three-dimensional adjustment model; the adjustment module is used to adjust according to the adjustment instruction, the preset deformation data of the vertices in the three-dimensional adjustment model and The first correspondence is used to determine an adjustment result of the 3D key point; a target module is configured to determine a target image according to the adjustment result of the 3D key point and the image to be processed.
  • an electronic device the device includes a memory and a processor, the memory is used to store computer instructions that can be run on the processor, and the processor is used to execute the The computer instructions implement the method described in the first aspect.
  • a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the method described in the first aspect is implemented.
  • a computer program product includes a computer program, and when the program is executed by a processor, the method described in the first aspect is implemented.
  • FIG. 1 is a flowchart of an image processing method according to an embodiment of the present disclosure
  • Fig. 2 is a schematic diagram of an interactive interface shown according to an embodiment of the present disclosure
  • Fig. 3 is a schematic diagram of a face standard model shown according to an embodiment of the present disclosure.
  • Fig. 4 is a flow chart of determining a first correspondence according to an embodiment of the present disclosure
  • Fig. 5 is a flowchart showing a method of determining a target image according to an embodiment of the present disclosure
  • FIG. 6 is a flowchart of an image processing method according to another embodiment of the present disclosure.
  • Fig. 7 is a schematic diagram of an integrated model shown according to an embodiment of the present disclosure.
  • Fig. 8 is a schematic structural diagram of an image processing device according to an embodiment of the present disclosure.
  • Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
  • first, second, third, etc. may be used in the present disclosure to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of the present disclosure, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word “if” as used herein may be interpreted as “at” or “when” or “in response to a determination.”
  • the product applying the disclosed technical solution has clearly informed the user of the information processing rules and obtained the user's independent consent before processing the user information.
  • the product applying the disclosed technical solution has obtained the separate consent of the user before processing the sensitive user information, and at the same time meets the requirement of "express consent". For example, at the user information collection device such as a camera, set a clear and prominent sign to inform that the user information has entered the collection range, and the user information will be collected.
  • the user information processing rules may include user Information processor, user information processing purpose, processing method, type of user information processed and other information.
  • At least one embodiment of the present disclosure provides an image processing method. Please refer to FIG. 1 , which shows the flow of the method, including steps S101 to S104.
  • the method can be used to process the image to be processed, for example, the target object in the image to be processed can be adjusted, and the target object can be, for example, at least one of the following objects in the image to be processed: face, hand, limb, adjusted
  • the items can be shape, size, position, etc.
  • the facial information of the face that is, the shape, size, proportion, etc. of the facial features, can be adjusted, so as to complete the enhancement processing such as face beautification, micro-shaping, and body shaping.
  • the image to be processed may be an image captured by the image acquisition device, or a frame of image in a video recorded by the image acquisition device. It can be understood that, by using the method provided by the embodiment of the present disclosure to process each frame of image in the video recorded by the image acquisition device, the processing of the video can be completed.
  • the method can be executed by electronic devices such as terminal equipment or servers, and the terminal equipment can be user equipment (User Equipment, UE), mobile equipment, terminal, cellular phone, cordless phone, personal digital assistant (Personal Digital Assistant, PDA) handheld device, computing device, vehicle-mounted device, wearable device, etc.
  • the method can be realized by calling a computer-readable instruction stored in a memory by a processor.
  • the method may be executed by a server, and the server may be a local server, a cloud server, or the like.
  • step S101 an image to be processed is acquired, wherein the image to be processed includes a target object.
  • the image to be processed may be an image taken by an image acquisition device, or a frame image in a video recorded by the image acquisition device, wherein the image acquisition device may be an electronic device with an image acquisition function such as a mobile phone or a camera.
  • the target object is the image of a specific object in the real scene in the image, for example, it can be the face in the image to be processed (that is, the image of the face in the image), the hand (that is, the hand in the image The resulting image), etc.
  • the image captured by the image acquisition device can be identified. If the image contains the target object, the image is acquired as the image to be processed. If the image does not contain the target object, the image is not regarded as the image to be processed; correspondingly, the The video recorded by the image acquisition device is identified. If a frame of image contains the target object, the frame of image is acquired as the image to be processed. If a frame of image does not contain the target object, the frame of image is not regarded as the image to be processed.
  • the user uses a mobile phone to record a video.
  • a face sometimes appears in the screen, and sometimes there is no face.
  • Image frames with no faces in the video frame are not treated as images to be processed for beautification processing, thereby ensuring real-time beautification processing of faces in the video screen, and reducing processor load when there are no faces in the video screen , save energy consumption, and avoid mishandling of video images.
  • step S102 the 3D key points of the target object are extracted, and a first corresponding relationship between the 3D key points and vertices in the 3D adjustment model is determined.
  • the depth image corresponding to the image to be processed can be obtained, and the image after the image to be processed is aligned with the depth image can be input into the pre-trained deep neural network.
  • Perform 3D keypoint detection While the image acquisition device acquires the image to be processed, it can start the structured light sensor of the camera of the image acquisition device to acquire the depth image, or use Time of Flight (ToF) sensing technology to acquire the depth image.
  • TOF Time of Flight
  • each detected 3D key point has an identifier.
  • the identifier of each 3D key point may be a sequence identifier.
  • the detection can be performed according to the characteristics of the target object or detection requirements, that is, whether to detect a certain position of the target object, and to detect several 3D key points can be preset in advance.
  • three-dimensional key point detection can be performed on facial features and other key positions. These key positions have signs such as eyes, mouth, eyebrows, nose, etc., so the detected three-dimensional key points is identified.
  • the three-dimensional adjustment model is used to represent the adjustment method of each adjustment item of the target object.
  • the three-dimensional adjustment model of the face may include a beauty model, which is used to represent various beauty items (such as thin face, big eyes, small mouth, etc.) way of beauty.
  • the 3D adjustment model can be composed of multiple vertices and the mesh structure between the vertices.
  • the vertices of the 3D adjustment model can also correspond to the 3D key points of the target object, and the multiple vertices of the 3D adjustment model are also identified.
  • the 3D adjustment Multiple vertices of the model have order, and the identification of each vertex can be order identification.
  • the order of the multiple vertices may be the same as or different from the order of the three-dimensional key points detected above.
  • the relationship between the 3D key point and the vertices in the 3D adjustment model is established.
  • the first correspondence is to correspond the 3D key points at the same key position with the vertices in the 3D adjustment model.
  • step S103 the adjustment result of the three-dimensional key points is determined according to the adjustment instruction, the preset deformation data of vertices in the three-dimensional adjustment model, and the first corresponding relationship.
  • the three-dimensional adjustment model may also store preset deformation data of each vertex, such as displacement data of the vertex when each adjustment item is performed.
  • preset deformation data can be recorded in the form of an array, and an array is created for each vertex, and the three-dimensional coordinates of the vertex are first recorded in the array, and then the displacement data of the vertex under each adjustment item is sequentially recorded.
  • the coordinate information of the 3D key points corresponding to the vertices in the 3D adjustment model can be converted into the coordinate system of the 3D adjustment model, and the converted 3D key points The coordinates of the vertex are added to the array of the vertex, so as to facilitate the subsequent calculation when adjusting the 3D key points.
  • the adjustment instruction can be generated according to the user's operation, for example, if the user selects at least one adjustment item, an adjustment instruction for the at least one adjustment item is generated; the adjustment instruction can also be automatically generated by the terminal executing the method.
  • the target object is a face
  • the user may select at least one adjustment item for the face, so as to generate an adjustment instruction corresponding to the at least one adjustment item.
  • at least one adjustment item may be set in advance, and then an adjustment instruction corresponding to the at least one adjustment item is automatically generated each time an image to be processed is acquired.
  • the adjustment process of the three-dimensional key points includes the position adjustment process of the three-dimensional key points, so the adjustment result of the three-dimensional key points includes the adjusted three-dimensional key points.
  • the adjustment item of the target object may be determined according to the adjustment instruction, and the preset deformation data of the vertices in the three-dimensional adjustment model corresponding to the adjustment item may be obtained.
  • the first deformation data According to the first deformation data, the three-dimensional key point corresponding to at least one vertex in the three-dimensional adjustment model is displaced, so as to obtain the adjustment result of the three-dimensional key point.
  • the adjustment items include adjustment position and adjustment type.
  • the adjustment position refers to the local position of the target object, such as a facial feature in the face
  • the adjustment type refers to the expected adjustment result, such as reducing, increasing, and rounding.
  • the target object is a face
  • the adjustment position is eyes
  • the adjustment type is enlarged
  • the adjustment item is small mouth
  • the adjustment position is mouth
  • the adjustment type is reduced, etc.
  • FIG. 2 it has shown the interactive interface of a face adjustment, has adjustment items such as thin face, big eyes, small head, rhinoplasty and small mouth etc. in this interface, after the user selects at least one adjustment item among them, then generate Contains the adjustment command for this adjustment item.
  • one adjustment item is determined, and if there are multiple adjustment items in the adjustment instruction, multiple adjustment items are determined.
  • the first deformation data includes displacement data of each vertex of the three-dimensional adjustment model under the adjustment item.
  • Each vertex can be traversed to obtain the deformation data of each vertex corresponding to the adjustment item in the adjustment instruction, that is, the displacement data of all vertices under the adjustment item.
  • the adjustment instruction includes, for example, the big eye item 202 in FIG. 2
  • traverse each vertex corresponding to the adjustment item and obtain the deformation data of the eye vertices (for example, the number of eye vertices of E1, E2, E3, and E4) in the three-dimensional adjustment model of the big eye project
  • the three-dimensional adjustment Other vertices in the model such as mouth vertices and nose vertices, do not have deformation data.
  • each vertex stores the displacement data under each adjustment item in the form of an array
  • the displacement data can be obtained according to the corresponding position of the adjustment item to the array.
  • the array of E1 is [0 ,1,0.2,0.1,0]
  • the first to fifth data positions in the array are the displacement data 0 of E1 under the thin face item 201, the displacement data 1 of E1 under the big eye item 202, and the small head
  • the displacement data of E1 under item 203 is 0.2
  • the displacement data of E1 under item 204 of rhinoplasty is 0.1
  • the displacement data of E1 under item 205 of small mouth is 0, then when the adjustment item is big eyes, it can be directly obtained from the second part of the E1 array.
  • the displacement data 0.2 corresponding to the big-eye item 202 is obtained from the position.
  • the displacement data corresponding to the big-eye item can be obtained from the second positions of the E2, E3, and E4 arrays respectively.
  • the deformation data corresponding to the adjustment item is obtained directly.
  • the deformation data (displacement data) of vertices E1-E4 corresponding to the big eye item are directly obtained.
  • the deformation data corresponding to each adjustment item may be acquired.
  • the three-dimensional adjustment model also stores displacement data corresponding to various combinations of adjustment items, so when there are multiple adjustment items in the adjustment instruction, multiple adjustment items can be directly obtained.
  • the displacement data corresponding to the combination of adjustment items is obtained directly.
  • the deformation data corresponding to the face-lifting item 201 is obtained directly;
  • the deformation data corresponding to the deformation data of the large-eye item 202 and the deformation data corresponding to the combination of the thin-face item 201 and the large-eye item 202 can also be obtained.
  • the adjustment command includes the adjustment items, it can also include the adjustment parameter values of each adjustment item.
  • the adjustment parameter value can be the adjustment degree of the adjustment item. Different adjustment degrees can correspond to different deformation data. For example, when the adjustment degree is 100%, the deformation data is the maximum deformation data corresponding to the adjustment item, and the adjustment degree is 60%. , the deformation data is 60% of the maximum deformation data corresponding to the adjustment item.
  • the adjustment of the adjustment items can be further determined according to the adjustment instruction. parameter value, and then adjust the first deformation data according to the adjusted parameter value.
  • the degree of the adjustment item can be adjusted by adjusting the parameter value, which increases the flexibility and diversity of the adjustment.
  • the coordinates of the three-dimensional key points corresponding to the vertices of the three-dimensional adjustment model and the displacement data corresponding to the vertices of the three-dimensional adjustment model can be calculated to obtain the adjustment result of the three-dimensional key points. Under one or more adjustment items, if the displacement data of at least one vertex is not 0, the 3D key points corresponding to these vertices will be displaced after the operation.
  • the preset deformation data is recorded in the form of an array, and after the first corresponding relationship is determined, the coordinate information of the 3D key point corresponding to the vertex is converted into the coordinate system of the 3D adjustment model, and the converted 3D When the coordinate information of the key point is added to the array of the vertex, the coordinate and displacement data of the three-dimensional key point can be directly extracted from the array of each vertex.
  • each displacement data can be used in sequence according to the three-dimensional key point corresponding to the vertex. Coordinates are calculated.
  • the displacement data of the eye vertex E1 is [0.2,0.1,1]
  • you can follow the order in the adjustment command such as small head item, nose augmentation
  • the displacement data of E1 corresponding to the project and the big-eye project can be used to calculate the coordinates of the three-dimensional key points corresponding to E1; or the displacement data corresponding to the big-eye project, small-head project and nose augmentation project can also be calculated according to the order in the E1 array.
  • the coordinates of the 3D key points corresponding to E1 are calculated.
  • the positions of the three-dimensional key points are adjusted, and the three-dimensional key points at the new positions are the adjusted three-dimensional key points in the adjustment result of the three-dimensional key points.
  • step S104 a target image is determined according to the adjustment result of the 3D key points and the image to be processed.
  • the same adjustment is performed on the corresponding position of the image to be processed, that is, the adjustment result is mapped to the image to be processed, thereby completing the adjustment of the target object in the image to be processed.
  • the target object is a facial image
  • the beautification process on the facial image can be completed in this step.
  • the vertices in the three-dimensional adjustment model by acquiring the image to be processed, and extracting the three-dimensional key points of the target object in the image to be processed, determining the first corresponding relationship between the three-dimensional key points and the vertices in the three-dimensional adjustment model, according to the adjustment instruction, the vertices in the three-dimensional adjustment model.
  • the preset deformation data and the first corresponding relationship determine the adjustment result of the three-dimensional key point, and determine the target image according to the adjustment result of the three-dimensional key point and the image to be processed.
  • the adjustment of the target object is to adjust the 3D key points according to the adjustment instruction and the preset deformation data, so the adjustment process is more precise and controllable , and the three-dimensional key points are extracted from the image to be processed, and finally the adjustment result obtained by adjusting the three-dimensional key points is returned to the image to be processed, so the adjustment effect of the target object in the obtained target image is natural and real, which improves the user satisfaction.
  • the image processing method further includes: acquiring a second corresponding relationship between vertices in the three-dimensional adjustment model and vertices in the three-dimensional standard model.
  • the three-dimensional standard model is the standard model of the target object, which is composed of multiple vertices and meshes between the vertices.
  • the three-dimensional standard model may be a standard facial model as shown in FIG. 3 . If the 3D key points are extracted from the 3D standard model, all vertices of the 3D standard model can be obtained.
  • the three-dimensional adjustment model is used to characterize the specific adjustment manner of at least one adjustment item of the three-dimensional standard model, that is, the three-dimensional adjustment model includes deformation data of each vertex of the three-dimensional standard model in at least one adjustment item.
  • the 3D adjustment model has a dedicated model coordinate system.
  • the coordinates of each vertex in the 3D adjustment model are the coordinates in the coordinate system of the 3D adjustment model.
  • the 3D adjustment model can also use the coordinate transformation matrix to coordinate the coordinates of the 3D adjustment model in the coordinate system Transform to the world coordinate system.
  • the three-dimensional adjustment model may be obtained by performing preset deformations respectively corresponding to at least one adjustment item on the three-dimensional standard model.
  • the coordinates of the vertices in the three-dimensional adjustment model and the coordinates of the vertices in the three-dimensional standard model can be converted into the same coordinate system, for example, the coordinates of the vertices in the three-dimensional standard model are coordinates in the world coordinate system, then
  • the coordinate transformation matrix of the three-dimensional adjustment model can be multiplied by the coordinates of the vertices in the three-dimensional adjustment model, so as to convert the coordinates of the vertices of the three-dimensional adjustment model to the world coordinate system.
  • the coordinates of the vertices in the converted three-dimensional adjustment model and the three-dimensional standard model The coordinates of vertices are all in the world coordinate system.
  • the distance threshold is to determine whether the two vertices are corresponding, that is, if the Euclidean distance is less than the distance threshold, then the two points are corresponding, otherwise they are not.
  • the first corresponding relationship between the 3D key points and the vertices in the 3D adjustment model may be determined as shown in FIG. 4 , including steps S401 to S402.
  • step S401 according to the identification of the 3D key point and the identification of the vertex in the 3D standard model, a third corresponding relationship between the 3D key point and the vertex in the 3D standard model is determined.
  • the setting logic of the key points of the standard object and the target object in the 3D standard model is the same, for example, they all include eyebrows, eyes, nose, mouth , therefore, when the position of the vertex in the target object in the 3D standard model generated based on the standard face image is the same as the position of the 3D key point in the target object, then the vertex in the 3D standard model and the identity of the 3D key point are the same , so the same three-dimensional key point and the vertices of the three-dimensional standard model are determined as pairs of vertices corresponding to each other, and the third corresponding relationship is obtained.
  • the order of the vertices of the three-dimensional standard model is consistent with the order of the three-dimensional key points of the target object, and the order of the same three-dimensional key points and the vertices of the three-dimensional standard model can be determined as a pair of vertices corresponding to each other, and the described third correspondence.
  • step S402 the first correspondence is determined according to the second correspondence and the third correspondence.
  • the vertices of the 3D adjustment model corresponding to the same vertex of the 3D standard model and the 3D key points are determined as corresponding to each other.
  • the 3D key is determined according to the third corresponding relationship between the 3D key point and each vertex of the 3D standard model.
  • the first corresponding relationship between the point and each vertex of the three-dimensional adjustment model can also be directly used to determine the first corresponding relationship between the 3D key points and the vertices of the 3D adjustment model, which is simple, convenient, accurate and reliable, and avoids the For the 3D key points of the target object of each image to be processed, complex operations such as Euclidean distance calculation are performed.
  • the target image may be determined according to the adjustment result of the three-dimensional key points and the image to be processed as shown in FIG. 5 , including steps S501 to S502.
  • step S501 a first grid is constructed between the adjustment results of the three-dimensional key points according to a pre-established first topology structure.
  • the pre-established first topology refers to the connection relationship of the vertices in the grid among the vertices of the 3D standard model, for example, which other vertices need to be connected to each vertex of the 3D standard model.
  • the first topological structure is recorded with the identification of vertices.
  • the identification of the three-dimensional key point corresponds to the identification of the vertices of the three-dimensional standard model one by one, and the third corresponding relationship between the three-dimensional key point and the vertices of the three-dimensional standard model is established in step S401, when at least one three-dimensional key point is displaced Finally, the identification of each 3D key point is still clear, and the corresponding relationship between each 3D key point and each vertex of the 3D standard model is still clear, and then the adjustment results of different 3D key points can be connected according to the first topology structure to construct the second a grid.
  • a target model of the target object is formed.
  • step S502 according to the pixel information of the projection point of the 3D key point on the image to be processed, the coordinate information of the projection point of the adjustment result of the 3D key point on the image to be processed, and the first A grid, rendering the adjustment result of the target object on the image to be processed to obtain a target image.
  • the pixel information of the projection point of the three-dimensional key point on the image to be processed can be extracted as the pixel information of the three-dimensional key point, wherein the pixel information includes, for example, RGB values, etc.
  • the three-dimensional key point is on the image to be processed
  • the pixel information of the projection point of the three-dimensional key point is unchanged before and after the three-dimensional key point adjustment, so the pixel information of the projection point of the three-dimensional key point on the image to be processed can also be used as the pixel of the three-dimensional key point adjustment result information; according to the pixel information of the adjustment result of the three-dimensional key point, render the first grid to obtain the pixel information in the first grid; according to the adjustment result of the three-dimensional key point in the image to be processed
  • the coordinate information of the projected point on the above, and the pixel information of the three-dimensional key point and the pixel information in the first grid are projected onto the image to be processed to obtain the target image. For example, if the target object is a facial image, then the
  • certain positions of the target object in the target image are adjusted, for example, the eyes in the face in the image to be processed become larger, the mouth becomes smaller, etc.
  • These adjustments change the pixels in the image, such as eyes When it becomes larger, the pixel points of the eye part are displaced, the number increases, and the shape composed of all the pixel points of the eye changes.
  • the pixel points are not directly adjusted on the two-dimensional image to be processed, but the pixel points on the image to be processed are adjusted by adjusting the three-dimensional key points extracted from the two-dimensional image to be processed. .
  • the 3D key point corresponds to its projection point on the image to be processed
  • the adjustment result of the 3D key point can be used to represent the adjustment result of the 3D key point corresponding to the projection point on the image to be processed, that is, the projection point of the projection point
  • the position adjustment of the pixel point can be, for example, extracting the pixel information of the projection point of the three-dimensional key point on the image to be processed, and re-projecting the pixel information to the adjustment result of the three-dimensional key point on the projection point of the image to be processed.
  • the first grid includes a plurality of closed sub-grids, and these sub-grids are surrounded by at least three three-dimensional key points.
  • the pixel information in each sub-grid can be rendered as the Pixel information of three 3D keypoints.
  • the image to be processed can be rendered on the output image first, for example, through an image copy operation of a rendering API such as OpenGL, the image to be processed can be copied to the output image, that is, as the background of the target image, wherein the output image includes The pixel information of the three-dimensional key points and the projection of the pixel information in the first grid on the two-dimensional plane; the image to be processed is used as the input image of the rendering process, and the coordinates of the projection points of each three-dimensional key point on the image to be processed are used as Input the texture sampling coordinates of the image, so that the pixel information of the projection point of the 3D key point on the image to be processed can be extracted.
  • a rendering API such as OpenGL
  • the pixel information of the 3D key point can be used as the pixel information of the adjustment result of the 3D key point; through the model transformation matrix of the 3D adjustment model, the coordinates of the adjustment result of the 3D key point are converted to the world coordinate system, and then through the transformation matrix from the world coordinate system to the clipping space, Convert the coordinates of the adjustment results of the 3D key points in the world coordinate system to the clipping coordinate system, and send them to the subsequent fragment rendering stage, that is, render the pixel information in the first grid according to the pixel information of the adjustment results of the 3D key points, And rendering the adjustment result of the three-dimensional key point and the pixel information in the first grid on the output image, so as to render the adjustment result of the target object on the image to be processed, and obtain the target image.
  • the first grid is constructed between the adjustment results of each three-dimensional key point to form the target model of the target object; and then the pixel information of the adjustment result of the three-dimensional key point is extracted, and the first grid
  • the rendering of pixel information is to paste pixel information on the target model, and finally render the target model with pixel information to the output image to obtain the final target image.
  • the image may also be processed in the manner shown in FIG. 6 , including steps S601 to S602.
  • step S601 generate a 3D extended model surrounding the 3D key point, wherein the vertices in the 3D extended model include the adjustment result of the first edge point and the second edge point obtained based on the extension of the first edge point , the first edge point is a three-dimensional key point corresponding to the boundary of the target object.
  • the first edge point corresponding to the boundary of the target object among the three-dimensional key points may be obtained first.
  • the projection point of the three-dimensional key point in the image to be processed is obtained; according to the projection point of the target object and the three-dimensional key point in the image to be processed, determine the target object A projection point on the boundary: determining a 3D key point corresponding to the projection point on the boundary of the target object as the first edge point.
  • a plurality of straight lines can be set in the preset direction in the image to be processed, for example, a plurality of horizontal straight lines can be set in advance, and then projected on the basis of the three-dimensional key points The points on the plurality of straight lines are determined to determine the projected points on the boundary of the target object.
  • this step it may be determined on the extension line of the line between the central point of all the three-dimensional key points (for example, the central point of the target object, for example, located on the nose) and the first edge point, and determine the connection with the first edge point.
  • a point at which the edge points are separated by a preset distance is a second edge point corresponding to the first edge point.
  • the calculation may be performed according to the coordinate information of each 3D key point, so as to obtain the center point among the multiple 3D key points, that is, the 3D key point located at the center of the target object. Then construct a straight line between the center point and each edge point of the target object, and further extend the preset distance outward on the straight line (the distance can be preset in advance and can be set according to the size of the target object, for example, for the target object 1/10 of the width), then the vertex of the extension line is the second edge point corresponding to the edge point.
  • a second grid may be constructed between the adjustment result of the first edge point and the second edge point according to the second pre-established topological structure, so as to obtain the three-dimensional extended model.
  • the pre-established second topology refers to the connection relationship of points in the grid between multiple first edge points and multiple second edge points, for example, which other points each point needs to be connected to.
  • all the first edge points are connected sequentially to form the inner circle of the 3D extended model; all the second edge points are connected sequentially to form the outer circle of the 3D extended model; then each first edge point and its corresponding second
  • the edge points are connected with a line, and the first edge point and the second edge point next to the corresponding second edge point are also connected with a line, thereby forming a second grid in the three-dimensional extended model.
  • the second topology is recorded in the order of the first edge point and the second edge point, so after the first edge point is adjusted, the second grid can still be constructed according to the topology.
  • the three-dimensional extended model is a model that surrounds the three-dimensional key points located on the contour of the target object.
  • the outer circle of the model ie, the circle surrounded by the second edge point
  • the inner circle of the model ie, The circle surrounded by the first edge point
  • the target model of the target object is formed.
  • a 3D extended model is added around the target model, and the target model and the 3D extended model pass through the first edge point
  • FIG. 7 shows a schematic diagram of an integrated model when the target object is a face.
  • step S602 the 3D extended model is rendered on the image to be processed according to the 3D extended model and the image to be processed.
  • the pixel information of the projection point of the first edge point on the image to be processed can be extracted. Since the pixel information of the first edge point is unchanged before and after the adjustment of the first edge point, the first edge point is The pixel information of the projection point on the image to be processed may also be used as the pixel information of the adjustment result of the first edge point; the pixel information of the projection point of the second edge point on the image to be processed is extracted as The pixel information of the second edge point; according to the pixel information of the adjustment result of the first edge point and the pixel information of the second edge point, render the second grid to obtain the second grid pixel information; according to the adjustment result of the first edge point and the coordinate information of the projection point of the second edge point on the image to be processed, the pixel information of the adjustment result of the first edge point, the The pixel information of the second edge point and the pixel information in the second grid are projected onto the image to be processed.
  • step S602 can be executed with reference to the operation in step S502.
  • a three-dimensional extended model can be constructed around the target model according to the method provided in this embodiment to obtain a comprehensive model, and then the comprehensive model can be operated according to the operation method introduced in step S502, so that the The target object and surrounding images are projected onto the image to be processed to obtain the target image.
  • the three-dimensional extension by determining the second edge points surrounding the target model composed of three-dimensional key points, and further determining the three-dimensional extension model, the three-dimensional extension The adjusted results of the model are projected onto the image to be processed. Since the outer ring of the 3D extended model has not been adjusted, the connection between the area corresponding to the 3D extended model and the surrounding area in the target image is relatively natural, and there is no abrupt connection; and although the inner ring of the 3D extended model has been adjusted Yes, but the pixel information in the second grid in the 3D extended model is rendered, so the connection between the area corresponding to the 3D extended model in the target image and the area corresponding to the target object is relatively natural, and there will be no abrupt connection .
  • the outside of the integrated model including the target model and the 3D extended model has not been adjusted, so the edge area of the entire integrated model on the target image is the same as the corresponding area on the image to be processed; while the inside of the integrated model (target model) After adjustment, the adjusted target model can overcome the uncoordinated and unnatural problems caused by the adjustment because the pixel information of the pixels in each sub-grid is the same during the rendering process, so this part (comprehensive model The corresponding region on the target object is also natural.
  • the vertices in the three-dimensional adjustment model and the vertices in the three-dimensional standard model all include, for example, the identification of the reflection order, and each vertex of the three-dimensional adjustment model also records an array representing preset deformation data corresponding to different adjustment items; extraction to be processed
  • the three-dimensional key points of the face in the image wherein each three-dimensional key point includes, for example, an identification reflecting the order, and a third corresponding relationship is established between the three-dimensional key points with the same identification and the vertices in the three-dimensional standard model, according to the second corresponding relationship and the third
  • the corresponding relationship is to establish a first corresponding relationship between the 3D key point and the vertex in the 3D adjustment model
  • At least one 3D key point is moved according to currently set adjustment items (such as big eyes, thin face, etc.) and adjustment parameter values (ie, adjustment degree), that is, deformation data of vertices in the 3D adjustment model.
  • adjustment items such as big eyes, thin face, etc.
  • adjustment parameter values ie, adjustment degree
  • the array of each vertex in the three-dimensional adjustment model can be traversed, and the deformation data of the vertex under the adjustment item is multiplied by the adjustment parameter value to obtain the displacement data of the vertex, and the displacement data of the vertex is used to compare
  • the three-dimensional key points corresponding to the array are displaced, and the displacement results of the three-dimensional key points are obtained. Then construct the first grid between the displacement results of the three-dimensional key points, and connect the first grid and the second grid as a whole through the first edge point to obtain a comprehensive model.
  • the image to be processed is pasted on the integrated model, and then the integrated model is rendered on the image to be processed to obtain the target image for presenting the face adjustment effect.
  • the image to be processed can be rendered on the output image first, for example, the image to be processed can be copied to the output image through an image copy operation of a rendering API such as OpenGL; then the image to be processed can be used as the input image of the rendering process , the coordinates of the projection points of each 3D key point on the image to be processed are taken as the texture sampling coordinates of the input image; the coordinates of the adjustment results of the 3D key points are converted to the world coordinate system through the model transformation matrix of the 3D adjustment model, and the world The transformation matrix from the coordinate system to the clipping space converts the coordinates of the adjustment results of the 3D key points in the world coordinate system to the clipping coordinate system, and sends them to the subsequent fragment rendering stage to realize the presentation of the real-time 3D adjustment effect.
  • a rendering API such as OpenGL
  • an image processing device is provided. Please refer to FIG.
  • the processed image includes the target object; the first correspondence module 802 is used to extract the 3D key points of the target object, and determine the first correspondence between the 3D key points and the vertices in the 3D adjustment model; the adjustment module 803 uses Determine the adjustment result of the 3D key point according to the adjustment instruction, the preset deformation data of the vertices in the 3D adjustment model and the first corresponding relationship; the target module 804 is used to determine the adjustment result of the 3D key point according to the adjustment result and the image to be processed to determine a target image.
  • a second corresponding module is also included, configured to: obtain a second corresponding relationship between the vertices in the 3D adjustment model and the vertices in the 3D standard model; the first corresponding module is configured to: According to the identification of the 3D key point and the identification of the vertex in the 3D standard model, determine the third corresponding relationship between the 3D key point and the vertex in the 3D standard model; according to the second corresponding relationship and the vertex in the 3D standard model The third corresponding relationship is determined, and the first corresponding relationship is determined.
  • the second corresponding module is used to: convert the coordinates of vertices in the three-dimensional adjustment model and the coordinates of vertices in the three-dimensional standard model into the same coordinate system; according to the The Euclidean distance between each vertex in the three-dimensional adjustment model and each vertex in the three-dimensional standard model is used to determine the second corresponding relationship.
  • the first corresponding module is configured to determine the 3D key point and the vertex in the 3D standard model according to the identification of the 3D key point and the identification of the vertex in the 3D standard model For the third corresponding relationship, it is used to: determine the same 3D key point and the vertices of the 3D standard model as a pair of vertices corresponding to each other, so as to obtain the third corresponding relationship.
  • the adjustment module is configured to: determine the adjustment item of the target object according to the adjustment instruction; obtain the preset deformation data of the vertex in the three-dimensional adjustment model, which corresponds to the adjustment item First deformation data: Displacing the 3D key point corresponding to at least one vertex in the 3D adjustment model according to the first deformation data, to obtain an adjustment result of the 3D key point.
  • the adjustment module is further configured to: determine the adjustment parameter value of the adjustment item according to the adjustment instruction before obtaining the adjustment result of the three-dimensional key point; The first deformation data is adjusted.
  • the target module is configured to: construct a first grid between the adjustment results of the 3D key points according to a pre-established first topology structure; The pixel information of the projection point on the image to be processed, the coordinate information of the projection point of the adjustment result of the three-dimensional key point on the image to be processed, and the first grid, and render the image on the image to be processed The adjustment result of the target object is obtained to obtain the target image.
  • the target module is further configured to: extract the pixel information of the projection point of the 3D key point on the image to be processed, as the pixel information of the adjustment result of the 3D key point; Rendering the first grid according to the pixel information of the adjustment result of the three-dimensional key point to obtain pixel information in the first grid; according to the adjustment result of the three-dimensional key point on the image to be processed Projecting the coordinate information of the point, projecting the pixel information of the three-dimensional key point and the pixel information in the first grid onto the image to be processed to obtain the target image.
  • an extension module configured to: generate a 3D extended model surrounding the 3D key point, wherein the vertices in the 3D extended model include the adjustment result of the first edge point and based on the The second edge point obtained by extending the first edge point, the first edge point is a three-dimensional key point corresponding to the boundary of the target object; according to the three-dimensional extended model and the image to be processed, in the to-be-processed The three-dimensional extended model is rendered on the image.
  • the expansion module is further configured to: obtain the first edge point; on an extension line of a line connecting the center point of the three-dimensional key point and the first edge point, Determining a point at a preset distance from the first edge point as the second edge point; according to a pre-established second topology, between the adjustment result of the first edge point and the second edge point Construct the second grid to obtain the 3D extended model.
  • the extension module is further configured to: obtain the projection point of the 3D key point in the image to be processed; according to the target object and the 3D key point in the image to be processed The projection point in the image is determined as the projection point on the boundary of the target object; and the three-dimensional key point corresponding to the projection point on the boundary of the target object is determined as the first edge point.
  • the expansion module is further configured to: set a plurality of straight lines in preset directions in the image to be processed; points, determine the projected points that lie on the boundary of the target object.
  • the extension module is further configured to: extract pixel information of a projection point of the first edge point on the image to be processed, as a pixel of the adjustment result of the first edge point information, and extract the pixel information of the projection point of the second edge point on the image to be processed as the pixel information of the second edge point; according to the pixel information of the adjustment result of the first edge point and the pixel information of the second edge point, render the second grid, and obtain pixel information in the second grid; according to the adjustment result of the first edge point and the second edge point in the Processing the coordinate information of the projection point on the image, projecting the pixel information of the adjustment result of the first edge point, the pixel information of the second edge point, and the pixel information in the second grid to the waiting processing image.
  • the target object includes at least one of the following objects in the image to be processed: face, hand, and limb.
  • At least one embodiment of the present disclosure provides a device. Please refer to FIG. 9 , which shows the structure of the device.
  • the device includes a memory 904, a processor 901, and a network interface 903. Coupled with 902, the memory is used to store computer instructions that can be run on a processor, and the processor is used to process the image based on the method described in any one of the first aspect when executing the computer instructions.
  • At least one embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the first aspect is implemented.
  • At least one embodiment of the present disclosure provides a computer program product, the product includes a computer program, and when the computer program is executed by a processor, the method described in any one of the first aspect is implemented
  • This disclosure relates to the field of augmented reality.
  • acquiring the image information of the target object in the real environment and then using various visual correlation algorithms to detect or identify the relevant features, states and attributes of the target object, and thus obtain the image information that matches the specific application.
  • AR effect combining virtual and reality.
  • the target object may involve faces, limbs, gestures, actions, etc. related to the human body, or markers and markers related to objects, or sand tables, display areas or display items related to venues or places.
  • Vision-related algorithms can involve visual positioning, SLAM, 3D reconstruction, image registration, background segmentation, object key point extraction and tracking, object pose or depth detection, etc.
  • Specific applications can not only involve interactive scenes such as guided tours, navigation, explanations, reconstructions, virtual effect overlays and display related to real scenes or objects, but also special effects processing related to people, such as makeup beautification, body beautification, special effect display, virtual Interactive scenarios such as model display.
  • the relevant features, states and attributes of the target object can be detected or identified through the convolutional neural network.
  • the above-mentioned convolutional neural network is a network model obtained by performing model training based on a deep learning framework.
  • first and second are used for descriptive purposes only, and should not be understood as indicating or implying relative importance.
  • plurality means two or more, unless otherwise clearly defined.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The present invention relates to an image processing method and apparatus, an electronic device, and a storage medium. The image processing method comprises: obtaining an image to be processed, wherein the image to be processed comprises a target object; extracting three-dimensional key points of the target object, and determining first correspondences between the three-dimensional key points and vertexes in a three-dimensional adjustment model; determining adjustment results of the three-dimensional key points according to an adjustment instruction, preset deformation data of the vertexes in the three-dimensional adjustment model, and the first correspondences; and determining a target image according to the adjustment results of the three-dimensional key points and the image to be processed.

Description

图像处理方法、装置、电子设备及存储介质Image processing method, device, electronic device and storage medium
相关申请交叉引用Related Application Cross Reference
本申请主张申请号为202111222848.5、申请日为2021年10月20日的中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application claims the priority of the Chinese patent application with the application number 202111222848.5 and the filing date of October 20, 2021. The entire content of the Chinese patent application is hereby incorporated by reference into this application.
技术领域technical field
本公开涉及图像处理技术领域,尤其涉及一种图像处理方法、装置、电子设备及存储介质。The present disclosure relates to the technical field of image processing, and in particular, to an image processing method, device, electronic equipment, and storage medium.
背景技术Background technique
随着人工智能技术的不断发展,图像处理的种类越来越多,效果越来越好。人们在拍照、录视频时,往往可以对得到的脸部图像进行美颜处理,以使脸部更加美观。然而,基于对脸部图像的二维信息的识别和调整,从而完成美颜处理,真实感和自然感较差,效果难以达到用户满意。With the continuous development of artificial intelligence technology, there are more and more types of image processing, and the effect is getting better and better. When people take pictures or record videos, they often can perform beauty treatment on the obtained facial images to make their faces more attractive. However, based on the identification and adjustment of the two-dimensional information of the facial image, the beauty treatment is completed, the sense of reality and naturalness is poor, and the effect is difficult to satisfy the user.
发明内容Contents of the invention
根据本公开实施例的第一方面,提供一种图像处理方法,包括:获取待处理图像,其中,所述待处理图像包括目标对象;提取所述目标对象的三维关键点,并确定所述三维关键点与三维调整模型中顶点之间的第一对应关系;根据调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果;根据所述三维关键点的调整结果和所述待处理图像,确定目标图像。According to a first aspect of an embodiment of the present disclosure, an image processing method is provided, including: acquiring an image to be processed, wherein the image to be processed includes a target object; extracting 3D key points of the target object, and determining the 3D A first correspondence between key points and vertices in the three-dimensional adjustment model; determining an adjustment result of the three-dimensional key points according to an adjustment instruction, preset deformation data of vertices in the three-dimensional adjustment model, and the first correspondence; A target image is determined according to the adjustment result of the three-dimensional key points and the image to be processed.
根据本公开实施例的第二方面,提供一种图像处理装置,包括:获取模块,用于获取待处理图像,其中,所述待处理图像包括目标对象;第一对应模块,用于提取所述目标对象的三维关键点,并确定所述三维关键点与三维调整模型中顶点之间的第一对应关系;调整模块,用于根据调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果;目标模块,用于根据所述三维关键点的调整结果和所述待处理图像,确定目标图像。According to the second aspect of the embodiments of the present disclosure, there is provided an image processing device, including: an acquisition module, configured to acquire an image to be processed, wherein the image to be processed includes a target object; a first corresponding module, configured to extract the The three-dimensional key points of the target object, and determine the first corresponding relationship between the three-dimensional key points and the vertices in the three-dimensional adjustment model; the adjustment module is used to adjust according to the adjustment instruction, the preset deformation data of the vertices in the three-dimensional adjustment model and The first correspondence is used to determine an adjustment result of the 3D key point; a target module is configured to determine a target image according to the adjustment result of the 3D key point and the image to be processed.
根据本公开实施例的第三方面,提供一种电子设备,所述设备包括存储器、处理器,所述存储器用于存储可在处理器上运行的计算机指令,所述处理器用于在执行所述计算机指令时实现第一方面所述的方法。According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, the device includes a memory and a processor, the memory is used to store computer instructions that can be run on the processor, and the processor is used to execute the The computer instructions implement the method described in the first aspect.
根据本公开实施例的第四方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述程序被处理器执行时实现第一方面所述的方法。According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described in the first aspect is implemented.
根据本公开实施例的第五方面,提供一种计算机程序产品,该产品包括计算机程序,当所述程序被处理器执行时实现第一方面所述的方法。According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, the product includes a computer program, and when the program is executed by a processor, the method described in the first aspect is implemented.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description serve to explain the principles of the disclosure.
图1是根据本公开一实施例示出的图像处理方法的流程图;FIG. 1 is a flowchart of an image processing method according to an embodiment of the present disclosure;
图2是根据本公开一实施例示出的交互界面的示意图;Fig. 2 is a schematic diagram of an interactive interface shown according to an embodiment of the present disclosure;
图3是根据本公开一实施例示出的脸部标准模型的示意图;Fig. 3 is a schematic diagram of a face standard model shown according to an embodiment of the present disclosure;
图4是根据本公开一实施例示出的确定第一对应关系的流程图;Fig. 4 is a flow chart of determining a first correspondence according to an embodiment of the present disclosure;
图5是根据本公开一实施例示出的确定目标图像的方式的流程图;Fig. 5 is a flowchart showing a method of determining a target image according to an embodiment of the present disclosure;
图6是根据本公开另一实施例示出的图像处理方法的流程图;FIG. 6 is a flowchart of an image processing method according to another embodiment of the present disclosure;
图7是根据本公开一实施例示出的综合模型的示意图;Fig. 7 is a schematic diagram of an integrated model shown according to an embodiment of the present disclosure;
图8是根据本公开实施例示出的图像处理装置的结构示意图;Fig. 8 is a schematic structural diagram of an image processing device according to an embodiment of the present disclosure;
图9是根据本公开实施例示出的电子设备的结构示意图。Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatuses and methods consistent with aspects of the present disclosure as recited in the appended claims.
在本公开使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本公开。在本公开和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terminology used in the present disclosure is for the purpose of describing particular embodiments only, and is not intended to limit the present disclosure. As used in this disclosure and the appended claims, the singular forms "a", "the", and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It should also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
应当理解,尽管在本公开可能采用术语“第一”、“第二”、“第三”等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本公开范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms "first", "second", "third", etc. may be used in the present disclosure to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of the present disclosure, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word "if" as used herein may be interpreted as "at" or "when" or "in response to a determination."
若本公开技术方案涉及用户信息,应用本公开技术方案的产品在处理用户信息前,已明确告知用户信息处理规则,并取得用户自主同意。若本公开技术方案涉及敏感用户信息,应用本公开技术方案的产品在处理敏感用户信息前,已取得用户单独同意,并且同时满足“明示同意”的要求。例如,在摄像头等用户信息采集装置处,设置明确显著的标识告知已进入用户信息采集范围,将会对用户信息进行采集,若用户自愿进入采集范围即视为同意对其用户信息进行采集;或者在用户信息处理的装置上,利用明显的标识/信息告知用户信息处理规则的情况下,通过弹窗信息或请用户自行上传其用户信息等方式获得用户授权;其中,用户信息处理规则可包括用户信息处理者、用户信息处理目的、处理方式、处理的用户信息种类等信息。If the disclosed technical solution involves user information, the product applying the disclosed technical solution has clearly informed the user of the information processing rules and obtained the user's independent consent before processing the user information. If the disclosed technical solution involves sensitive user information, the product applying the disclosed technical solution has obtained the separate consent of the user before processing the sensitive user information, and at the same time meets the requirement of "express consent". For example, at the user information collection device such as a camera, set a clear and prominent sign to inform that the user information has entered the collection range, and the user information will be collected. If the user voluntarily enters the collection range, it is deemed to agree to the collection of his user information; or On the user information processing device, when the user information processing rules are notified with obvious signs/information, the user authorization is obtained through pop-up information or asking the user to upload their user information; among them, the user information processing rules may include user Information processor, user information processing purpose, processing method, type of user information processed and other information.
第一方面,本公开至少一个实施例提供了一种图像处理方法,请参照附图1,其示出了该方法的流程,包括步骤S101至步骤S104。In a first aspect, at least one embodiment of the present disclosure provides an image processing method. Please refer to FIG. 1 , which shows the flow of the method, including steps S101 to S104.
其中,该方法可以用于对待处理图像进行处理,例如可以对待处理图像中的目标对象进行调整,目标对象可以为,例如待处理图像中以下至少一个对象:脸部、手部、肢体,所调整的项目可以为形状、尺寸、位置等。例如,待处理图像中具有脸部时,可以对脸部的面部信息,即五官形状、尺寸、比例等进行调整,从而完成脸部的美颜、微整形、美体等增强处理。Wherein, the method can be used to process the image to be processed, for example, the target object in the image to be processed can be adjusted, and the target object can be, for example, at least one of the following objects in the image to be processed: face, hand, limb, adjusted The items can be shape, size, position, etc. For example, when there is a face in the image to be processed, the facial information of the face, that is, the shape, size, proportion, etc. of the facial features, can be adjusted, so as to complete the enhancement processing such as face beautification, micro-shaping, and body shaping.
待处理图像可以为图像采集设备拍摄的图像,或图像采集设备所录制的视频中的一帧图像。可以理解的是,通过利用本公开实施例提供的方法对图像采集设备所录制的视频中的每一帧图像都进行处理,则可以完成对该视频的处理。The image to be processed may be an image captured by the image acquisition device, or a frame of image in a video recorded by the image acquisition device. It can be understood that, by using the method provided by the embodiment of the present disclosure to process each frame of image in the video recorded by the image acquisition device, the processing of the video can be completed.
另外,该方法可以由终端设备或服务器等电子设备执行,终端设备可以为用户设备(User Equipment,UE)、移动设备、终端、蜂窝电话、无绳电话、个人数字处理(Personal Digital Assistant,PDA)手持设备、计算设备、车载设备、可穿戴设备等,该方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。或者,可以通过服务器执行该方法,服务器可以为本地服务器、云端服务器等。In addition, the method can be executed by electronic devices such as terminal equipment or servers, and the terminal equipment can be user equipment (User Equipment, UE), mobile equipment, terminal, cellular phone, cordless phone, personal digital assistant (Personal Digital Assistant, PDA) handheld device, computing device, vehicle-mounted device, wearable device, etc., the method can be realized by calling a computer-readable instruction stored in a memory by a processor. Alternatively, the method may be executed by a server, and the server may be a local server, a cloud server, or the like.
在步骤S101中,获取待处理图像,其中,所述待处理图像包括目标对象。In step S101, an image to be processed is acquired, wherein the image to be processed includes a target object.
其中,待处理图像可以为图像采集设备拍摄的图像,或图像采集设备所录制的视频中的一帧图像,其中的图像采集设备可以为手机、相机等具备图像采集功能的电子设备。目标对象是真实场景中的特定对象在图像中所成的像,例如,可以为待处理图像中的脸部(即脸部在图像中所成的像),手部(即手部在图像中所成的像)等。Wherein, the image to be processed may be an image taken by an image acquisition device, or a frame image in a video recorded by the image acquisition device, wherein the image acquisition device may be an electronic device with an image acquisition function such as a mobile phone or a camera. The target object is the image of a specific object in the real scene in the image, for example, it can be the face in the image to be processed (that is, the image of the face in the image), the hand (that is, the hand in the image The resulting image), etc.
可以对图像采集设备拍摄的图像进行识别,若图像中包含目标对象,则获取该图像作为待处理图像,若图像中不包含目标对象,则该图像不作为待处理图像;相对应的,可以对图像采集设备录制的视频进行识别,若某一帧图像中包含目标对象,则获取该帧图像作为待处理图像,若某一帧图像中不包含目标对象,则该帧图像不作为待处理图像。The image captured by the image acquisition device can be identified. If the image contains the target object, the image is acquired as the image to be processed. If the image does not contain the target object, the image is not regarded as the image to be processed; correspondingly, the The video recorded by the image acquisition device is identified. If a frame of image contains the target object, the frame of image is acquired as the image to be processed. If a frame of image does not contain the target object, the frame of image is not regarded as the image to be processed.
在一个可能的场景中,用户使用手机录制视频,录制过程中画面内有时出现脸部,有时不出现脸部,则画面中存在脸部的图像帧被作为待处理图像进行美颜处理,而画面中不存在脸部的图像帧不被作为待处理图像进行美颜处理,从而既可以保证视频画面中的脸部被实时美颜处理,又可以在视频画面中不存在脸部时降低处理器负荷,节省能耗,并避免对视频画面进行误处理等。In a possible scenario, the user uses a mobile phone to record a video. During the recording process, a face sometimes appears in the screen, and sometimes there is no face. Image frames with no faces in the video frame are not treated as images to be processed for beautification processing, thereby ensuring real-time beautification processing of faces in the video screen, and reducing processor load when there are no faces in the video screen , save energy consumption, and avoid mishandling of video images.
在步骤S102中,提取所述目标对象的三维关键点,并确定所述三维关键点与三维调整模型中顶点之间的第一对应关系。In step S102, the 3D key points of the target object are extracted, and a first corresponding relationship between the 3D key points and vertices in the 3D adjustment model is determined.
提取目标对象的三维关键点的方式有多种,一种示例中,可以获取待处理图像对应的深度图像,并将待处理图像与深度图像对齐后的图像输入到预先训练的深度神经网络中,进行三维关键点检测。图像采集设备获取待处理图像的同时,可以启动图像采集设备的摄像头的结构光感测器获取深度图像,或者采用飞时测距(Time of Flight,ToF)感测技术获取深度图像。There are many ways to extract the 3D key points of the target object. In one example, the depth image corresponding to the image to be processed can be obtained, and the image after the image to be processed is aligned with the depth image can be input into the pre-trained deep neural network. Perform 3D keypoint detection. While the image acquisition device acquires the image to be processed, it can start the structured light sensor of the camera of the image acquisition device to acquire the depth image, or use Time of Flight (ToF) sensing technology to acquire the depth image.
检测得到的三维关键点包括多个,且检测得到的每个三维关键点是具有标识的,例如检测得到的三维关键点具有顺序,则每个三维关键点的标识可以为次序标识。例如,在检测目标对象的三维关键点时,可以按照目标对象的特点或检测要求进行检测,即目标对象的某个位置是否检测,以及检测几个三维关键点,是可以提前预设的。例如,在对脸部图像进行检测时,可以对脸部的五官以及其他关键位置进行三维关键点检测,这些关键位置具有标识例如眼睛、嘴、眉毛、鼻子等,因此所检测得到的三维关键点是具有标识的。There are multiple detected 3D key points, and each detected 3D key point has an identifier. For example, if the detected 3D key points have a sequence, the identifier of each 3D key point may be a sequence identifier. For example, when detecting the 3D key points of the target object, the detection can be performed according to the characteristics of the target object or detection requirements, that is, whether to detect a certain position of the target object, and to detect several 3D key points can be preset in advance. For example, when detecting a face image, three-dimensional key point detection can be performed on facial features and other key positions. These key positions have signs such as eyes, mouth, eyebrows, nose, etc., so the detected three-dimensional key points is identified.
三维调整模型用于表示目标对象的各个调整项目的调整方式,例如,脸部的三维调整模型可以包括美颜模型,其用于表示各个美颜项目(例如瘦脸、大眼、小嘴等项目)的美颜方式。三维调整模型可以由多个顶点以及顶点间的网格结构组成,三维调整模型的顶点也可以对应目标对象的各个三维关键点,且三维调整模型的多个顶点也是具有标识的,例如,三维调整模型的多个顶点具有顺序,则每个顶点的标识可以为次序标识。多个顶点的排序方式与上述检测得到的三维关键点的顺序可以相同,也可以不同。The three-dimensional adjustment model is used to represent the adjustment method of each adjustment item of the target object. For example, the three-dimensional adjustment model of the face may include a beauty model, which is used to represent various beauty items (such as thin face, big eyes, small mouth, etc.) way of beauty. The 3D adjustment model can be composed of multiple vertices and the mesh structure between the vertices. The vertices of the 3D adjustment model can also correspond to the 3D key points of the target object, and the multiple vertices of the 3D adjustment model are also identified. For example, the 3D adjustment Multiple vertices of the model have order, and the identification of each vertex can be order identification. The order of the multiple vertices may be the same as or different from the order of the three-dimensional key points detected above.
由于检测得到的目标对象的三维关键点是对应于目标对象的各个关键位置的,而三维调整模型也是对应于目标对象的各个关键位置的,因此建立三维关键点与三维调整模型中顶点之间的第一对应关系,即将相同的关键位置处的三维关键点和三维调整模型中顶点进行对应。Since the detected 3D key points of the target object correspond to each key position of the target object, and the 3D adjustment model also corresponds to each key position of the target object, the relationship between the 3D key point and the vertices in the 3D adjustment model is established. The first correspondence is to correspond the 3D key points at the same key position with the vertices in the 3D adjustment model.
在步骤S103中,根据调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果。In step S103, the adjustment result of the three-dimensional key points is determined according to the adjustment instruction, the preset deformation data of vertices in the three-dimensional adjustment model, and the first corresponding relationship.
其中,三维调整模型还可以存储各个顶点的预设形变数据,例如在进行各个调整项目时,顶点的位移数据等。每个调整项目中,至少有一个顶点需要进行位移,因此可以记载每个顶点在不同调整项目下的位移数据(注:若顶点不需要位移,则位移数据为0)。例如,可以采用数组的方式对预设形变数据进行记载,每个顶点建立一个数组,先在数组中记录该顶点的三维坐标,然后依次记录该顶点在各个调整项目下的位移数据。基于上述数组的记录方式,可以在确定第一对应关系后,将与三维调整模型中顶点对应的三维关键点的坐标信息转换至三维调整模型的坐标系内,并将该转换后的三维关键点的坐标添加到该顶点的数组中,以便于后续对三维关键点进行调整时的计算。Wherein, the three-dimensional adjustment model may also store preset deformation data of each vertex, such as displacement data of the vertex when each adjustment item is performed. In each adjustment item, at least one vertex needs to be displaced, so the displacement data of each vertex under different adjustment items can be recorded (note: if the vertex does not need to be displaced, the displacement data is 0). For example, the preset deformation data can be recorded in the form of an array, and an array is created for each vertex, and the three-dimensional coordinates of the vertex are first recorded in the array, and then the displacement data of the vertex under each adjustment item is sequentially recorded. Based on the recording method of the above-mentioned array, after the first corresponding relationship is determined, the coordinate information of the 3D key points corresponding to the vertices in the 3D adjustment model can be converted into the coordinate system of the 3D adjustment model, and the converted 3D key points The coordinates of the vertex are added to the array of the vertex, so as to facilitate the subsequent calculation when adjusting the 3D key points.
其中,调整指令可以根据用户的操作生成,例如用户对至少一个调整项目进行选择,则生成针对所述至少一个调整项目的调整指令;调整指令还可以由执行该方法的终端自动生成。在目标对象为脸部时,用户可以针对脸部选择至少一个调整项目,从而生成该至少一个调整项目对应的调整指令。再例如,在目标对象为脸部时,可以预先设置至少一个调整项目,然后在每次获取到待处理图像后,均自动生成对应上述至少一个调整项目的调整指令。Wherein, the adjustment instruction can be generated according to the user's operation, for example, if the user selects at least one adjustment item, an adjustment instruction for the at least one adjustment item is generated; the adjustment instruction can also be automatically generated by the terminal executing the method. When the target object is a face, the user may select at least one adjustment item for the face, so as to generate an adjustment instruction corresponding to the at least one adjustment item. For another example, when the target object is a face, at least one adjustment item may be set in advance, and then an adjustment instruction corresponding to the at least one adjustment item is automatically generated each time an image to be processed is acquired.
三维关键点的调整过程,包括三维关键点的位置调整过程,因此三维关键点的调整结果,包括位置被调整后的三维关键点。The adjustment process of the three-dimensional key points includes the position adjustment process of the three-dimensional key points, so the adjustment result of the three-dimensional key points includes the adjusted three-dimensional key points.
在一个示例中,本步骤确定三维关键点的调整结果时,可以根据所述调整指令确定目标对象的调整项目,获取所述三维调整模型中顶点的预设形变数据中与所述调整项目对应的第一形变数据,根据所述第一形变数据,对所述三维调整模型中至少一个顶点对应的所述三维关键点进行位移,从而得到所述三维关键点的调整结果。In an example, when determining the adjustment result of the three-dimensional key point in this step, the adjustment item of the target object may be determined according to the adjustment instruction, and the preset deformation data of the vertices in the three-dimensional adjustment model corresponding to the adjustment item may be obtained. The first deformation data. According to the first deformation data, the three-dimensional key point corresponding to at least one vertex in the three-dimensional adjustment model is displaced, so as to obtain the adjustment result of the three-dimensional key point.
调整项目包括调整位置和调整类型,调整位置指的是目标对象的局部位置,例如脸部中的某个五官,调整类型指的是期待的调整结果,例如调小、调大、调圆等。举例来说,目标对象为脸部时,调整项目为大眼时,调整位置为眼部,调整类型为调大;调整项目为小嘴时,调整位置为嘴,调整类型为调小等等。请参照附图2,其示出了一个脸部调整的交互界面,该界面内具有瘦脸、大眼、小头、隆鼻和小嘴等调整项目,用户选中其中至少一个调整项目后,则生成包含该调整项目的调整指令。The adjustment items include adjustment position and adjustment type. The adjustment position refers to the local position of the target object, such as a facial feature in the face, and the adjustment type refers to the expected adjustment result, such as reducing, increasing, and rounding. For example, when the target object is a face, when the adjustment item is big eyes, the adjustment position is eyes, and the adjustment type is enlarged; when the adjustment item is small mouth, the adjustment position is mouth, and the adjustment type is reduced, etc. Please refer to accompanying drawing 2, it has shown the interactive interface of a face adjustment, has adjustment items such as thin face, big eyes, small head, rhinoplasty and small mouth etc. in this interface, after the user selects at least one adjustment item among them, then generate Contains the adjustment command for this adjustment item.
若调整指令中具有一个调整项目,则确定一个调整项目,若调整指令中具有多个调整项目,则确定多个调整项目。If there is one adjustment item in the adjustment instruction, one adjustment item is determined, and if there are multiple adjustment items in the adjustment instruction, multiple adjustment items are determined.
第一形变数据,包括三维调整模型的每个顶点在调整项目下的位移数据。可以遍历每个顶点,获取调整指令中的调整项目所对应的每个顶点的形变数据,即所有顶点在该调整项目下的位移数据,例如,当调整指令包括例如图2中的大眼项目202时,遍历该调整项目对应的每个顶点,获取大眼项目中三维调整模型中的眼部顶点(例如E1、E2、E3、E4眼部顶点的数量不限于此)的形变数据,而三维调整模型中的其他顶点,例如嘴部顶点、鼻部顶点则没有形变数据。当每个顶点以数组的形式存储各个调整项目下的位移数据时,可以按照调整项目到数组的对应位置获取位移数据,以图2中的眼部顶点E1为例,例如E1的数组为[0,1,0.2,0.1,0],该数组中的第一个数据位置至第五个数据位置依次是瘦脸项目201下E1的位移数据0、大眼项目202下E1的位移数据1、小头 项目203下E1的位移数据0.2、隆鼻项目204下E1的位移数据0.1和小嘴项目205下E1的位移数据0,则当调整项目为大眼时,则可以直接从E1数组的第二个位置获取到大眼项目202对应的位移数据0.2,类似地,可以分别从E2、E3、E4数组的第二个位置获取到大眼项目所对应的位移数据。The first deformation data includes displacement data of each vertex of the three-dimensional adjustment model under the adjustment item. Each vertex can be traversed to obtain the deformation data of each vertex corresponding to the adjustment item in the adjustment instruction, that is, the displacement data of all vertices under the adjustment item. For example, when the adjustment instruction includes, for example, the big eye item 202 in FIG. 2 , traverse each vertex corresponding to the adjustment item, and obtain the deformation data of the eye vertices (for example, the number of eye vertices of E1, E2, E3, and E4) in the three-dimensional adjustment model of the big eye project, and the three-dimensional adjustment Other vertices in the model, such as mouth vertices and nose vertices, do not have deformation data. When each vertex stores the displacement data under each adjustment item in the form of an array, the displacement data can be obtained according to the corresponding position of the adjustment item to the array. Take the eye vertex E1 in Figure 2 as an example, for example, the array of E1 is [0 ,1,0.2,0.1,0], the first to fifth data positions in the array are the displacement data 0 of E1 under the thin face item 201, the displacement data 1 of E1 under the big eye item 202, and the small head The displacement data of E1 under item 203 is 0.2, the displacement data of E1 under item 204 of rhinoplasty is 0.1, and the displacement data of E1 under item 205 of small mouth is 0, then when the adjustment item is big eyes, it can be directly obtained from the second part of the E1 array. The displacement data 0.2 corresponding to the big-eye item 202 is obtained from the position. Similarly, the displacement data corresponding to the big-eye item can be obtained from the second positions of the E2, E3, and E4 arrays respectively.
在调整指令中的调整项目只有一个时,则直接获取该调整项目对应的形变数据,例如该调整项目为大眼时,则直接获取大眼项目对应的顶点E1~E4的形变数据(位移数据)。在调整指令中的调整项目有多个时,则可以获取每个调整项目对应的形变数据。或者,三维调整模型在存储各个调整项目的位移数据之外,还存储了调整项目之间的各种组合所对应的位移数据,则在调整指令中的调整项目有多个时,可以直接获取多个调整项目的组合所对应的位移数据。例如,在美颜指令中的美颜项目只有瘦脸时,则直接获取瘦脸项目201对应的形变数据,在美颜指令中的美颜项目包括瘦脸和大眼时,则可以分别获取瘦脸项目201对应的形变数据和大眼项目202对应的形变数据,还可以获取瘦脸项目201和大眼项目202的组合所对应的形变数据。When there is only one adjustment item in the adjustment command, the deformation data corresponding to the adjustment item is obtained directly. For example, when the adjustment item is a big eye, the deformation data (displacement data) of vertices E1-E4 corresponding to the big eye item are directly obtained. . When there are multiple adjustment items in the adjustment instruction, the deformation data corresponding to each adjustment item may be acquired. Or, in addition to storing the displacement data of each adjustment item, the three-dimensional adjustment model also stores displacement data corresponding to various combinations of adjustment items, so when there are multiple adjustment items in the adjustment instruction, multiple adjustment items can be directly obtained. The displacement data corresponding to the combination of adjustment items. For example, when the beauty item in the beauty command is only face-lifting, the deformation data corresponding to the face-lifting item 201 is obtained directly; The deformation data corresponding to the deformation data of the large-eye item 202 and the deformation data corresponding to the combination of the thin-face item 201 and the large-eye item 202 can also be obtained.
另外,调整指令在包括调整项目的同时,还可以包括各个调整项目的调整参数值,请继续参照附图2,该界面内具有调整参数的刻度尺,拨动该刻度尺的定位点位置,可以调整调整指令中调整项目的调整参数值。调整参数值可以为该调整项目的调整程度,不同的调整程度可以对应不同的形变数据,例如调整程度为100%时,则形变数据为该调整项目所对应的最大形变数据,调整程度为60%,则形变数据为该调整项目所对应的最大形变数据的60%。因此可以在根据所述第一形变数据,对所述三维调整模型中顶点对应的所述三维关键点进行位移得到所述三维关键点的调整结果之前,进一步根据调整指令确定所述调整项目的调整参数值,再根据所述调整参数值对所述第一形变数据进行调整。通过调整参数值可以对调整项目的程度进行调整,增加了调整的灵活性和多样性。In addition, while the adjustment command includes the adjustment items, it can also include the adjustment parameter values of each adjustment item. Please continue to refer to Figure 2. There is a scale for adjusting parameters in this interface. Toggle the position of the anchor point of the scale to Adjust the adjustment parameter value of the adjustment item in the adjustment instruction. The adjustment parameter value can be the adjustment degree of the adjustment item. Different adjustment degrees can correspond to different deformation data. For example, when the adjustment degree is 100%, the deformation data is the maximum deformation data corresponding to the adjustment item, and the adjustment degree is 60%. , the deformation data is 60% of the maximum deformation data corresponding to the adjustment item. Therefore, before the 3D key points corresponding to the vertices in the 3D adjustment model are displaced according to the first deformation data to obtain the adjustment result of the 3D key points, the adjustment of the adjustment items can be further determined according to the adjustment instruction. parameter value, and then adjust the first deformation data according to the adjusted parameter value. The degree of the adjustment item can be adjusted by adjusting the parameter value, which increases the flexibility and diversity of the adjustment.
可以对三维调整模型顶点对应的三维关键点的坐标和三维调整模型顶点所对应的位移数据进行运算,得到三维关键点的调整结果。在一个或多个调整项目下,至少有一个顶点的位移数据不为0,则这些顶点对应的三维关键点在运算后发生位移。在采用数组的方式对预设形变数据进行记载,且在确定第一对应关系后,将与顶点对应的三维关键点的坐标信息转换至三维调整模型的坐标系内,并将该转换后的三维关键点的坐标信息添加到该顶点的数组中的情况下,可以直接从每个顶点的数组中提取三维关键点的坐标和位移数据。The coordinates of the three-dimensional key points corresponding to the vertices of the three-dimensional adjustment model and the displacement data corresponding to the vertices of the three-dimensional adjustment model can be calculated to obtain the adjustment result of the three-dimensional key points. Under one or more adjustment items, if the displacement data of at least one vertex is not 0, the 3D key points corresponding to these vertices will be displaced after the operation. The preset deformation data is recorded in the form of an array, and after the first corresponding relationship is determined, the coordinate information of the 3D key point corresponding to the vertex is converted into the coordinate system of the 3D adjustment model, and the converted 3D When the coordinate information of the key point is added to the array of the vertex, the coordinate and displacement data of the three-dimensional key point can be directly extracted from the array of each vertex.
在一种可能的实施方式中,当根据调整指令获取到针对某个顶点的多个不为0的位移数据时,可以按照预设顺序,依次按照每个位移数据对顶点对应的三维关键点的坐标进行运算。例如,调整指令中包括小头项目、隆鼻项目和大眼项目,则眼部顶点E1的位移数据为[0.2,0.1,1],则可以按照调整指令中的顺序例如小头项目、隆鼻项目和大眼项目所对应的E1的位移数据对E1所对应三维关键点的坐标进行运算;或者也可以按照E1数组中的顺序例如大眼项目、小头项目和隆鼻项目对应的位移数据对E1所对应的三维关键点的坐标进行运算。In a possible implementation, when a plurality of non-zero displacement data for a certain vertex is obtained according to the adjustment instruction, according to the preset sequence, each displacement data can be used in sequence according to the three-dimensional key point corresponding to the vertex. Coordinates are calculated. For example, if the adjustment command includes small head item, nose augmentation item and big eye item, then the displacement data of the eye vertex E1 is [0.2,0.1,1], then you can follow the order in the adjustment command such as small head item, nose augmentation The displacement data of E1 corresponding to the project and the big-eye project can be used to calculate the coordinates of the three-dimensional key points corresponding to E1; or the displacement data corresponding to the big-eye project, small-head project and nose augmentation project can also be calculated according to the order in the E1 array. The coordinates of the 3D key points corresponding to E1 are calculated.
按照上述至少一种方式对三维关键点进行位移后,三维关键点的位置被调整,处在新位置上的三维关键点即为三维关键点的调整结果中位置被调整后的三维关键点。After the three-dimensional key points are displaced according to at least one of the above methods, the positions of the three-dimensional key points are adjusted, and the three-dimensional key points at the new positions are the adjusted three-dimensional key points in the adjustment result of the three-dimensional key points.
在步骤S104中,根据所述三维关键点的调整结果和所述待处理图像,确定目标图像。In step S104, a target image is determined according to the adjustment result of the 3D key points and the image to be processed.
本步骤中,根据三维关键点的调整结果,对待处理图像的对应位置进行相同的调整,也就是将调整结果映射到处理图像上,从而完成对待处理图像中的目标对象的调整。例如,在目标对象为脸部图像时,可以在本步骤中完成对脸部图像的美颜处理。In this step, according to the adjustment result of the three-dimensional key points, the same adjustment is performed on the corresponding position of the image to be processed, that is, the adjustment result is mapped to the image to be processed, thereby completing the adjustment of the target object in the image to be processed. For example, when the target object is a facial image, the beautification process on the facial image can be completed in this step.
根据上述实施例可知,通过获取待处理图像,并提取待处理图像中目标对象的三维 关键点,确定三维关键点与三维调整模型中顶点的第一对应关系,根据调整指令、三维调整模型中顶点的预设形变数据和第一对应关系,确定三维关键点的调整结果,根据三维关键点的调整结果和待处理图像,确定目标图像。由于三维调整模型是三维的,且三维调整模型顶点具有预设形变数据,而对目标对象的调整,是根据调整指令和预设形变数据对三维关键点进行调整,因此调整过程更加精细,可控,再者三维关键点是从待处理图像中提取得到,最后三维关键点经过调整得到的调整结果又返回待处理图像,因此所得到的目标图像中的目标对象的调整效果自然且真实,提高了用户的满意度。According to the above-mentioned embodiment, by acquiring the image to be processed, and extracting the three-dimensional key points of the target object in the image to be processed, determining the first corresponding relationship between the three-dimensional key points and the vertices in the three-dimensional adjustment model, according to the adjustment instruction, the vertices in the three-dimensional adjustment model The preset deformation data and the first corresponding relationship determine the adjustment result of the three-dimensional key point, and determine the target image according to the adjustment result of the three-dimensional key point and the image to be processed. Since the 3D adjustment model is 3D, and the vertices of the 3D adjustment model have preset deformation data, the adjustment of the target object is to adjust the 3D key points according to the adjustment instruction and the preset deformation data, so the adjustment process is more precise and controllable , and the three-dimensional key points are extracted from the image to be processed, and finally the adjustment result obtained by adjusting the three-dimensional key points is returned to the image to be processed, so the adjustment effect of the target object in the obtained target image is natural and real, which improves the user satisfaction.
在本公开的一些实施例中,所述图像处理方法还包括:获取所述三维调整模型中顶点与三维标准模型中顶点的第二对应关系。In some embodiments of the present disclosure, the image processing method further includes: acquiring a second corresponding relationship between vertices in the three-dimensional adjustment model and vertices in the three-dimensional standard model.
其中,三维标准模型为目标对象的标准模型,由多个顶点和顶点间的网格构成。例如目标对象为脸部图像时,则三维标准模型可以为如图3所示的标准脸部模型。若对三维标准模型进行三维关键点提取,则可以得到三维标准模型的所有顶点。三维调整模型用于表征三维标准模型的至少一个调整项目的具体调整方式,即三维调整模型包括至少一个调整项目中,三维标准模型的各个顶点的形变数据。三维调整模型具有专用的模型坐标系,三维调整模型内的各个顶点的坐标均为该三维调整模型坐标系内的坐标,三维调整模型还可以利用坐标变换矩阵将该三维调整模型坐标系内的坐标转换至世界坐标系内。在本公开的一些实施例中,可以通过对三维标准模型执行至少一个调整项目分别对应的预设形变,获得三维调整模型。Wherein, the three-dimensional standard model is the standard model of the target object, which is composed of multiple vertices and meshes between the vertices. For example, when the target object is a facial image, the three-dimensional standard model may be a standard facial model as shown in FIG. 3 . If the 3D key points are extracted from the 3D standard model, all vertices of the 3D standard model can be obtained. The three-dimensional adjustment model is used to characterize the specific adjustment manner of at least one adjustment item of the three-dimensional standard model, that is, the three-dimensional adjustment model includes deformation data of each vertex of the three-dimensional standard model in at least one adjustment item. The 3D adjustment model has a dedicated model coordinate system. The coordinates of each vertex in the 3D adjustment model are the coordinates in the coordinate system of the 3D adjustment model. The 3D adjustment model can also use the coordinate transformation matrix to coordinate the coordinates of the 3D adjustment model in the coordinate system Transform to the world coordinate system. In some embodiments of the present disclosure, the three-dimensional adjustment model may be obtained by performing preset deformations respectively corresponding to at least one adjustment item on the three-dimensional standard model.
因此,可以先将所述三维调整模型中顶点的坐标与所述三维标准模型中顶点的坐标,转换至相同的坐标系内,例如三维标准模型中顶点的坐标为世界坐标系内的坐标,则可以以三维调整模型中顶点的坐标乘该三维调整模型的坐标变换矩阵,从而将三维调整模型的顶点的坐标转换至世界坐标系,如此,转换后的三维调整模型中顶点的坐标和三维标准模型中顶点的坐标均在世界坐标系内。根据所述转换后的三维调整模型中每个顶点与所述三维标准模型中每个顶点间的欧氏距离,确定所述第二对应关系,可以以两个顶点间的欧氏距离和预设的距离阈值,确定该两个顶点是否对应,即若欧氏距离小于距离阈值,则该这两个点对应,否则不对应。Therefore, the coordinates of the vertices in the three-dimensional adjustment model and the coordinates of the vertices in the three-dimensional standard model can be converted into the same coordinate system, for example, the coordinates of the vertices in the three-dimensional standard model are coordinates in the world coordinate system, then The coordinate transformation matrix of the three-dimensional adjustment model can be multiplied by the coordinates of the vertices in the three-dimensional adjustment model, so as to convert the coordinates of the vertices of the three-dimensional adjustment model to the world coordinate system. In this way, the coordinates of the vertices in the converted three-dimensional adjustment model and the three-dimensional standard model The coordinates of vertices are all in the world coordinate system. According to the Euclidean distance between each vertex in the converted three-dimensional adjustment model and each vertex in the three-dimensional standard model, determine the second corresponding relationship, which can be based on the Euclidean distance between two vertices and the preset The distance threshold is to determine whether the two vertices are corresponding, that is, if the Euclidean distance is less than the distance threshold, then the two points are corresponding, otherwise they are not.
基于此,可以按照如图4所示的方式确定所述三维关键点与三维调整模型中顶点之间的第一对应关系,包括步骤S401至步骤S402。Based on this, the first corresponding relationship between the 3D key points and the vertices in the 3D adjustment model may be determined as shown in FIG. 4 , including steps S401 to S402.
在步骤S401中,根据所述三维关键点的标识和所述三维标准模型中顶点的标识,确定所述三维关键点与所述三维标准模型中顶点之间的第三对应关系。In step S401, according to the identification of the 3D key point and the identification of the vertex in the 3D standard model, a third corresponding relationship between the 3D key point and the vertex in the 3D standard model is determined.
由于三维标准模型为基于标准对象(如标准脸部图像)生成的标准模型,该三维标准模型中标准对象和目标对象的关键点的设置逻辑相同,例如均按顺序包括眉毛、眼、鼻子、嘴,因此,基于标准脸部图像生成的三维标准模型中顶点在目标对象中的位置,与三维关键点在目标对象中的位置相同时,则该三维标准模型中顶点与该三维关键点的标识相同,因此将标识相同的三维关键点和所述三维标准模型的顶点,确定为相互对应的顶点对,得到所述第三对应关系。例如,三维标准模型顶点的顺序与目标对象的三维关键点的顺序是一致的,可以将次序标识相同的三维关键点和所述三维标准模型的顶点,确定为相互对应的顶点对,得到所述第三对应关系。Since the 3D standard model is a standard model generated based on a standard object (such as a standard face image), the setting logic of the key points of the standard object and the target object in the 3D standard model is the same, for example, they all include eyebrows, eyes, nose, mouth , therefore, when the position of the vertex in the target object in the 3D standard model generated based on the standard face image is the same as the position of the 3D key point in the target object, then the vertex in the 3D standard model and the identity of the 3D key point are the same , so the same three-dimensional key point and the vertices of the three-dimensional standard model are determined as pairs of vertices corresponding to each other, and the third corresponding relationship is obtained. For example, the order of the vertices of the three-dimensional standard model is consistent with the order of the three-dimensional key points of the target object, and the order of the same three-dimensional key points and the vertices of the three-dimensional standard model can be determined as a pair of vertices corresponding to each other, and the described third correspondence.
在步骤S402中,根据所述第二对应关系和所述第三对应关系,确定所述第一对应关系。In step S402, the first correspondence is determined according to the second correspondence and the third correspondence.
将与三维标准模型的同一顶点相对应的三维调整模型的顶点和三维关键点,确定为相互对应的关系。The vertices of the 3D adjustment model corresponding to the same vertex of the 3D standard model and the 3D key points are determined as corresponding to each other.
本实施例中,通过预先设置三维标准模型的各个顶点与三维调整模型的各个顶点间 的第二对应关系,根据三维关键点与三维标准模型的各顶点的第三对应关系,确定所述三维关键点与三维调整模型的各顶点的第一对应关系。在其他实施例中,在获取到待处理图像的目标对象的三维关键点后,也可以直接应用标识确定三维关键点与三维调整模型的顶点的第一对应关系,简单方便,准确可靠,避免了针对每个待处理图像的目标对象的三维关键点,进行欧氏距离计算等复杂操作。In this embodiment, by presetting the second corresponding relationship between each vertex of the 3D standard model and each vertex of the 3D adjustment model, the 3D key is determined according to the third corresponding relationship between the 3D key point and each vertex of the 3D standard model. The first corresponding relationship between the point and each vertex of the three-dimensional adjustment model. In other embodiments, after obtaining the 3D key points of the target object of the image to be processed, the identification can also be directly used to determine the first corresponding relationship between the 3D key points and the vertices of the 3D adjustment model, which is simple, convenient, accurate and reliable, and avoids the For the 3D key points of the target object of each image to be processed, complex operations such as Euclidean distance calculation are performed.
在本公开的一些实施例中,可以按照如图5所示的方式根据所述三维关键点的调整结果和所述待处理图像,确定目标图像,包括步骤S501至步骤S502。In some embodiments of the present disclosure, the target image may be determined according to the adjustment result of the three-dimensional key points and the image to be processed as shown in FIG. 5 , including steps S501 to S502.
在步骤S501中,按照预先制定的第一拓扑结构,在所述三维关键点的调整结果之间构建第一网格。In step S501, a first grid is constructed between the adjustment results of the three-dimensional key points according to a pre-established first topology structure.
其中,预先制定的第一拓扑结构,指的是三维标准模型的各个顶点间的网格中,顶点的连线关系,例如是三维标准模型每个顶点需要与其他哪些顶点连接。第一拓扑结构是以顶点的标识进行记载的。而由于三维关键点的标识是与三维标准模型顶点的标识一一对应的,且在步骤S401建立三维关键点与三维标准模型的顶点间的第三对应关系,因此当至少一个三维关键点发生位移后,各个三维关键点的标识依然明确,且各个三维关键点与三维标准模型的各个顶点的对应关系依然明确,进而可以按照第一拓扑结构对不同的三维关键点调整结果进行连线,构建第一网格。Wherein, the pre-established first topology refers to the connection relationship of the vertices in the grid among the vertices of the 3D standard model, for example, which other vertices need to be connected to each vertex of the 3D standard model. The first topological structure is recorded with the identification of vertices. And because the identification of the three-dimensional key point corresponds to the identification of the vertices of the three-dimensional standard model one by one, and the third corresponding relationship between the three-dimensional key point and the vertices of the three-dimensional standard model is established in step S401, when at least one three-dimensional key point is displaced Finally, the identification of each 3D key point is still clear, and the corresponding relationship between each 3D key point and each vertex of the 3D standard model is still clear, and then the adjustment results of different 3D key points can be connected according to the first topology structure to construct the second a grid.
在各个三维关键点的调整结果之间构建第一网格后,形成了目标对象的目标模型。After the first mesh is constructed between the adjustment results of the various 3D key points, a target model of the target object is formed.
在步骤S502中,根据所述三维关键点在所述待处理图像上的投影点的像素信息、所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息以及所述第一网格,在所述待处理图像上渲染所述目标对象的调整结果,得到目标图像。In step S502, according to the pixel information of the projection point of the 3D key point on the image to be processed, the coordinate information of the projection point of the adjustment result of the 3D key point on the image to be processed, and the first A grid, rendering the adjustment result of the target object on the image to be processed to obtain a target image.
可以提取所述三维关键点在所述待处理图像上的投影点的像素信息,作为所述三维关键点的像素信息,其中像素信息包括例如RGB值等,此外,三维关键点在待处理图像上的投影点的像素信息在三维关键点调整前后,该像素信息是不变的,因此所述三维关键点在所述待处理图像上的投影点的像素信息也可以作为三维关键点调整结果的像素信息;根据所述三维关键点的调整结果的像素信息,渲染所述第一网格,得到所述第一网格内的像素信息;根据所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息,将所述三维关键点的像素信息和所述第一网格内的像素信息投影到所述待处理图像上,得到所述目标图像。例如,目标对象是脸部图像,则目标图像为完成脸部图像的美颜处理的图像。The pixel information of the projection point of the three-dimensional key point on the image to be processed can be extracted as the pixel information of the three-dimensional key point, wherein the pixel information includes, for example, RGB values, etc. In addition, the three-dimensional key point is on the image to be processed The pixel information of the projection point of the three-dimensional key point is unchanged before and after the three-dimensional key point adjustment, so the pixel information of the projection point of the three-dimensional key point on the image to be processed can also be used as the pixel of the three-dimensional key point adjustment result information; according to the pixel information of the adjustment result of the three-dimensional key point, render the first grid to obtain the pixel information in the first grid; according to the adjustment result of the three-dimensional key point in the image to be processed The coordinate information of the projected point on the above, and the pixel information of the three-dimensional key point and the pixel information in the first grid are projected onto the image to be processed to obtain the target image. For example, if the target object is a facial image, then the target image is an image that has undergone beautification processing of the facial image.
相对于待处理图像,目标图像中的目标对象的某些位置被调整,例如待处理图像中的脸部中的眼睛变大,嘴巴变小等,这些调整使图像中像素点发生变化,例如眼睛变大时,眼睛部分的像素点发生位移,数量增加,且眼睛的所有像素点组成的形状发生变化。而本公开中并非直接在二维的待处理图像上对像素点进行调整,而是通过对二维的待处理图像中提取到的三维关键点进行调整,实现对待处理图像上的像素点进行调整。也就是说,三维关键点与其在待处理图像上的投影点相对应,因此三维关键点的调整结果可以用于表征三维关键点对应待处理图像上的投影点的调整结果,即该投影点的像素点的位置调整,例如可以通过提取三维关键点在待处理图像上的投影点的像素信息,并将该像素信息重新投影至三维关键点的调整结果在待处理图像的投影点上。Compared with the image to be processed, certain positions of the target object in the target image are adjusted, for example, the eyes in the face in the image to be processed become larger, the mouth becomes smaller, etc. These adjustments change the pixels in the image, such as eyes When it becomes larger, the pixel points of the eye part are displaced, the number increases, and the shape composed of all the pixel points of the eye changes. However, in this disclosure, the pixel points are not directly adjusted on the two-dimensional image to be processed, but the pixel points on the image to be processed are adjusted by adjusting the three-dimensional key points extracted from the two-dimensional image to be processed. . That is to say, the 3D key point corresponds to its projection point on the image to be processed, so the adjustment result of the 3D key point can be used to represent the adjustment result of the 3D key point corresponding to the projection point on the image to be processed, that is, the projection point of the projection point The position adjustment of the pixel point can be, for example, extracting the pixel information of the projection point of the three-dimensional key point on the image to be processed, and re-projecting the pixel information to the adjustment result of the three-dimensional key point on the projection point of the image to be processed.
第一网格包括多个封闭的子网格,这些子网格由至少三个三维关键点围绕形成。渲染第一网格内的像素信息时,例如渲染位于三个三维关键点围绕形成的第一网格内部的像素信息时,可以将每个子网格内的像素信息渲染为围绕该子网格的三个三维关键点的像素信息。这是因为,从待处理图像上提取三维关键点时,可以针对具有相同像素信息的像素区域的边界上的点进行提取,因此这样的像素区域内的像素点是相同的,因为它 们具有相同的像素信息,进而像素区域边界上的点对应的三维关键点组成的子网格内的像素信息也对与这些三维关键点的像素信息相同。The first grid includes a plurality of closed sub-grids, and these sub-grids are surrounded by at least three three-dimensional key points. When rendering the pixel information in the first grid, for example, when rendering the pixel information inside the first grid formed by three 3D key points, the pixel information in each sub-grid can be rendered as the Pixel information of three 3D keypoints. This is because, when extracting three-dimensional key points from the image to be processed, the points on the boundary of the pixel area with the same pixel information can be extracted, so the pixel points in such a pixel area are the same because they have the same The pixel information, and then the pixel information in the sub-grid composed of the three-dimensional key points corresponding to the points on the boundary of the pixel area is also the same as the pixel information of these three-dimensional key points.
在一个示例中,可以先将待处理图像渲染到输出图像上,例如通过OpenGL等渲染API的图像拷贝操作,将待处理图像拷贝到输出图像上,即作为目标图像的背景,其中,输出图像包括三维关键点的像素信息和第一网格内的像素信息在二维平面的投影;将待处理图像作为渲染流程的输入图像,将每个三维关键点在待处理图像上的投影点的坐标作为输入图像的纹理采样坐标,这样就可以提取三维关键点在待处理图像上的投影点的像素信息,由于调整前后三维关键点的像素信息不变,因此三维关键点在待处理图像上的投影点的像素信息可以作为三维关键点的调整结果的像素信息;通过三维调整模型的模型变换矩阵将三维关键点的调整结果的坐标转换至世界坐标系,再通过世界坐标系到裁剪空间的变换矩阵,将世界坐标系内的三维关键点的调整结果的坐标转换至裁剪坐标系,并送给后续片元渲染阶段,即根据三维关键点的调整结果的像素信息渲染第一网格内的像素信息,并将三维关键点的调整结果和第一网格内的像素信息渲染在输出图像上,从而实现在所述待处理图像上渲染所述目标对象的调整结果,得到目标图像。In an example, the image to be processed can be rendered on the output image first, for example, through an image copy operation of a rendering API such as OpenGL, the image to be processed can be copied to the output image, that is, as the background of the target image, wherein the output image includes The pixel information of the three-dimensional key points and the projection of the pixel information in the first grid on the two-dimensional plane; the image to be processed is used as the input image of the rendering process, and the coordinates of the projection points of each three-dimensional key point on the image to be processed are used as Input the texture sampling coordinates of the image, so that the pixel information of the projection point of the 3D key point on the image to be processed can be extracted. Since the pixel information of the 3D key point remains unchanged before and after adjustment, the projection point of the 3D key point on the image to be processed The pixel information of the 3D key point can be used as the pixel information of the adjustment result of the 3D key point; through the model transformation matrix of the 3D adjustment model, the coordinates of the adjustment result of the 3D key point are converted to the world coordinate system, and then through the transformation matrix from the world coordinate system to the clipping space, Convert the coordinates of the adjustment results of the 3D key points in the world coordinate system to the clipping coordinate system, and send them to the subsequent fragment rendering stage, that is, render the pixel information in the first grid according to the pixel information of the adjustment results of the 3D key points, And rendering the adjustment result of the three-dimensional key point and the pixel information in the first grid on the output image, so as to render the adjustment result of the target object on the image to be processed, and obtain the target image.
本实施例中,通过在各个三维关键点的调整结果之间构建第一网格,以形成目标对象的目标模型;再通过提取三维关键点的调整结果的像素信息,以及第一网格内的像素信息的渲染,以在目标模型上贴上像素信息,最后将具有像素信息的目标模型渲染到输出图像上,得到最终的目标图像。In this embodiment, the first grid is constructed between the adjustment results of each three-dimensional key point to form the target model of the target object; and then the pixel information of the adjustment result of the three-dimensional key point is extracted, and the first grid The rendering of pixel information is to paste pixel information on the target model, and finally render the target model with pixel information to the output image to obtain the final target image.
本公开的一些实施例中,还可以按照如图6所示的方式对图像进行处理,包括步骤S601至步骤S602。In some embodiments of the present disclosure, the image may also be processed in the manner shown in FIG. 6 , including steps S601 to S602.
在步骤S601中,生成环绕所述三维关键点的三维扩展模型,其中,所述三维扩展模型中的顶点包括第一边缘点的调整结果及基于所述第一边缘点扩展得到的第二边缘点,所述第一边缘点为对应所述目标对象的边界的三维关键点。In step S601, generate a 3D extended model surrounding the 3D key point, wherein the vertices in the 3D extended model include the adjustment result of the first edge point and the second edge point obtained based on the extension of the first edge point , the first edge point is a three-dimensional key point corresponding to the boundary of the target object.
本步骤中,可以先获取所述三维关键点中对应所述目标对象边界的第一边缘点。In this step, the first edge point corresponding to the boundary of the target object among the three-dimensional key points may be obtained first.
在一些实施例中,获取所述三维关键点在所述待处理图像中的投影点;根据所述待处理图像中所述目标对象和所述三维关键点的投影点,确定所述目标对象的边界上的投影点;将所述目标对象的边界上的投影点所对应的三维关键点,确定为所述第一边缘点。In some embodiments, the projection point of the three-dimensional key point in the image to be processed is obtained; according to the projection point of the target object and the three-dimensional key point in the image to be processed, determine the target object A projection point on the boundary: determining a 3D key point corresponding to the projection point on the boundary of the target object as the first edge point.
示例性的,确定目标对象的边界上的投影点时,可以在待处理图像中预设方向上设置多个直线,例如预先设置多个横向的直线,然后基于所述三维关键点中投影在所述多个直线上的点,确定处于目标对象的边界上的投影点。Exemplarily, when determining the projection point on the boundary of the target object, a plurality of straight lines can be set in the preset direction in the image to be processed, for example, a plurality of horizontal straight lines can be set in advance, and then projected on the basis of the three-dimensional key points The points on the plurality of straight lines are determined to determine the projected points on the boundary of the target object.
本步骤中,可以在所有所述三维关键点中的中心点(例如目标对象的中心点,例如位于鼻子上)和所述第一边缘点的连线的延长线上,确定与所述第一边缘点间隔预设距离的点为所述第一边缘点对应的第二边缘点。In this step, it may be determined on the extension line of the line between the central point of all the three-dimensional key points (for example, the central point of the target object, for example, located on the nose) and the first edge point, and determine the connection with the first edge point. A point at which the edge points are separated by a preset distance is a second edge point corresponding to the first edge point.
在一些实施例中,可以根据各个三维关键点的坐标信息进行计算,从而得到多个三维关键点中的中心点,即位于目标对象的中心的三维关键点。然后在中心点和目标对象的每个边缘点之间构建直线,并在直线上进一步向外延长预设距离(该距离可以提前预设,可以根据目标对象的尺寸进行设置,例如为目标对象的宽度的1/10),则延长线的顶点即为该边缘点对应的第二边缘点。In some embodiments, the calculation may be performed according to the coordinate information of each 3D key point, so as to obtain the center point among the multiple 3D key points, that is, the 3D key point located at the center of the target object. Then construct a straight line between the center point and each edge point of the target object, and further extend the preset distance outward on the straight line (the distance can be preset in advance and can be set according to the size of the target object, for example, for the target object 1/10 of the width), then the vertex of the extension line is the second edge point corresponding to the edge point.
本步骤中,可以按照预先制定的第二拓扑结构,在所述第一边缘点的调整结果和所述第二边缘点之间构建第二网格,得到所述三维扩展模型。In this step, a second grid may be constructed between the adjustment result of the first edge point and the second edge point according to the second pre-established topological structure, so as to obtain the three-dimensional extended model.
预先制定的第二拓扑结构,指的是多个第一边缘点和多个第二边缘点间的网格中,点的连线关系,例如每个点需要与其他哪些点连接。例如,所有的第一边缘点依次连线, 形成三维扩展模型的内圈;所有的第二边缘点依次连线,形成三维扩展模型的外圈;然后每个第一边缘点与其对应的第二边缘点连线,且该第一边缘点与对应的第二边缘点下一个第二边缘点也连线,从而形成三维扩展模型内的第二网格。第二拓扑结构是以第一边缘点和第二边缘点的次序进行记载的,因此当第一边缘点被调整后,依然可以按照该拓扑结构构建第二网格。The pre-established second topology refers to the connection relationship of points in the grid between multiple first edge points and multiple second edge points, for example, which other points each point needs to be connected to. For example, all the first edge points are connected sequentially to form the inner circle of the 3D extended model; all the second edge points are connected sequentially to form the outer circle of the 3D extended model; then each first edge point and its corresponding second The edge points are connected with a line, and the first edge point and the second edge point next to the corresponding second edge point are also connected with a line, thereby forming a second grid in the three-dimensional extended model. The second topology is recorded in the order of the first edge point and the second edge point, so after the first edge point is adjusted, the second grid can still be constructed according to the topology.
三维扩展模型是环绕在位于目标对象的轮廓上的三维关键点周围的模型,该模型的外圈(即第二边缘点所围成的圈)是未被调整的,该模型的内圈(即第一边缘点所围成的圈)是被调整过的,因为第一边缘点被调整了。The three-dimensional extended model is a model that surrounds the three-dimensional key points located on the contour of the target object. The outer circle of the model (ie, the circle surrounded by the second edge point) is not adjusted, and the inner circle of the model (ie, The circle surrounded by the first edge point) is adjusted, because the first edge point is adjusted.
上述实施例中已经提到,在各个三维关键点的调整结果之间构建第一网格后,形成了目标对象的目标模型。而在所述第一边缘点的调整结果和所述第二边缘点之间构建第二网格后,则目标模型周围添加了三维扩展模型,而且目标模型和三维扩展模型是通过第一边缘点相连,为描述方便,下文可以将连为一体的目标模型和三维扩展模型称之为综合模型。请参照附图7,其示出了目标对象为脸部时,综合模型的示意图。It has been mentioned in the above-mentioned embodiments that after the first grid is constructed between the adjustment results of the various three-dimensional key points, the target model of the target object is formed. After the second grid is constructed between the adjustment result of the first edge point and the second edge point, a 3D extended model is added around the target model, and the target model and the 3D extended model pass through the first edge point For the convenience of description, the target model and the 3D extended model connected as one can be referred to as an integrated model in the following. Please refer to FIG. 7 , which shows a schematic diagram of an integrated model when the target object is a face.
在步骤S602中,根据所述三维扩展模型和所述待处理图像,在所述待处理图像上渲染所述三维扩展模型。In step S602, the 3D extended model is rendered on the image to be processed according to the 3D extended model and the image to be processed.
可以提取所述第一边缘点在所述待处理图像上的投影点的像素信息,由于第一边缘点的像素信息在第一边缘点调整前后是不变的,因此所述第一边缘点在所述待处理图像上的投影点的像素信息也可以作为所述第一边缘点的调整结果的像素信息;提取所述第二边缘点在所述待处理图像上的投影点的像素信息,作为所述第二边缘点的像素信息;根据所述第一边缘点的调整结果的像素信息和所述第二边缘点的像素信息,渲染所述第二网格,得到所述第二网格内的像素信息;根据所述第一边缘点的调整结果和所述第二边缘点在所述待处理图像上的投影点的坐标信息,将所述第一边缘点的调整结果的像素信息、所述第二边缘点的像素信息和所述第二网格内的像素信息,投影到所述待处理图像上。The pixel information of the projection point of the first edge point on the image to be processed can be extracted. Since the pixel information of the first edge point is unchanged before and after the adjustment of the first edge point, the first edge point is The pixel information of the projection point on the image to be processed may also be used as the pixel information of the adjustment result of the first edge point; the pixel information of the projection point of the second edge point on the image to be processed is extracted as The pixel information of the second edge point; according to the pixel information of the adjustment result of the first edge point and the pixel information of the second edge point, render the second grid to obtain the second grid pixel information; according to the adjustment result of the first edge point and the coordinate information of the projection point of the second edge point on the image to be processed, the pixel information of the adjustment result of the first edge point, the The pixel information of the second edge point and the pixel information in the second grid are projected onto the image to be processed.
上述操作与步骤S502中的操作方式基本相同,因此可以参照步骤S502的操作方式,执行步骤S602。或者说,可以在执行步骤S502之前,按照本实施例的提供的方式在目标模型周围构建三维扩展模型,得到综合模型,然后再按照步骤S502介绍的操作方式对综合模型进行操作,从而一次性将目标对象和周围的一圈图像投影到待处理图像上,得到目标图像。The above operation is basically the same as the operation in step S502, so step S602 can be executed with reference to the operation in step S502. In other words, before performing step S502, a three-dimensional extended model can be constructed around the target model according to the method provided in this embodiment to obtain a comprehensive model, and then the comprehensive model can be operated according to the operation method introduced in step S502, so that the The target object and surrounding images are projected onto the image to be processed to obtain the target image.
本实施例中,通过确定环绕在三维关键点组成的目标模型周围的第二边缘点,并进一步确定三维扩展模型,从而可以在将目标模型的调整结果投射到待处理图像的同时,将三维扩展模型的调整结果投射到待处理图像上。由于三维扩展模型的外圈是未被调整的,因此目标图像中三维扩展模型对应的区域与周围区域的连接部分较为自然,不存在突兀的衔接;而虽然三维扩展模型的内圈是被调整过的,但三维扩展模型内的第二网格中的像素信息是被渲染出来的,因此目标图像中三维扩展模型对应的区域与目标对象对应的区域连接部分也比较自然,不会存在突兀的衔接。换句话说,包括目标模型和三维扩展模型的综合模型外部未经过调整,因此整个综合模型在目标图像上的边缘区域与待处理图像上的对应区域是相同的;而综合模型内部(目标模型)经过调整,但经过调整的目标模型在渲染过程中由于每个子网格内的像素点的像素信息是相同的,因此能够克服由于调整造成的不协调和不自然等问题,因此该部分(综合模型内部的目标模型)在目标对象上所对应的区域也是自然的。In this embodiment, by determining the second edge points surrounding the target model composed of three-dimensional key points, and further determining the three-dimensional extension model, the three-dimensional extension The adjusted results of the model are projected onto the image to be processed. Since the outer ring of the 3D extended model has not been adjusted, the connection between the area corresponding to the 3D extended model and the surrounding area in the target image is relatively natural, and there is no abrupt connection; and although the inner ring of the 3D extended model has been adjusted Yes, but the pixel information in the second grid in the 3D extended model is rendered, so the connection between the area corresponding to the 3D extended model in the target image and the area corresponding to the target object is relatively natural, and there will be no abrupt connection . In other words, the outside of the integrated model including the target model and the 3D extended model has not been adjusted, so the edge area of the entire integrated model on the target image is the same as the corresponding area on the image to be processed; while the inside of the integrated model (target model) After adjustment, the adjusted target model can overcome the uncoordinated and unnatural problems caused by the adjustment because the pixel information of the pixels in each sub-grid is the same during the rendering process, so this part (comprehensive model The corresponding region on the target object is also natural.
下面以脸部的微调处理为例,介绍本公开提供的图像处理方法的一个完整过程。Taking the fine-tuning processing of the face as an example, a complete process of the image processing method provided by the present disclosure will be introduced below.
首先导入三维标准模型(例如,标准脸部3D模型),并采用计算欧氏距离的方式 建立预制的三维调整模型中顶点与三维标准模型中顶点的第二对应关系,并将第二对应关系存储到查找表中,其中三维调整模型中顶点与三维标准模型中顶点均包括例如反映次序的标识,三维调整模型的各个顶点还记录了表示不同调整项目对应的预设形变数据的数组;提取待处理图像中脸部的三维关键点,其中每个三维关键点包括例如反映次序的标识,在标识相同的三维关键点和三维标准模型中顶点间建立第三对应关系,根据第二对应关系和第三对应关系,建立三维关键点与三维调整模型中顶点间的第一对应关系,根据第一对应关系将三维关键点的标识更新到三维调整模型中对应顶点的数组中。First import a 3D standard model (for example, a standard face 3D model), and use the method of calculating the Euclidean distance to establish the second corresponding relationship between the vertices in the prefabricated 3D adjustment model and the vertices in the 3D standard model, and store the second corresponding relationship In the lookup table, the vertices in the three-dimensional adjustment model and the vertices in the three-dimensional standard model all include, for example, the identification of the reflection order, and each vertex of the three-dimensional adjustment model also records an array representing preset deformation data corresponding to different adjustment items; extraction to be processed The three-dimensional key points of the face in the image, wherein each three-dimensional key point includes, for example, an identification reflecting the order, and a third corresponding relationship is established between the three-dimensional key points with the same identification and the vertices in the three-dimensional standard model, according to the second corresponding relationship and the third The corresponding relationship is to establish a first corresponding relationship between the 3D key point and the vertex in the 3D adjustment model, and update the identification of the 3D key point to the array of the corresponding vertex in the 3D adjustment model according to the first corresponding relationship.
接下来,在待处理图像上确定每个三维关键点的投影点,然后在待处理图像的脸部上构建横线,并在每条横向上的多个投影点中确定位于脸部边界上的投影点,并将位于边界上的投影点所对应的三维关键点确定为第一边缘点,计算所有三维关键点中的中心点,并且将中心点与第一边缘点的连线延长一个单位长度得到第二边缘点,然后在第一边缘点和第二边缘点间构建第二网格,组成三维扩展模型。Next, determine the projection point of each 3D key point on the image to be processed, and then construct a horizontal line on the face of the image to be processed, and determine the one located on the boundary of the face among the multiple projection points on each horizontal line Projection points, and determine the 3D key point corresponding to the projection point on the boundary as the first edge point, calculate the center point of all 3D key points, and extend the connection line between the center point and the first edge point by one unit length The second edge point is obtained, and then a second grid is constructed between the first edge point and the second edge point to form a three-dimensional extended model.
根据当前设置的调整项目(例如大眼、瘦脸等)和调整参数值(即调整程度),即三维调整模型中顶点的形变数据,对至少一个三维关键点进行移动。在一些实施例中,可以遍历三维调整模型中每个顶点的数组,并且将该调整项目下顶点的形变数据与调整参数值相乘得到该顶点的位移数据,并且利用该顶点的位移数据对其数组对应的三维关键点进行位移,得到三维关键点的位移结果。再在三维关键点的位移结果间构建第一网格,并将第一网格和第二网格通过第一边缘点连接为一个整体,得到综合模型。At least one 3D key point is moved according to currently set adjustment items (such as big eyes, thin face, etc.) and adjustment parameter values (ie, adjustment degree), that is, deformation data of vertices in the 3D adjustment model. In some embodiments, the array of each vertex in the three-dimensional adjustment model can be traversed, and the deformation data of the vertex under the adjustment item is multiplied by the adjustment parameter value to obtain the displacement data of the vertex, and the displacement data of the vertex is used to compare The three-dimensional key points corresponding to the array are displaced, and the displacement results of the three-dimensional key points are obtained. Then construct the first grid between the displacement results of the three-dimensional key points, and connect the first grid and the second grid as a whole through the first edge point to obtain a comprehensive model.
最后,在综合模型上贴上待处理图像,然后将综合模型渲染到待处理图像上,得到用于呈现脸部调整效果的目标图像。在一些实施例中,可以先将待处理图像渲染到输出图像上,例如通过OpenGL等渲染API的图像拷贝操作,将待处理图像拷贝到输出图像上;然后将待处理图像作为渲染流程的输入图像,将每个三维关键点在待处理图像上的投影点的坐标作为输入图像的纹理采样坐标;通过三维调整模型的模型变换矩阵将三维关键点的调整结果的坐标转换至世界坐标系,通过世界坐标系到裁剪空间的变换矩阵,将世界坐标系内的三维关键点的调整结果的坐标转换至裁剪坐标系,并送给后续片元渲染阶段即可实现实时3D调整效果的呈现。Finally, the image to be processed is pasted on the integrated model, and then the integrated model is rendered on the image to be processed to obtain the target image for presenting the face adjustment effect. In some embodiments, the image to be processed can be rendered on the output image first, for example, the image to be processed can be copied to the output image through an image copy operation of a rendering API such as OpenGL; then the image to be processed can be used as the input image of the rendering process , the coordinates of the projection points of each 3D key point on the image to be processed are taken as the texture sampling coordinates of the input image; the coordinates of the adjustment results of the 3D key points are converted to the world coordinate system through the model transformation matrix of the 3D adjustment model, and the world The transformation matrix from the coordinate system to the clipping space converts the coordinates of the adjustment results of the 3D key points in the world coordinate system to the clipping coordinate system, and sends them to the subsequent fragment rendering stage to realize the presentation of the real-time 3D adjustment effect.
根据本公开实施例的第二方面,提供一种图像处理装置,请参照附图8,其示出了该装置的结构,包括:获取模块801,用于获取待处理图像,其中,所述待处理图像包括目标对象;第一对应模块802,用于提取所述目标对象的三维关键点,并确定所述三维关键点与三维调整模型中顶点之间的第一对应关系;调整模块803,用于根据调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果;目标模块804,用于根据所述三维关键点的调整结果和所述待处理图像,确定目标图像。According to the second aspect of the embodiments of the present disclosure, an image processing device is provided. Please refer to FIG. The processed image includes the target object; the first correspondence module 802 is used to extract the 3D key points of the target object, and determine the first correspondence between the 3D key points and the vertices in the 3D adjustment model; the adjustment module 803 uses Determine the adjustment result of the 3D key point according to the adjustment instruction, the preset deformation data of the vertices in the 3D adjustment model and the first corresponding relationship; the target module 804 is used to determine the adjustment result of the 3D key point according to the adjustment result and the image to be processed to determine a target image.
在本公开的一些实施例中,还包括第二对应模块,用于:获取所述三维调整模型中顶点与三维标准模型中顶点之间的第二对应关系;所述第一对应模块用于:根据所述三维关键点的标识和所述三维标准模型中顶点的标识,确定所述三维关键点与所述三维标准模型中顶点之间的第三对应关系;根据所述第二对应关系和所述第三对应关系,确定所述第一对应关系。In some embodiments of the present disclosure, a second corresponding module is also included, configured to: obtain a second corresponding relationship between the vertices in the 3D adjustment model and the vertices in the 3D standard model; the first corresponding module is configured to: According to the identification of the 3D key point and the identification of the vertex in the 3D standard model, determine the third corresponding relationship between the 3D key point and the vertex in the 3D standard model; according to the second corresponding relationship and the vertex in the 3D standard model The third corresponding relationship is determined, and the first corresponding relationship is determined.
在本公开的一些实施例中,所述第二对应模块用于:将所述三维调整模型中顶点的坐标与所述三维标准模型中顶点的坐标,转换至相同的坐标系内;根据所述三维调整模型中每个顶点与所述三维标准模型中每个顶点间的欧氏距离,确定所述第二对应关系。In some embodiments of the present disclosure, the second corresponding module is used to: convert the coordinates of vertices in the three-dimensional adjustment model and the coordinates of vertices in the three-dimensional standard model into the same coordinate system; according to the The Euclidean distance between each vertex in the three-dimensional adjustment model and each vertex in the three-dimensional standard model is used to determine the second corresponding relationship.
在本公开的一些实施例中,所述第一对应模块用于根据所述三维关键点的标识和所述三维标准模型中顶点的标识,确定所述三维关键点与所述三维标准模型中顶点之间的第三对应关系时,用于:将标识相同的所述三维关键点和所述三维标准模型的顶点,确 定为相互对应的顶点对,得到所述第三对应关系。In some embodiments of the present disclosure, the first corresponding module is configured to determine the 3D key point and the vertex in the 3D standard model according to the identification of the 3D key point and the identification of the vertex in the 3D standard model For the third corresponding relationship, it is used to: determine the same 3D key point and the vertices of the 3D standard model as a pair of vertices corresponding to each other, so as to obtain the third corresponding relationship.
在本公开的一些实施例中,所述调整模块用于:根据所述调整指令确定目标对象的调整项目;获取所述三维调整模型中顶点的预设形变数据中,与所述调整项目对应的第一形变数据;根据所述第一形变数据,对所述三维调整模型中至少一个顶点对应的所述三维关键点进行位移,得到所述三维关键点的调整结果。In some embodiments of the present disclosure, the adjustment module is configured to: determine the adjustment item of the target object according to the adjustment instruction; obtain the preset deformation data of the vertex in the three-dimensional adjustment model, which corresponds to the adjustment item First deformation data: Displacing the 3D key point corresponding to at least one vertex in the 3D adjustment model according to the first deformation data, to obtain an adjustment result of the 3D key point.
在本公开的一些实施例中,所述调整模块还用于:得到所述三维关键点的调整结果之前,根据所述调整指令确定所述调整项目的调整参数值;根据所述调整参数值对所述第一形变数据进行调整。In some embodiments of the present disclosure, the adjustment module is further configured to: determine the adjustment parameter value of the adjustment item according to the adjustment instruction before obtaining the adjustment result of the three-dimensional key point; The first deformation data is adjusted.
在本公开的一些实施例中,所述目标模块用于:按照预先制定的第一拓扑结构,在所述三维关键点的调整结果之间构建第一网格;根据所述三维关键点在所述待处理图像上的投影点的像素信息、所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息以及所述第一网格,在所述待处理图像上渲染所述目标对象的调整结果,得到目标图像。In some embodiments of the present disclosure, the target module is configured to: construct a first grid between the adjustment results of the 3D key points according to a pre-established first topology structure; The pixel information of the projection point on the image to be processed, the coordinate information of the projection point of the adjustment result of the three-dimensional key point on the image to be processed, and the first grid, and render the image on the image to be processed The adjustment result of the target object is obtained to obtain the target image.
在本公开的一些实施例中,所述目标模块还用于:提取所述三维关键点在所述待处理图像上的投影点的像素信息,作为所述三维关键点的调整结果的像素信息;根据所述三维关键点的调整结果的像素信息,渲染所述第一网格,得到所述第一网格内的像素信息;根据所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息,将所述三维关键点的像素信息和所述第一网格内的像素信息投影到所述待处理图像上,得到所述目标图像。In some embodiments of the present disclosure, the target module is further configured to: extract the pixel information of the projection point of the 3D key point on the image to be processed, as the pixel information of the adjustment result of the 3D key point; Rendering the first grid according to the pixel information of the adjustment result of the three-dimensional key point to obtain pixel information in the first grid; according to the adjustment result of the three-dimensional key point on the image to be processed Projecting the coordinate information of the point, projecting the pixel information of the three-dimensional key point and the pixel information in the first grid onto the image to be processed to obtain the target image.
在本公开的一些实施例中,还包括扩展模块,用于:生成环绕所述三维关键点的三维扩展模型,其中,所述三维扩展模型中的顶点包括第一边缘点的调整结果及基于所述第一边缘点扩展得到的第二边缘点,所述第一边缘点为对应所述目标对象的边界的三维关键点;根据所述三维扩展模型和所述待处理图像,在所述待处理图像上渲染所述三维扩展模型。In some embodiments of the present disclosure, an extension module is also included, configured to: generate a 3D extended model surrounding the 3D key point, wherein the vertices in the 3D extended model include the adjustment result of the first edge point and based on the The second edge point obtained by extending the first edge point, the first edge point is a three-dimensional key point corresponding to the boundary of the target object; according to the three-dimensional extended model and the image to be processed, in the to-be-processed The three-dimensional extended model is rendered on the image.
在本公开的一些实施例中,所述扩展模块还用于:获取所述第一边缘点;在所述三维关键点中的中心点和所述第一边缘点的连线的延长线上,确定与所述第一边缘点间隔预设距离的点为所述第二边缘点;按照预先制定的第二拓扑结构,在所述第一边缘点的调整结果和所述第二边缘点之间构建第二网格,得到所述三维扩展模型。In some embodiments of the present disclosure, the expansion module is further configured to: obtain the first edge point; on an extension line of a line connecting the center point of the three-dimensional key point and the first edge point, Determining a point at a preset distance from the first edge point as the second edge point; according to a pre-established second topology, between the adjustment result of the first edge point and the second edge point Construct the second grid to obtain the 3D extended model.
在本公开的一些实施例中,所述扩展模块还用于:获取所述三维关键点在所述待处理图像中的投影点;根据所述目标对象及所述三维关键点在所述待处理图像中的投影点,确定所述目标对象的边界上的投影点;将所述目标对象的边界上的投影点所对应的三维关键点,确定为所述第一边缘点。In some embodiments of the present disclosure, the extension module is further configured to: obtain the projection point of the 3D key point in the image to be processed; according to the target object and the 3D key point in the image to be processed The projection point in the image is determined as the projection point on the boundary of the target object; and the three-dimensional key point corresponding to the projection point on the boundary of the target object is determined as the first edge point.
在本公开的一些实施例中,所述扩展模块还用于:在所述待处理图像中的预设方向上设置多个直线;基于所述三维关键点中投影在所述多个直线上的点,确定处于所述目标对象的边界上的投影点。In some embodiments of the present disclosure, the expansion module is further configured to: set a plurality of straight lines in preset directions in the image to be processed; points, determine the projected points that lie on the boundary of the target object.
在本公开的一些实施例中,所述扩展模块还用于:提取所述第一边缘点在所述待处理图像上的投影点的像素信息,作为所述第一边缘点的调整结果的像素信息,并提取所述第二边缘点在所述待处理图像上的投影点的像素信息,作为所述第二边缘点的像素信息;根据所述第一边缘点的调整结果的像素信息和所述第二边缘点的像素信息,渲染所述第二网格,得到所述第二网格内的像素信息;根据所述第一边缘点的调整结果和所述第二边缘点在所述待处理图像上的投影点的坐标信息,将所述第一边缘点的调整结果的像素信息、所述第二边缘点的像素信息和所述第二网格内的像素信息,投影到所述待处理图像上。In some embodiments of the present disclosure, the extension module is further configured to: extract pixel information of a projection point of the first edge point on the image to be processed, as a pixel of the adjustment result of the first edge point information, and extract the pixel information of the projection point of the second edge point on the image to be processed as the pixel information of the second edge point; according to the pixel information of the adjustment result of the first edge point and the pixel information of the second edge point, render the second grid, and obtain pixel information in the second grid; according to the adjustment result of the first edge point and the second edge point in the Processing the coordinate information of the projection point on the image, projecting the pixel information of the adjustment result of the first edge point, the pixel information of the second edge point, and the pixel information in the second grid to the waiting processing image.
在本公开的一些实施例中,所述目标对象包括所述待处理图像中以下至少一个对象:脸部、手部、肢体。In some embodiments of the present disclosure, the target object includes at least one of the following objects in the image to be processed: face, hand, and limb.
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在第一方面有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the apparatus in the above embodiments, the specific manner in which each module executes operations has been described in detail in the embodiment of the method in the first aspect, and will not be described in detail here.
第三方面,本公开至少一个实施例提供了一种设备,请参照附图9,其示出了该设备的结构,所述设备包括存储器904、处理器901、网络接口903,它们通过内部总线902耦接,所述存储器用于存储可在处理器上运行的计算机指令,所述处理器用于在执行所述计算机指令时基于第一方面任一项所述的方法对图像进行处理。In a third aspect, at least one embodiment of the present disclosure provides a device. Please refer to FIG. 9 , which shows the structure of the device. The device includes a memory 904, a processor 901, and a network interface 903. Coupled with 902, the memory is used to store computer instructions that can be run on a processor, and the processor is used to process the image based on the method described in any one of the first aspect when executing the computer instructions.
第四方面,本公开至少一个实施例提供了一种计算机可读存储介质,其上存储有计算机程序,所述程序被处理器执行时实现第一方面任一项所述的方法。In a fourth aspect, at least one embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the first aspect is implemented.
第五方面,本公开至少一个实施例提供了一种计算机程序产品,该产品包括计算机程序,当所述计算机程序被处理器执行时实现第一方面任一项所述的方法In a fifth aspect, at least one embodiment of the present disclosure provides a computer program product, the product includes a computer program, and when the computer program is executed by a processor, the method described in any one of the first aspect is implemented
本公开涉及增强现实领域,通过获取现实环境中的目标对象的图像信息,进而借助各类视觉相关算法实现对目标对象的相关特征、状态及属性进行检测或识别处理,从而得到与具体应用匹配的虚拟与现实相结合的AR效果。示例性的,目标对象可涉及与人体相关的脸部、肢体、手势、动作等,或者与物体相关的标识物、标志物,或者与场馆或场所相关的沙盘、展示区域或展示物品等。视觉相关算法可涉及视觉定位、SLAM、三维重建、图像注册、背景分割、对象的关键点提取及跟踪、对象的位姿或深度检测等。具体应用不仅可以涉及跟真实场景或物品相关的导览、导航、讲解、重建、虚拟效果叠加展示等交互场景,还可以涉及与人相关的特效处理,比如妆容美化、肢体美化、特效展示、虚拟模型展示等交互场景。可通过卷积神经网络,实现对目标对象的相关特征、状态及属性进行检测或识别处理。上述卷积神经网络是基于深度学习框架进行模型训练而得到的网络模型。This disclosure relates to the field of augmented reality. By acquiring the image information of the target object in the real environment, and then using various visual correlation algorithms to detect or identify the relevant features, states and attributes of the target object, and thus obtain the image information that matches the specific application. AR effect combining virtual and reality. Exemplarily, the target object may involve faces, limbs, gestures, actions, etc. related to the human body, or markers and markers related to objects, or sand tables, display areas or display items related to venues or places. Vision-related algorithms can involve visual positioning, SLAM, 3D reconstruction, image registration, background segmentation, object key point extraction and tracking, object pose or depth detection, etc. Specific applications can not only involve interactive scenes such as guided tours, navigation, explanations, reconstructions, virtual effect overlays and display related to real scenes or objects, but also special effects processing related to people, such as makeup beautification, body beautification, special effect display, virtual Interactive scenarios such as model display. The relevant features, states and attributes of the target object can be detected or identified through the convolutional neural network. The above-mentioned convolutional neural network is a network model obtained by performing model training based on a deep learning framework.
在本公开中,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性。术语“多个”指两个或两个以上,除非另有明确的限定。In the present disclosure, the terms "first" and "second" are used for descriptive purposes only, and should not be understood as indicating or implying relative importance. The term "plurality" means two or more, unless otherwise clearly defined.
本领域技术人员在考虑说明书及实践这里公开的公开后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Other embodiments of the disclosure will be readily apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. The present disclosure is intended to cover any modification, use or adaptation of the present disclosure. These modifications, uses or adaptations follow the general principles of the present disclosure and include common knowledge or conventional technical means in the technical field not disclosed in the present disclosure. . The specification and examples are to be considered exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It should be understood that the present disclosure is not limited to the precise constructions which have been described above and shown in the drawings, and 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 (18)

  1. 一种图像处理方法,包括:An image processing method, comprising:
    获取待处理图像,其中,所述待处理图像包括目标对象;acquiring an image to be processed, wherein the image to be processed includes a target object;
    提取所述目标对象的三维关键点,并确定所述三维关键点与三维调整模型中顶点之间的第一对应关系;extracting 3D key points of the target object, and determining a first correspondence between the 3D key points and vertices in the 3D adjustment model;
    根据调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果;determining the adjustment result of the three-dimensional key points according to the adjustment instruction, the preset deformation data of the vertices in the three-dimensional adjustment model, and the first corresponding relationship;
    根据所述三维关键点的调整结果和所述待处理图像,确定目标图像。A target image is determined according to the adjustment result of the three-dimensional key points and the image to be processed.
  2. 根据权利要求1所述的图像处理方法,还包括:The image processing method according to claim 1, further comprising:
    获取所述三维调整模型中顶点与三维标准模型中顶点之间的第二对应关系;Acquiring a second corresponding relationship between vertices in the three-dimensional adjustment model and vertices in the three-dimensional standard model;
    确定所述三维关键点与所述三维调整模型中顶点之间的第一对应关系,包括:Determining the first corresponding relationship between the 3D key points and the vertices in the 3D adjustment model includes:
    根据所述三维关键点的标识和所述三维标准模型中顶点的标识,确定所述三维关键点与所述三维标准模型中顶点之间的第三对应关系;determining a third correspondence between the three-dimensional key points and the vertices in the three-dimensional standard model according to the identification of the three-dimensional key points and the identification of vertices in the three-dimensional standard model;
    根据所述第二对应关系和所述第三对应关系,确定所述第一对应关系。Determine the first correspondence according to the second correspondence and the third correspondence.
  3. 根据权利要求2所述的图像处理方法,其中,获取所述三维调整模型中顶点与所述三维标准模型中顶点之间的第二对应关系,包括:The image processing method according to claim 2, wherein obtaining the second corresponding relationship between the vertices in the three-dimensional adjustment model and the vertices in the three-dimensional standard model comprises:
    将所述三维调整模型中顶点的坐标与所述三维标准模型中顶点的坐标,转换至相同的坐标系内;converting the coordinates of the vertices in the three-dimensional adjustment model and the coordinates of the vertices in the three-dimensional standard model into the same coordinate system;
    根据所述三维调整模型中每个顶点与所述三维标准模型中每个顶点间的欧氏距离,确定所述第二对应关系。The second corresponding relationship is determined according to the Euclidean distance between each vertex in the three-dimensional adjustment model and each vertex in the three-dimensional standard model.
  4. 根据权利要求2所述的图像处理方法,其中,根据所述三维关键点的标识和所述三维标准模型中顶点的标识,确定所述三维关键点与所述三维标准模型中顶点之间的第三对应关系,包括:The image processing method according to claim 2, wherein, according to the identification of the 3D key point and the identification of the vertex in the 3D standard model, determine the first position between the 3D key point and the vertex in the 3D standard model Three correspondences, including:
    将标识相同的所述三维关键点和所述三维标准模型的顶点,确定为相互对应的顶点对,得到所述第三对应关系。Determining the same 3D key point and vertices of the 3D standard model as a pair of vertices corresponding to each other to obtain the third corresponding relationship.
  5. 根据权利要求1至4中任一项所述的图像处理方法,其中,根据所述调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果,包括:The image processing method according to any one of claims 1 to 4, wherein the three-dimensional key is determined according to the adjustment instruction, the preset deformation data of vertices in the three-dimensional adjustment model and the first correspondence Point adjustment results, including:
    根据所述调整指令确定所述目标对象的调整项目;determining adjustment items of the target object according to the adjustment instruction;
    获取所述三维调整模型中顶点的预设形变数据中与所述调整项目对应的第一形变数据;Obtaining the first deformation data corresponding to the adjustment item among the preset deformation data of vertices in the three-dimensional adjustment model;
    根据所述第一形变数据,对所述三维调整模型中至少一个顶点对应的三维关键点进行位移,得到所述三维关键点的调整结果。According to the first deformation data, a 3D key point corresponding to at least one vertex in the 3D adjustment model is displaced to obtain an adjustment result of the 3D key point.
  6. 根据权利要求5所述的图像处理方法,其中,在得到所述三维关键点的调整结果之前,还包括:The image processing method according to claim 5, wherein, before obtaining the adjustment result of the three-dimensional key points, further comprising:
    根据所述调整指令确定所述调整项目的调整参数值;determining an adjustment parameter value of the adjustment item according to the adjustment instruction;
    根据所述调整参数值对所述第一形变数据进行调整。The first deformation data is adjusted according to the adjustment parameter value.
  7. 根据权利要求1至4中任一项所述的图像处理方法,其中,根据所述三维关键点的调整结果和所述待处理图像,确定目标图像,包括:The image processing method according to any one of claims 1 to 4, wherein, according to the adjustment result of the three-dimensional key points and the image to be processed, determining the target image includes:
    按照预先制定的第一拓扑结构,在所述三维关键点的调整结果之间构建第一网格;Constructing a first grid between the adjustment results of the 3D key points according to a pre-established first topology structure;
    根据所述三维关键点在所述待处理图像上的投影点的像素信息、所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息以及所述第一网格,在所述待处理图像上渲染所述目标对象的调整结果,得到目标图像。According to the pixel information of the projection point of the 3D key point on the image to be processed, the coordinate information of the projection point of the adjustment result of the 3D key point on the image to be processed, and the first grid, in The adjustment result of the target object is rendered on the image to be processed to obtain a target image.
  8. 根据权利要求7所述的图像处理方法,其中,根据所述三维关键点在所述待处理图像上的投影点的像素信息、所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息以及所述第一网格,在所述待处理图像上渲染所述目标对象的调整结果, 得到所述目标图像,包括:The image processing method according to claim 7, wherein, according to the pixel information of the projection point of the three-dimensional key point on the image to be processed, the projection of the adjustment result of the three-dimensional key point on the image to be processed Coordinate information of the point and the first grid, rendering the adjustment result of the target object on the image to be processed, and obtaining the target image, including:
    提取所述三维关键点在所述待处理图像上的投影点的像素信息,作为所述三维关键点的调整结果的像素信息;Extracting the pixel information of the projection point of the three-dimensional key point on the image to be processed, as the pixel information of the adjustment result of the three-dimensional key point;
    根据所述三维关键点的调整结果的像素信息,渲染所述第一网格,得到所述第一网格内的像素信息;Rendering the first grid according to the pixel information of the adjustment result of the three-dimensional key points to obtain the pixel information in the first grid;
    根据所述三维关键点的调整结果在所述待处理图像上的投影点的坐标信息,将所述三维关键点的像素信息和所述第一网格内的像素信息投影到所述待处理图像上,得到所述目标图像。Projecting the pixel information of the 3D key point and the pixel information in the first grid to the image to be processed according to the coordinate information of the projection point of the adjustment result of the 3D key point on the image to be processed on, get the target image.
  9. 根据权利要求1至4中任一项所述的图像处理方法,还包括:The image processing method according to any one of claims 1 to 4, further comprising:
    生成环绕所述三维关键点的三维扩展模型,其中,所述三维扩展模型中的顶点包括第一边缘点的调整结果及基于所述第一边缘点扩展得到的第二边缘点,所述第一边缘点为对应所述目标对象的边界的三维关键点;generating a 3D extended model surrounding the 3D key point, wherein the vertices in the 3D extended model include an adjustment result of a first edge point and a second edge point obtained based on the extension of the first edge point, the first The edge point is a three-dimensional key point corresponding to the boundary of the target object;
    根据所述三维扩展模型和所述待处理图像,在所述待处理图像上渲染所述三维扩展模型。Render the 3D extended model on the image to be processed according to the 3D extended model and the image to be processed.
  10. 根据权利要求9所述的图像处理方法,其中,生成环绕所述三维关键点的三维扩展模型,包括:The image processing method according to claim 9, wherein generating a three-dimensional extended model surrounding the three-dimensional key point comprises:
    获取所述第一边缘点;obtaining the first edge point;
    在所述三维关键点中的中心点和所述第一边缘点的连线的延长线上,确定与所述第一边缘点间隔预设距离的点为所述第二边缘点;On the extension line of the line connecting the central point in the three-dimensional key point and the first edge point, determine a point at a preset distance from the first edge point as the second edge point;
    按照预先制定的第二拓扑结构,在所述第一边缘点的调整结果和所述第二边缘点之间构建第二网格,得到所述三维扩展模型。According to the pre-established second topology structure, a second grid is constructed between the adjustment result of the first edge point and the second edge point to obtain the three-dimensional extended model.
  11. 根据权利要求10所述的图像处理方法,其中,获取所述第一边缘点,包括:The image processing method according to claim 10, wherein obtaining the first edge point comprises:
    获取所述三维关键点在所述待处理图像中的投影点;Acquiring projection points of the three-dimensional key points in the image to be processed;
    根据所述目标对象及所述三维关键点在所述待处理图像中的投影点,确定所述目标对象的边界上的投影点;determining a projection point on the boundary of the target object according to the projection point of the target object and the three-dimensional key point in the image to be processed;
    将所述目标对象的边界上的投影点所对应的三维关键点,确定为所述第一边缘点。A three-dimensional key point corresponding to a projection point on the boundary of the target object is determined as the first edge point.
  12. 根据权利要求11所述的图像处理方法,其中,根据所述目标对象及所述三维关键点在所述待处理图像中的投影点,确定所述目标对象的边界上的投影点,包括:The image processing method according to claim 11, wherein, according to the target object and the projection point of the three-dimensional key point in the image to be processed, determining the projection point on the boundary of the target object comprises:
    在所述待处理图像中的预设方向上设置多个直线;setting a plurality of straight lines in preset directions in the image to be processed;
    基于所述三维关键点中投影在所述多个直线上的点,确定处于所述目标对象的边界上的投影点。Based on the points projected on the plurality of straight lines among the three-dimensional key points, a projected point on the boundary of the target object is determined.
  13. 根据权利要求9所述的图像处理方法,其中,根据所述三维扩展模型和所述待处理图像,在所述待处理图像上渲染所述三维扩展模型,包括:The image processing method according to claim 9, wherein rendering the 3D extended model on the image to be processed according to the 3D extended model and the image to be processed comprises:
    提取所述第一边缘点在所述待处理图像上的投影点的像素信息,作为所述第一边缘点的调整结果的像素信息,并提取所述第二边缘点在所述待处理图像上的投影点的像素信息,作为所述第二边缘点的像素信息;extracting the pixel information of the projection point of the first edge point on the image to be processed as the pixel information of the adjustment result of the first edge point, and extracting the pixel information of the second edge point on the image to be processed The pixel information of the projected point is used as the pixel information of the second edge point;
    根据所述第一边缘点的调整结果的像素信息和所述第二边缘点的像素信息,渲染所述第二网格,得到所述第二网格内的像素信息;Rendering the second grid according to the pixel information of the adjustment result of the first edge point and the pixel information of the second edge point to obtain pixel information in the second grid;
    根据所述第一边缘点的调整结果和所述第二边缘点在所述待处理图像上的投影点的坐标信息,将所述第一边缘点的调整结果的像素信息、所述第二边缘点的像素信息和所述第二网格内的像素信息,投影到所述待处理图像上。According to the adjustment result of the first edge point and the coordinate information of the projection point of the second edge point on the image to be processed, the pixel information of the adjustment result of the first edge point, the second edge point The pixel information of the points and the pixel information in the second grid are projected onto the image to be processed.
  14. 根据权利要求1至4中任一项所述的图像处理方法,其中,所述目标对象包括所述待处理图像中以下至少一个对象:脸部、手部、肢体。The image processing method according to any one of claims 1 to 4, wherein the target object includes at least one of the following objects in the image to be processed: face, hand, and limb.
  15. 一种图像处理装置,包括:An image processing device, comprising:
    获取模块,用于获取待处理图像,其中,所述待处理图像包括目标对象;An acquisition module, configured to acquire an image to be processed, wherein the image to be processed includes a target object;
    第一对应模块,用于提取所述目标对象的三维关键点,并确定所述三维关键点与三 维调整模型中顶点之间的第一对应关系;The first correspondence module is used to extract the three-dimensional key points of the target object, and determine the first correspondence between the three-dimensional key points and the vertices in the three-dimensional adjustment model;
    调整模块,用于根据调整指令、所述三维调整模型中顶点的预设形变数据和所述第一对应关系,确定所述三维关键点的调整结果;An adjustment module, configured to determine the adjustment result of the three-dimensional key points according to the adjustment instruction, the preset deformation data of the vertices in the three-dimensional adjustment model, and the first corresponding relationship;
    目标模块,用于根据所述三维关键点的调整结果和所述待处理图像,确定目标图像。The target module is configured to determine a target image according to the adjustment result of the 3D key points and the image to be processed.
  16. 一种电子设备,所述设备包括存储器、处理器,所述存储器用于存储可在处理器上运行的计算机指令,所述处理器用于在执行所述计算机指令时实现权利要求1至14任一项所述的方法。An electronic device comprising a memory and a processor, the memory is used to store computer instructions executable on the processor, and the processor is used to implement any one of claims 1 to 14 when executing the computer instructions method described in the item.
  17. 一种计算机可读存储介质,其上存储有计算机程序,所述程序被处理器执行时实现权利要求1至14任一所述的方法。A computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method according to any one of claims 1 to 14 is implemented.
  18. 一种计算机程序产品,该产品包括计算机程序,当所述程序被处理器执行时实现权利要求1至14任一所述的方法。A computer program product comprising a computer program, which implements the method of any one of claims 1 to 14 when said program is executed by a processor.
PCT/CN2022/125036 2021-10-20 2022-10-13 Image processing method and apparatus, electronic device, and storage medium WO2023066120A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111222848.5 2021-10-20
CN202111222848.5A CN113657357B (en) 2021-10-20 2021-10-20 Image processing method, image processing device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2023066120A1 true WO2023066120A1 (en) 2023-04-27

Family

ID=78494756

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/125036 WO2023066120A1 (en) 2021-10-20 2022-10-13 Image processing method and apparatus, electronic device, and storage medium

Country Status (2)

Country Link
CN (3) CN114581986A (en)
WO (1) WO2023066120A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114581986A (en) * 2021-10-20 2022-06-03 北京市商汤科技开发有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN115239860B (en) * 2022-09-01 2023-08-01 北京达佳互联信息技术有限公司 Expression data generation method and device, electronic equipment and storage medium
CN115409951B (en) * 2022-10-28 2023-03-24 北京百度网讯科技有限公司 Image processing method, image processing device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108447017A (en) * 2018-05-31 2018-08-24 Oppo广东移动通信有限公司 Face virtual face-lifting method and device
CN108550185A (en) * 2018-05-31 2018-09-18 Oppo广东移动通信有限公司 Beautifying faces treating method and apparatus
CN108876708A (en) * 2018-05-31 2018-11-23 Oppo广东移动通信有限公司 Image processing method, device, electronic equipment and storage medium
CN109190503A (en) * 2018-08-10 2019-01-11 珠海格力电器股份有限公司 U.S. face method, apparatus, computing device and storage medium
CN113657357A (en) * 2021-10-20 2021-11-16 北京市商汤科技开发有限公司 Image processing method, image processing device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108765273B (en) * 2018-05-31 2021-03-09 Oppo广东移动通信有限公司 Virtual face-lifting method and device for face photographing
CN109584151B (en) * 2018-11-30 2022-12-13 腾讯科技(深圳)有限公司 Face beautifying method, device, terminal and storage medium
CN111985265B (en) * 2019-05-21 2024-04-12 华为技术有限公司 Image processing method and device
CN110675489B (en) * 2019-09-25 2024-01-23 北京达佳互联信息技术有限公司 Image processing method, device, electronic equipment and storage medium
CN111368678B (en) * 2020-02-26 2023-08-25 Oppo广东移动通信有限公司 Image processing method and related device
CN113379623B (en) * 2021-05-31 2023-12-19 北京达佳互联信息技术有限公司 Image processing method, device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108447017A (en) * 2018-05-31 2018-08-24 Oppo广东移动通信有限公司 Face virtual face-lifting method and device
CN108550185A (en) * 2018-05-31 2018-09-18 Oppo广东移动通信有限公司 Beautifying faces treating method and apparatus
CN108876708A (en) * 2018-05-31 2018-11-23 Oppo广东移动通信有限公司 Image processing method, device, electronic equipment and storage medium
CN109190503A (en) * 2018-08-10 2019-01-11 珠海格力电器股份有限公司 U.S. face method, apparatus, computing device and storage medium
CN113657357A (en) * 2021-10-20 2021-11-16 北京市商汤科技开发有限公司 Image processing method, image processing device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN113657357B (en) 2022-02-25
CN114581986A (en) 2022-06-03
CN114581987A (en) 2022-06-03
CN113657357A (en) 2021-11-16

Similar Documents

Publication Publication Date Title
WO2023066120A1 (en) Image processing method and apparatus, electronic device, and storage medium
CN107993216B (en) Image fusion method and equipment, storage medium and terminal thereof
WO2021093453A1 (en) Method for generating 3d expression base, voice interactive method, apparatus and medium
WO2019242454A1 (en) Object modeling movement method, apparatus and device
EP3992919B1 (en) Three-dimensional facial model generation method and apparatus, device, and medium
CN107484428B (en) Method for displaying objects
WO2022095721A1 (en) Parameter estimation model training method and apparatus, and device and storage medium
CN113628327B (en) Head three-dimensional reconstruction method and device
US20230085468A1 (en) Advanced Automatic Rig Creation Processes
CN111652123B (en) Image processing and image synthesizing method, device and storage medium
WO2022237081A1 (en) Makeup look transfer method and apparatus, and device and computer-readable storage medium
US10169891B2 (en) Producing three-dimensional representation based on images of a person
EP4165606A1 (en) Object reconstruction with texture parsing
US20220319231A1 (en) Facial synthesis for head turns in augmented reality content
CN112348937A (en) Face image processing method and electronic equipment
CN113822965A (en) Image rendering processing method, device and equipment and computer storage medium
KR20230110787A (en) Methods and systems for forming personalized 3D head and face models
CN113516755B (en) Image processing method, image processing apparatus, electronic device, and storage medium
KR20160046399A (en) Method and Apparatus for Generation Texture Map, and Database Generation Method
US11080920B2 (en) Method of displaying an object
JP6341540B2 (en) Information terminal device, method and program
RU2703327C1 (en) Method of processing a two-dimensional image and a user computing device thereof
CN111652807A (en) Eye adjustment method, eye live broadcast method, eye adjustment device, eye live broadcast device, electronic equipment and storage medium
US11983819B2 (en) Methods and systems for deforming a 3D body model based on a 2D image of an adorned subject
CN117011493B (en) Three-dimensional face reconstruction method, device and equipment based on symbol distance function representation

Legal Events

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

Ref document number: 22882730

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE