CN109165571B - Method and apparatus for inserting image - Google Patents

Method and apparatus for inserting image Download PDF

Info

Publication number
CN109165571B
CN109165571B CN201810879255.8A CN201810879255A CN109165571B CN 109165571 B CN109165571 B CN 109165571B CN 201810879255 A CN201810879255 A CN 201810879255A CN 109165571 B CN109165571 B CN 109165571B
Authority
CN
China
Prior art keywords
human eye
key point
point data
image
target
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201810879255.8A
Other languages
Chinese (zh)
Other versions
CN109165571A (en
Inventor
邓涵
刘志超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201810879255.8A priority Critical patent/CN109165571B/en
Publication of CN109165571A publication Critical patent/CN109165571A/en
Application granted granted Critical
Publication of CN109165571B publication Critical patent/CN109165571B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/0093Geometric image transformation in the plane of the image for image warping, i.e. transforming by individually repositioning each pixel
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06KRECOGNITION OF DATA; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K9/00Methods or arrangements for reading or recognising printed or written characters or for recognising patterns, e.g. fingerprints
    • G06K9/00597Acquiring or recognising eyes, e.g. iris verification
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods
    • G06T7/74Determining position or orientation of objects or cameras using feature-based methods involving reference images or patches
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Abstract

The embodiment of the application discloses a method and a device for inserting an image. One embodiment of the method comprises: acquiring a target human eye image and determining human eye key point data of the target human eye image; determining auxiliary key point data of a target human eye image based on the human eye key point data; performing coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data; and obtaining an image to be inserted, and inserting the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image. The embodiment improves the flexibility of inserting the preset image into the human eye image, and is beneficial to enriching the display form of the preset image inserted into the human eye image.

Description

Method and apparatus for inserting image
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for inserting images.
Background
With the development of image processing technology, the human eye key point detection technology is widely applied. For example, the human eye key point detection technology can be applied to the fields of special effect addition of human eye images, judgment of human eye shapes and the like.
The human eye key points refer to points representing specific positions in the human eye image, such as points representing positions of corners of the eye, points representing positions of edges of eyelids, and the like. At present, some material images (such as eyelash images, eye makeup images and the like) can be inserted into human eye images by utilizing the positions of human eye key points in the human eye images.
Disclosure of Invention
The embodiment of the application provides a method and a device for inserting an image.
In a first aspect, an embodiment of the present application provides a method for inserting an image, where the method includes: acquiring a target human eye image and determining human eye key point data of the target human eye image, wherein the human eye key point data is used for representing the position of a human eye key point in the target human eye image; determining auxiliary key point data of the target human eye image based on the human eye key point data, wherein the auxiliary key point data is used for representing the position of the auxiliary key point in the target human eye image; performing coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data; and obtaining an image to be inserted, and inserting the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image.
In some embodiments, prior to determining the auxiliary key point data for the target human eye image based on the human eye key point data, the method further comprises: the method comprises the steps of obtaining preset reference human eye key point data and reference auxiliary key point data, wherein the reference human eye key point data are used for representing the positions of human eye key points in a preset reference human eye image in the reference human eye image, and the reference auxiliary key point data are used for representing the positions of reference auxiliary key points which are preset in the reference human eye image.
In some embodiments, determining ancillary keypoint data for the target human eye image based on the human eye keypoint data comprises: constructing a first triangulation grid based on the reference auxiliary key point data and the reference human eye key point data; determining a second triangulation mesh formed on the target human eye image based on the side length and the inner angle of a triangle included in the first triangulation mesh and the corresponding relation between the human eye key point data and the human eye key point data of the target human eye image; determining a target vertex from the vertices of the triangles comprised by the second triangulation mesh, and determining auxiliary key point data of the target eye image based on the position of the target vertex in the target eye image.
In some embodiments, coordinate transformation is performed on the auxiliary key point data to obtain transformed auxiliary key point data, including: performing coordinate transformation on the reference auxiliary key point data to obtain transformed reference auxiliary key point data; and inputting the reference auxiliary key point data, the transformed reference auxiliary key point data and the auxiliary key point data of the target human eye image into a preset coordinate mapping model to obtain the transformed auxiliary key point data of the target human eye image.
In some embodiments, coordinate transforming the reference auxiliary keypoint data to obtain transformed reference auxiliary keypoint data comprises: determining an opening degree value representing the opening degree of the human eyes indicated by the target human eye image according to the human eye key point data of the target human eye image; determining a radian value used for representing the change degree of coordinates of the reference auxiliary key point data according to a preset radian calculation formula and the abscissa included in the reference auxiliary key point data; and determining transformed reference auxiliary key point data based on the arc value and the opening degree value.
In some embodiments, the coordinate mapping model is a model constructed based on moving least squares MLS.
In some embodiments, obtaining an image to be inserted comprises: acquiring a preset image; and deforming the preset image based on the human eye key point data and the transformed auxiliary key point data, and determining the deformed preset image as an image to be inserted.
In a second aspect, an embodiment of the present application provides an apparatus for inserting an image, the apparatus including: the first acquisition unit is configured to acquire a target human eye image and determine human eye key point data of the target human eye image, wherein the human eye key point data is used for representing the position of a human eye key point in the target human eye image; the determining unit is configured to determine auxiliary key point data of the target human eye image based on the human eye key point data, wherein the auxiliary key point data is used for representing the position of the auxiliary key point in the target human eye image; the transformation unit is configured to perform coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data; and the inserting unit is configured to acquire the image to be inserted and insert the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image.
In some embodiments, the apparatus further comprises: the second obtaining unit is configured to obtain preset reference human eye key point data and reference auxiliary key point data, wherein the reference human eye key point data is used for representing the position of a human eye key point in a preset reference human eye image in the reference human eye image, and the reference auxiliary key point data is used for representing the position of a reference auxiliary key point which is preset in the reference human eye image.
In some embodiments, the determining unit comprises: a construction module configured to construct a first triangulation mesh based on the reference auxiliary key point data and the reference human eye key point data; a first determination module configured to determine a second triangulation mesh formed on the target human eye image based on a side length and an inner angle of a triangle included in the first triangulation mesh and a correspondence between the human eye key point data and the human eye key point data of the target human eye image; a second determination module configured to determine target vertices from the vertices of the triangles comprised by the second triangulation mesh and to determine auxiliary keypoint data of the target eye image based on the positions of the target vertices in the target eye image.
In some embodiments, the transform unit comprises: a transformation module configured to perform coordinate transformation on the reference auxiliary key point data to obtain transformed reference auxiliary key point data; and the generating module is configured to input the reference auxiliary key point data, the transformed reference auxiliary key point data and the auxiliary key point data of the target human eye image into a preset coordinate mapping model to obtain the transformed auxiliary key point data of the target human eye image.
In some embodiments, the transformation module comprises: the first determining submodule is configured to determine an opening degree value representing the opening degree of the human eyes indicated by the target human eye image according to the human eye key point data of the target human eye image; a second determining submodule configured to determine a radian value used for representing a degree of change of coordinates of the reference auxiliary key point data according to a preset radian calculation formula and the abscissa included in the reference auxiliary key point data; a third determination submodule configured to determine the transformed reference auxiliary keypoint data based on the arc value and the openness value.
In some embodiments, the coordinate mapping model is a model constructed based on moving least squares MLS.
In some embodiments, the insertion unit comprises: an acquisition module configured to acquire a preset image; and the deformation module is configured to deform the preset image based on the human eye key point data and the transformed auxiliary key point data, and determine the deformed preset image as an image to be inserted.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the first aspect.
In a fourth aspect, the present application provides a computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the method and the device for inserting the image, the human eye key point data of the obtained target human eye image is determined, the auxiliary key point data of the target human eye image is determined based on the human eye key point data, then the coordinate transformation is carried out on the auxiliary key point data, the transformed auxiliary key point data is obtained, finally, the preset image is transformed based on the transformed auxiliary key point data, and the transformed preset image is inserted into the corresponding position of the target human eye image, so that the flexibility of inserting the preset image into the human eye image is improved, and the display form of the preset image inserted into the human eye image is enriched.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for inserting an image according to an embodiment of the present application;
FIG. 3A is an exemplary diagram of a first triangulation mesh for a method of interpolating an image according to an embodiment of the present application;
FIG. 3B is an exemplary diagram of a second triangulation mesh for a method of interpolating an image according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an application scenario of a method for inserting an image according to an embodiment of the present application;
FIG. 5 is a flow diagram of yet another embodiment of a method for inserting an image according to an embodiment of the present application;
FIG. 6 is an exemplary diagram of determining an openness value from human eye key point data according to a method for inserting an image according to an embodiment of the present application;
FIG. 7 is a schematic diagram of an embodiment of an apparatus for inserting an image according to an embodiment of the present application;
FIG. 8 is a block diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which the method for inserting an image or the apparatus for inserting an image of the embodiments of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various applications, such as image processing applications, video playing applications, instant messaging tools, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting image display, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server that provides various services, such as a background image processing server that provides support for images displayed on the terminal devices 101, 102, 103. The background image processing server may process the acquired human eye image and obtain a processing result (e.g., a human eye image inserted into a preset image).
It should be noted that the method for inserting the image provided in the embodiment of the present application may be executed by the server 105, or may be executed by the terminal devices 101, 102, and 103, and accordingly, the apparatus for inserting the image may be disposed in the server 105, or may be disposed in the terminal devices 101, 102, and 103.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation. In the case where the target eye image and the preset image do not need to be acquired from a remote location, the system architecture may not include a network, but only include a terminal device or a server.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for inserting an image according to the present application is shown. The method for inserting an image comprises the following steps:
step 201, obtaining a target eye image, and determining eye key point data of the target eye image.
In this embodiment, the execution subject (for example, the server or the terminal device shown in fig. 1) of the method for inserting an image may first acquire the target human eye image from a remote location or from a local location by a wired connection manner or a wireless connection manner. The target human eye image may be an image including an eye image of a target person (for example, a user using a terminal device as shown in fig. 1 or other person). For example, the target human eye image may be an image obtained by photographing eyes of a target person, or may be a human eye image extracted from a face image representing a face of the target person. It should be noted that the target eye image may be a single image; or may be an image of a human eye included in an image frame extracted from the target video. For example, the target human eye image may be a human eye image included in a currently displayed image frame included in the video played on the execution subject.
Then, the execution subject may determine eye key point data of the target eye image. The human eye key point data is used for representing the position of the human eye key point in the target human eye image. Generally, the human eye key point data may include coordinate values in a coordinate system established in advance in the target human eye image, and the positions of the human eye key points in the target human eye image may be determined according to the coordinate values. The human eye keypoints may be points that represent particular locations in the human eye image (e.g., points that represent corners of the eye, points that represent edges of the eyelids, etc.).
In this embodiment, the executing body may determine the eye key point data of the target eye image by using various existing methods for determining the eye key point.
For example, the execution subject may input the target human eye image into a human eye key point extraction model trained in advance to obtain human eye key point data. The human eye key point extraction model can be used for representing the corresponding relation between the human eye image and the human eye key point data. For another example, when the target human eye image is a human eye image included in the human face image, the execution subject may input the human face image into a human face key point extraction model trained in advance, so as to obtain human face key point data. The face key point extraction model can be used for representing the corresponding relation between the face image and the face key point data. The execution subject may further extract, from the obtained face key point data, face key point data representing eyes as the eye key point data. It should be noted that the human eye keypoint extraction Model or the human face keypoint extraction Model may be a Model obtained by training an initial Model (for example, a Convolutional Neural Network (CNN), an Active Shape Model (ASM), or the like) by using a machine learning method based on a training sample (for example, the training sample may include a sample human eye image and labeled human eye keypoint data for labeling human eye keypoints of the sample human eye image) (for example, training the sample human eye image as an input of the initial Model, and the labeled human eye keypoint data as an expected output of the initial Model). It should be understood that the method for training to obtain the human eye key point extraction model is a well-known technology which is widely researched and applied at present, and is not described in detail herein.
Step 202, determining auxiliary key point data of the target human eye image based on the human eye key point data.
In the present embodiment, the execution subject may determine auxiliary key point data of the target human eye image based on the human eye key point data determined in step 201. The auxiliary key point data is used for representing the position of the auxiliary key point in the target human eye image. The auxiliary key points may be key points added by the execution subject in the target eye image for characterizing the position of inserting other images into the target eye image in combination with the eye key point data.
Specifically, the execution subject may determine the auxiliary key point data of the target human eye image in various methods. For example, the execution subject may add an auxiliary key point within a preset range of the target human eye image (e.g., a range determined by a preset distance above a human eye key point representing an upper eyelid edge and an eye corner of a human eye) according to data preset by a technician, and determine the auxiliary key point data. Wherein, the preset data includes but is not limited to at least one of the following: the distance between the auxiliary key points, and the distance between the auxiliary key points and the human eye key points.
In some optional implementations of this embodiment, before step 202, the executing body may further obtain preset reference human eye key point data and reference auxiliary key point data. The reference eye key point data is used for representing the position of a preset reference eye image of the eye key point in the reference eye image, and the reference auxiliary key point data is used for representing the position of a preset reference auxiliary key point in the reference eye image. The reference human eye image can be a human eye image preset by a technician, the human eye image can be used as a template, and the reference human eye key points and the reference auxiliary key points of the human eye image can be used as reference key points for determining the auxiliary key points of the target human eye image. Specifically, the reference eye key point data may be the eye key point data of the reference eye image determined by using the eye key point extraction model listed in step 201. The auxiliary key points characterized by the reference auxiliary key point data may be points manually set by a technician or points set by the executing agent based on a preset distance between the auxiliary key points and/or a distance between the auxiliary key points and the reference human eye key points.
In some optional implementations of the embodiment, the executing entity may determine the auxiliary key point data of the target human eye image according to the following steps:
first, a first triangulation mesh is constructed based on reference auxiliary key point data and reference human eye key point data. The Triangulation mesh is a mesh composed of a plurality of triangles, which is generated by triangulating (triangulating) a plurality of points by using a Triangulation algorithm. In this implementation manner, the reference auxiliary keypoints characterized by the reference auxiliary keypoint data and the reference human eye keypoints characterized by the reference human eye keypoint data are vertices of triangles included in the first triangulation mesh.
Then, a second triangulation mesh formed on the target human eye image is determined based on the side length and the inner angle of the triangle included in the first triangulation mesh and the corresponding relationship between the human eye key point data and the human eye key point data of the target human eye image. Specifically, the execution subject may determine the distance between key points of the human eyes in the target human eye image, determine a corresponding triangle on the target human eye image according to a principle of a similar triangle and a triangle formed by two reference human eye key points and one reference auxiliary key point in the triangles included in the first triangulation mesh, and then determine each determined triangle as a triangle included in the second triangulation mesh. It should be noted that the triangle determined on the target eye image may not be completely similar to the corresponding triangle included in the first triangulation mesh, that is, an angle difference between an inner angle of the triangle determined on the target eye image and an inner angle of the triangle included in the corresponding first triangulation mesh may be within a preset difference.
By way of example, referring to fig. 3A, a schematic diagram of a first triangulation mesh is shown, where point A, B, C, D, E is a reference eye keypoint and point F, G, H, I is a reference assist keypoint. As shown in fig. 3B, a schematic diagram of the second triangulation mesh is shown, where points a ', B ', C ', D ', and E ' are key points of human eyes of the target human eye image, and points F ', G ', H ', and I ' are auxiliary key points of the target human eye image. In fig. 3A, for the triangle ABF, knowing the length of AB and the angles of the three corners, since the length between points a ' and B ' as shown in fig. 3B can be calculated, a triangle a ' B ' F ' similar to the triangle ABF can be determined in the target human eye image. Based on the same method, a triangular BCG, a triangular CDH, and a triangular DEI can be obtained, thereby obtaining a second triangulation mesh as shown in fig. 3B.
It should be noted that, in practice, the number of the eye key points and the auxiliary key points of the target eye image is not limited to the number listed in the above example, and the executing subject may determine the second triangulation mesh from the first triangulation mesh according to the principle of similar triangles.
And finally, determining auxiliary key points from the vertices of the triangles included in the second triangulation mesh to obtain auxiliary key point data of the target human eye image. Specifically, the auxiliary key point data may include coordinates of auxiliary key points, and the executing body may determine vertices other than the eye key points as the auxiliary key points from vertices of triangles included in the second triangulation mesh, and determine coordinates of the auxiliary key points in the target eye image as the coordinates of the auxiliary key points.
And 203, performing coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data.
In this embodiment, the executing entity may perform coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data. Specifically, the execution body may perform coordinate transformation on the auxiliary key point data in various methods. As an example, the executing entity may determine a degree value representing an opening degree of the human eye indicated by the target human eye image (for example, a ratio of a distance between human eye key points representing an upper eyelid edge center point and a lower eyelid edge center point of the eye to a distance between human eye key points representing a left canthus and a right canthus of the eye), search a coefficient corresponding to the determined degree value from a correspondence table of correspondence between a pre-established characteristic degree value and a coefficient used for coordinate transformation of the auxiliary key point data, transform a coordinate value included in the auxiliary key point data based on the coefficient (for example, multiply a vertical coordinate value and a horizontal coordinate value included in the auxiliary key point data by the corresponding coefficient respectively), and obtain transformed auxiliary key point data.
And 204, acquiring an image to be inserted, and inserting the image to be inserted into the transformed auxiliary key point data and the human eye key point data representation position in the target human eye image.
In this embodiment, the execution main body may first acquire the image to be inserted from a remote place or from a local place. Wherein the image to be inserted may be an image to be inserted into the target human eye image. For example, the image to be inserted may be an eyelash image, an eye makeup image, or the like.
Then, the execution subject may insert the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image. Specifically, the positions represented by the transformed auxiliary key point data and the human eye key point data may be image regions formed by the transformed auxiliary key points and the human eye key points of the target human eye image. For example, assuming that the image to be inserted is an eyelash image, the image region having the smallest area including the transformed auxiliary key points and the key points of human eyes is the position where the image to be inserted is inserted.
With continued reference to fig. 4, fig. 4 is a schematic diagram of an application scenario of the method for inserting an image according to the present embodiment. In the application scenario of fig. 4, the terminal device 401 first captures an eye image of the user as a target eye image 402. Then, the terminal device 401 obtains eye key point data 403 of the target eye image 402 using the pre-trained eye key point extraction model. The eye key point data is used for representing the position of the eye key point 4021 in the target eye image, and includes the coordinates of the represented eye key point in the target eye image 402. Subsequently, the terminal device 401 adds a preset number of auxiliary key points 4022 above the upper eyelid edge representing human eyes according to the distance between the auxiliary key points and the key points of the human eyes preset by the technician, and determines auxiliary key point data 404, where the auxiliary key point data 404 is used for representing the positions of the auxiliary key points in the target human eye image 402, including the coordinates of the represented auxiliary key points in the target human eye image 402. Then, the terminal device 401 may use a ratio of a distance between the eye key points representing the upper eyelid edge center point and the lower eyelid edge center point of the eye and a distance between the eye key points representing the left canthus and the right canthus of the eye as a degree value representing the degree of openness of the eye indicated by the target eye image 402, the terminal device 401 further searches a coefficient corresponding to the determined degree value from a correspondence table of a correspondence between the pre-established degree value representing and a coefficient used for performing coordinate transformation on the auxiliary key point data, and then transforms a coordinate value included in the auxiliary key point data based on the coefficient to obtain transformed auxiliary key point data 405 representing the position of the transformed auxiliary key point 4023 in the target eye image 402. Finally, the terminal device 401 acquires an image to be inserted 406 (e.g., an eyelash image), and inserts the image to be inserted 406 into the region where the transformed auxiliary keypoints and the human eye keypoints are located.
According to the method provided by the embodiment of the application, the human eye key point data of the obtained target human eye image is determined, the auxiliary key point data of the target human eye image is determined based on the human eye key point data, the auxiliary key point data is subjected to coordinate transformation to obtain the transformed auxiliary key point data, the preset image is deformed based on the transformed auxiliary key point data, and the deformed preset image is inserted into the corresponding position of the target human eye image, so that the flexibility of inserting the preset image into the human eye image is improved, and the display form of the preset image inserted into the human eye image is enriched.
With further reference to FIG. 5, a flow 500 of yet another embodiment of a method for inserting an image is shown. The flow 500 of the method for inserting an image comprises the steps of:
step 501, obtaining a target eye image, and determining eye key point data of the target eye image.
In this embodiment, step 501 is substantially the same as step 201 in the corresponding embodiment of fig. 2, and is not described here again.
Step 502, obtaining preset reference human eye key point data and reference auxiliary key point data.
In the present embodiment, an execution subject (e.g., a server or a terminal device shown in fig. 1) of the method for inserting an image may obtain preset reference eye key point data and reference auxiliary key point data from a remote place or a local place through a wired connection manner or a wireless connection manner. The reference eye key point data is used for representing the position of a preset reference eye image of the eye key point in the reference eye image, and the reference auxiliary key point data is used for representing the position of a preset reference auxiliary key point in the reference eye image. Specifically, the reference eye key point data may be the eye key point data of the reference eye image determined by using the eye key point extraction model listed in step 201. The auxiliary key points characterized by the reference auxiliary key point data may be points manually set by a technician or points set by the executing agent based on a preset distance between the auxiliary key points and/or a distance between the auxiliary key points and the reference human eye key points.
Step 503, determining auxiliary key point data of the target human eye image based on the human eye key point data.
In this embodiment, step 503 is substantially the same as step 202 in the corresponding embodiment of fig. 2, and is not described herein again.
And step 504, performing coordinate transformation on the reference auxiliary key point data to obtain transformed reference auxiliary key point data.
In this embodiment, the execution body may perform coordinate transformation on the reference auxiliary key point data according to various methods to obtain transformed reference auxiliary key point data. As an example, the executing entity may determine a degree value representing an opening degree of the human eye indicated by the target human eye image (for example, a ratio of a distance between human eye key points representing an upper eyelid edge center point and a lower eyelid edge center point of the eye to a distance between human eye key points representing a left canthus and a right canthus of the eye), search a coefficient corresponding to the determined degree value from a correspondence table of correspondence between a pre-established characteristic degree value and a coefficient used for coordinate transformation of the auxiliary key point data, transform a coordinate value included in the auxiliary key point data based on the coefficient (for example, multiply a vertical coordinate value and a horizontal coordinate value included in the auxiliary key point data by the corresponding coefficient respectively), and obtain transformed auxiliary key point data.
In some optional implementation manners of this embodiment, the executing body may perform coordinate transformation on the reference auxiliary key point data according to the following steps to obtain transformed reference auxiliary key point data:
firstly, determining an opening degree value representing the opening degree of human eyes indicated by a target human eye image according to human eye key point data of the target human eye image. Specifically, the openness value may be a ratio of a distance between human eye key points characterizing an upper eyelid edge center point and a lower eyelid edge center point of the eye to a distance between human eye key points characterizing a left canthus and a right canthus of the eye. As shown in fig. 6, 601 and 602 are eye key points representing corners of eyes, 603 and 604 are eye key points representing midpoints of upper and lower eyelid edges of eyes, respectively, L1 is a distance between 601 and 602, and L2 is a distance between 603 and 604, the opening degree value may be L2/L1. The opening degree value may be a value calculated from the eye key point of any one of the target eye images, or may be an average value of values calculated from the eye key points of each of the two eye images, which is not limited herein.
Then, according to a preset radian calculation formula and the abscissa included in the reference auxiliary key point data, a radian value used for representing the degree of change of the coordinates of the reference auxiliary key point data is determined. Specifically, the execution body may calculate an abscissa included in the reference auxiliary key point data using a radian calculation formula, and determine a calculation result as a radian value, wherein the abscissa may be an abscissa in a coordinate system established based on the reference eye image. For example, the upper left corner of the reference eye image is the origin of coordinates, the horizontal direction is the horizontal axis, and the vertical direction is the vertical axis. As an example, the radian calculation formula may be as follows:
r=(x/w-0.5)×2×m (1),
wherein r is an arc value, x is an abscissa included in the reference auxiliary key point data, w is a transverse length of the reference human eye image, and m is a preset adjustment coefficient. As can be seen from equation (1), the closer the reference auxiliary key point is to the lateral center point of the reference eye image, the smaller the r value is, and otherwise, the larger the r value is.
And finally, determining transformed reference auxiliary key point data based on the arc value and the opening degree value. As an example, the execution subject may obtain the ordinate included in the transformed reference auxiliary key point data according to the following formula:
y'=[1-(1-y/h)×cos(r)×d]×h (2),
wherein y' is a vertical coordinate included in the transformed reference auxiliary key point data, y is a vertical coordinate included in the reference auxiliary key point data, h is a longitudinal width of the reference human eye image, r is a calculated arc value, and d is an opening degree value. The method can be seen from the above formula, when the eyelid of the human eye represented by the actually detected target human eye image moves, the opening degree value can be calculated in real time, and the reference auxiliary key point data of the reference human eye image is subjected to coordinate transformation according to the opening degree value, so that the transformed reference auxiliary key point data is obtained.
The execution body may set the abscissa included in the reference auxiliary key point data as the abscissa included in the transformed reference auxiliary key point data, that is, the abscissa remains unchanged. Alternatively, the above formula execution subject may obtain the abscissa included in the transformed reference auxiliary key point data according to the following formula:
x'=[x/w×(1-sin(r))×d]×w (3),
wherein x' is an abscissa included in the transformed reference auxiliary key point data, x is an abscissa included in the reference auxiliary key point data, w is a transverse length of the reference human eye image, r is a calculated arc value, and d is an opening degree value.
It should be noted that the origin of coordinates where the abscissa and the ordinate in the formulas (1) to (3) are located is the upper left corner of the reference human eye image, and when the origin of coordinates is not the upper left corner of the reference human eye image, the forms of the formulas (1) to (3) may be adjusted accordingly. For example, if the origin of coordinates is the lower left corner of the reference human eye image, equation (2) may be in the form:
y'=y×cos(r)×d。
by executing the steps described in this implementation manner, it is possible to calculate the transformed reference auxiliary key point data in real time when the eye represented by the target eye image blinks, and perform coordinate transformation to different degrees on the reference auxiliary key point data at different positions, thereby facilitating real-time adjustment of the shape of the image inserted into the target eye image according to the transformed reference auxiliary key point data, and making the display effect of the image inserted into the target eye image (e.g., eyelash image) richer (e.g., stronger stereoscopic impression).
And 505, inputting the reference auxiliary key point data, the transformed reference auxiliary key point data and the auxiliary key point data of the target human eye image into a preset coordinate mapping model to obtain the transformed auxiliary key point data of the target human eye image.
In this embodiment, the execution body may input the reference auxiliary key point data, the transformed reference auxiliary key point data, and the auxiliary key point data of the target eye image into a preset coordinate mapping model, so as to obtain the transformed auxiliary key point data of the target eye image. The coordinate mapping model is used for representing the corresponding relation between the reference auxiliary key point data, the transformed reference auxiliary key point data, the auxiliary key point data of the target human eye image and the transformed auxiliary key point data of the target human eye image.
The coordinate mapping model may be, for example, a calculation formula preset by a skilled person, by which, the execution body may calculate the variation amounts of the abscissa and the ordinate included in the reference auxiliary key point data and the transformed reference auxiliary key point data, and then, based on the calculated variation amounts, the method includes the steps of converting an abscissa and an ordinate included in auxiliary key point data of a target human eye image (for example, adding a variation of the abscissa and a variation of the ordinate to the abscissa and the ordinate included in the auxiliary key point data of the target human eye image, respectively), or multiplying a variation of the abscissa and a variation of the ordinate by preset coefficients to obtain an intermediate variation, and adding the intermediate variation to the abscissa and the ordinate included in the auxiliary key point data of the target human eye image, respectively) to obtain converted auxiliary key point data of the target human eye image.
In some optional implementations of the present embodiment, the coordinate mapping model may be a model constructed based on Moving Least Squares (MLS). The moving least square method is a curve fitting method and has a good fitting effect on a large amount of data. The coordinate mapping model can perform fitting calculation on the input reference auxiliary key point data and the transformed reference auxiliary key point data by using a moving least square method, so as to obtain parameters of a fitting formula. Then, the coordinate mapping model can calculate the auxiliary key point data of the input target human eye image by using a fitting formula to obtain the transformed auxiliary key point data of the target human eye image. It should be noted that the moving least square method is a well-known technique which is widely researched and applied at present, and the fitting process and the fitting formula of the moving least square method are not described herein again.
Step 506, acquiring a preset image.
In this embodiment, the execution subject may acquire a preset image. The preset image may be various types of images, such as an eyelash image, an eye makeup image, and the like. As an example, the preset image may be an image extracted from the reference eye image at a position where the reference eye key point and the reference auxiliary key point are located. For example, the preset image may be an eyelash image preset in the reference human eye image.
And 507, deforming the preset image based on the key point data of the human eyes and the transformed auxiliary key point data, and determining the deformed preset image as an image to be inserted.
In this embodiment, the execution subject may deform the preset image based on the human eye key point data and the transformed auxiliary key point data. In general, the shape and size of the preset image do not match those of the target eye image, and thus, the preset image needs to be deformed to match those of the target eye image. In this implementation, the execution body may deform the preset image according to various existing methods. As an example, the executing entity may determine a polygon (e.g., a rectangle, a trapezoid, etc.) including the eye key point and the auxiliary key point of the target eye image, where the shape of the polygon may be the same as the shape of the preset image, and then scale the preset image according to a proportional relationship between the polygon and the shape of the preset image to obtain the deformed preset image.
As another example, the executing entity may construct a first triangulation mesh based on the reference eye key points and the reference auxiliary key points of the reference eye image, and construct a second triangulation mesh based on the eye key points and the auxiliary key points of the target eye image. The execution main body can deform the shape of the image area covered by the triangle to the shape of the triangle in the second triangulation mesh corresponding to the triangle, wherein the coverage range of the first triangulation mesh is the same as the display range of the preset image, the triangle in the first triangulation mesh corresponds to the triangle in the second triangulation mesh, and for each triangle in the first triangulation mesh. And determining the combination of the deformed triangular image areas as an image to be inserted.
And step 508, inserting the image to be inserted into the transformed auxiliary key point data and human eye key point data representation positions in the target human eye image.
In this embodiment, step 508 is substantially the same as the method for inserting the image to be inserted into the target eye image described in step 204 in the corresponding embodiment of fig. 2, and is not repeated here.
As can be seen from fig. 5, compared to the embodiment corresponding to fig. 2, the flow 500 of the method for inserting an image in the present embodiment highlights the step of performing coordinate transformation on the auxiliary key point data of the target human eye image based on the reference auxiliary key point data. Therefore, the scheme described in this embodiment can obtain the transformed auxiliary key point data of the target human eye image by using the reference auxiliary key point data of the reference human eye image, thereby further improving the flexibility of inserting the image and enriching the display effect of the inserted image.
With further reference to fig. 7, as an implementation of the methods shown in the above figures, the present application provides an embodiment of an apparatus for inserting an image, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 7, the apparatus 700 for inserting an image of the present embodiment includes: a first obtaining unit 701, configured to obtain a target human eye image, and determine human eye key point data of the target human eye image, where the human eye key point data is used to represent a position of a human eye key point in the target human eye image; a determining unit 702 configured to determine auxiliary key point data of the target human eye image based on the human eye key point data, wherein the auxiliary key point data is used for representing the position of an auxiliary key point in the target human eye image; a transformation unit 703 configured to perform coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data; and the inserting unit 704 is configured to acquire the image to be inserted, and insert the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image.
In this embodiment, the first acquiring unit 701 may first acquire the target human eye image from a remote location or a local location through a wired connection manner or a wireless connection manner. The target human eye image may be an image including an eye image of a target person (for example, a user using a terminal device as shown in fig. 1 or other person). For example, the target human eye image may be an image obtained by photographing eyes of a target person, or may be a human eye image extracted from a face image representing a face of the target person. It should be noted that the target eye image may be a single image; or may be an image of a human eye included in an image frame extracted from the target video. For example, the target human eye image may be a human eye image included in a currently displayed image frame included in the video played on the apparatus 700.
Then, the first acquisition unit 701 may determine eye key point data of the target eye image. The human eye key point data is used for representing the position of the human eye key point in the target human eye image. Generally, the human eye key point data may include coordinate values in a coordinate system established in advance in the target human eye image, and the positions of the human eye key points in the target human eye image may be determined according to the coordinate values. The human eye keypoints may be points that represent particular locations in the human eye image (e.g., points that represent corners of the eye, points that represent edges of the eyelids, etc.).
In this embodiment, the first obtaining unit 701 may determine the eye key point data of the target eye image by using various existing methods for determining the eye key point. For example, the first obtaining unit 701 may input the target human eye image into a human eye key point extraction model trained in advance to obtain human eye key point data.
In the present embodiment, the determination unit 702 may determine auxiliary key point data of the target human eye image based on the human eye key point data determined by the first acquisition unit 701. The auxiliary key point data is used for representing the position of the auxiliary key point in the target human eye image. The auxiliary key points may be key points added by the determination unit 702 in the target human eye image for characterizing a position of inserting the preset image into the target human eye image in combination with the human eye key point data.
Specifically, the determination unit 702 may determine the auxiliary key point data of the target human eye image in various methods. For example, the determining unit 702 may add the auxiliary key points within a preset range of the target human eye image (e.g., a range determined by a preset distance above the human eye key points representing the upper eyelid edge and the canthus of the human eye) according to data preset by a technician, and determine the auxiliary key point data. Wherein, the preset data includes but is not limited to at least one of the following: the distance between the auxiliary key points, and the distance between the auxiliary key points and the human eye key points.
In this embodiment, the transformation unit 703 may perform coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data. Specifically, the transformation unit 703 may perform coordinate transformation on the auxiliary key point data in various methods. As an example, the transforming unit 703 may determine a degree value representing the degree of openness of the human eye indicated by the target human eye image (for example, a ratio of a distance between human eye key points representing upper eyelid edge center points and lower eyelid edge center points of the eye to a distance between human eye key points representing left canthus and right canthus of the eye), search a coefficient corresponding to the determined degree value from a correspondence table of correspondence between a pre-established characteristic degree value and a coefficient used for coordinate transformation of the auxiliary key point data, transform a coordinate value included in the auxiliary key point data based on the coefficient (for example, multiply a vertical coordinate value and a horizontal coordinate value included in the auxiliary key point data by the corresponding coefficient, and obtain transformed auxiliary key point data.
In this embodiment, the insertion unit 704 may first acquire the image to be inserted from a remote location or from a local location. Wherein the image to be inserted may be an image to be inserted into the target human eye image. For example, the image to be inserted may be an eyelash image, an eye makeup image, or the like.
Then, the inserting unit 704 may insert the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image. Specifically, the positions represented by the transformed auxiliary key point data and the human eye key point data may be image regions formed by the transformed auxiliary key points and the human eye key points of the target human eye image. For example, assuming that the image to be inserted is an eyelash image, the image region having the smallest area including the transformed auxiliary key points and the key points of human eyes is the position where the image to be inserted is inserted.
In some optional implementations of this embodiment, the apparatus 700 may further include: a second obtaining unit (not shown in the figure) configured to obtain preset reference human eye key point data and reference auxiliary key point data, wherein the reference human eye key point data is used for representing the position of a human eye key point in a preset reference human eye image in the reference human eye image, and the reference auxiliary key point data is used for representing the position of a reference auxiliary key point which is set in the reference human eye image in advance.
In some optional implementations of this embodiment, the determining unit 702 may include: a construction module (not shown in the figures) configured to construct a first triangulation mesh based on the reference auxiliary key point data and the reference human eye key point data; a first determining module (not shown in the figure) configured to determine a second triangulation mesh formed on the target human eye image based on the side length and the inner angle of the triangle included in the first triangulation mesh and a correspondence between the human eye key point data and the human eye key point data of the target human eye image; a second determining module (not shown in the figures) configured to determine target vertices from the vertices of the triangles comprised by the second triangulation mesh and to determine auxiliary keypoint data of the target eye image based on the positions of the target vertices in the target eye image.
In some optional implementations of this embodiment, the transforming unit 703 may include: a transformation module (not shown in the figure) configured to perform coordinate transformation on the reference auxiliary key point data to obtain transformed reference auxiliary key point data; and the generating module (not shown in the figure) is configured to input the reference auxiliary key point data, the transformed reference auxiliary key point data and the auxiliary key point data of the target human eye image into a preset coordinate mapping model to obtain the transformed auxiliary key point data of the target human eye image.
In some optional implementations of this embodiment, the transformation module may include: a first determining submodule (not shown in the figure) configured to determine an openness degree value representing an openness degree of a human eye indicated by the target human eye image according to the human eye key point data of the target human eye image; a second determining submodule (not shown in the drawings) configured to determine a radian value for characterizing a degree of change of coordinates of the reference auxiliary key point data, according to a preset radian calculation formula and an abscissa included in the reference auxiliary key point data; a third determination submodule (not shown in the figures) configured to determine the transformed reference auxiliary keypoint data on the basis of the arc value and the openness value.
In some optional implementations of the present embodiment, the coordinate mapping model is a model constructed based on a moving least squares MLS.
In some optional implementations of this embodiment, the inserting unit 704 may include: an acquisition module (not shown in the figures) configured to acquire a preset image; a deformation module (not shown in the figure) configured to deform the preset image based on the human eye key point data and the transformed auxiliary key point data, and determine the deformed preset image as an image to be inserted.
According to the device provided by the embodiment of the application, the auxiliary key point data of the target human eye image is determined by determining the human eye key point data of the obtained target human eye image, the auxiliary key point data of the target human eye image is determined based on the human eye key point data, the coordinate transformation is performed on the auxiliary key point data to obtain the transformed auxiliary key point data, the preset image is transformed based on the transformed auxiliary key point data, and the transformed preset image is inserted into the corresponding position of the target human eye image, so that the flexibility of inserting the preset image into the human eye image is improved, and the display form of the preset image inserted into the human eye image is facilitated to be enriched.
Referring now to FIG. 8, a block diagram of a computer system 800 suitable for use in implementing an electronic device (e.g., the server or terminal device shown in FIG. 1) of an embodiment of the present application is shown. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 801.
It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable medium or any combination of the two. A computer readable medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a first acquisition unit, a determination unit, a transformation unit, and an insertion unit. Where the names of the cells do not in some cases constitute a limitation on the cells themselves, for example, the first acquisition unit may also be described as a "cell that acquires a target eye image, and determines eye key point data of the target eye image".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a target human eye image and determining human eye key point data of the target human eye image, wherein the human eye key point data is used for representing the position of a human eye key point in the target human eye image; determining auxiliary key point data of the target human eye image based on the human eye key point data, wherein the auxiliary key point data is used for representing the position of the auxiliary key point in the target human eye image; performing coordinate transformation on the auxiliary key point data to obtain transformed auxiliary key point data; and obtaining an image to be inserted, and inserting the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (10)

1. A method for inserting an image, comprising:
acquiring a target human eye image and determining human eye key point data of the target human eye image, wherein the human eye key point data is used for representing the position of a human eye key point in the target human eye image;
acquiring preset reference human eye key point data and reference auxiliary key point data, wherein the reference human eye key point data is used for representing the position of a human eye key point in a preset reference human eye image in the reference human eye image, and the reference auxiliary key point data is used for representing the position of a reference auxiliary key point preset in the reference human eye image;
determining auxiliary key point data of the target human eye image based on the human eye key point data, wherein the auxiliary key point data is used for representing the position of an auxiliary key point in the target human eye image;
determining an opening degree value representing the opening degree of the human eyes indicated by the target human eye image according to the human eye key point data of the target human eye image;
determining a radian value used for representing the change degree of coordinates of the reference auxiliary key point data according to a preset radian calculation formula and the abscissa included by the reference auxiliary key point data;
determining transformed reference auxiliary key point data based on the camber value and the opening degree value;
inputting the reference auxiliary key point data, the transformed reference auxiliary key point data and the auxiliary key point data of the target human eye image into a preset coordinate mapping model to obtain transformed auxiliary key point data of the target human eye image;
and obtaining an image to be inserted, and inserting the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image.
2. The method of claim 1, wherein said determining auxiliary keypoint data for the target human eye image based on the human eye keypoint data comprises:
constructing a first triangulation mesh based on the reference auxiliary key point data and the reference human eye key point data;
determining a second triangulation mesh formed on the target human eye image based on the side length and the inner angle of the triangle included in the first triangulation mesh and the corresponding relationship between the reference human eye key point data and the human eye key point data of the target human eye image;
determining a target vertex from the vertices of the triangles comprised by the second triangulation mesh, and determining auxiliary key point data of the target eye image based on the position of the target vertex in the target eye image.
3. The method of claim 1, wherein the coordinate mapping model is a model constructed based on Moving Least Squares (MLS).
4. The method according to one of claims 1-3, wherein the acquiring an image to be inserted comprises:
acquiring a preset image;
and based on the human eye key point data and the transformed auxiliary key point data, deforming the preset image, and determining the deformed preset image as an image to be inserted.
5. An apparatus for inserting an image, comprising:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is configured to acquire a target human eye image and determine human eye key point data of the target human eye image, and the human eye key point data is used for representing the position of a human eye key point in the target human eye image;
the second acquisition unit is configured to acquire preset reference human eye key point data and reference auxiliary key point data, wherein the reference human eye key point data is used for representing the positions of human eye key points in a preset reference human eye image in the reference human eye image, and the reference auxiliary key point data is used for representing the positions of reference auxiliary key points which are preset in the reference human eye image;
a determining unit configured to determine auxiliary key point data of the target human eye image based on the human eye key point data, wherein the auxiliary key point data is used for representing the position of an auxiliary key point in the target human eye image;
a transform unit comprising: the device comprises a transformation module and a generation module, wherein the change module comprises: the first determining submodule is configured to determine an opening degree value representing the opening degree of the human eye indicated by the target human eye image according to the human eye key point data of the target human eye image; a second determining submodule configured to determine a radian value used for representing a degree of change of coordinates of the reference auxiliary key point data according to a preset radian calculation formula and an abscissa included in the reference auxiliary key point data; a third determination submodule configured to determine post-transform reference assist keypoint data based on the camber value and the openness value; the generation module is configured to: inputting the reference auxiliary key point data, the transformed reference auxiliary key point data and the auxiliary key point data of the target human eye image into a preset coordinate mapping model to obtain transformed auxiliary key point data of the target human eye image;
and the inserting unit is configured to acquire an image to be inserted and insert the image to be inserted into the position represented by the transformed auxiliary key point data and the human eye key point data in the target human eye image.
6. The apparatus of claim 5, wherein the determining unit comprises:
a construction module configured to construct a first triangulation mesh based on the reference auxiliary keypoint data and the reference human eye keypoint data;
a first determination module configured to determine a second triangulation mesh formed on the target human eye image based on a side length and an inner angle of a triangle included in the first triangulation mesh and a correspondence between the reference human eye key point data and the human eye key point data of the target human eye image;
a second determination module configured to determine target vertices from vertices of triangles comprised by the second triangulation mesh and to determine auxiliary keypoint data of the target eye image based on locations of the target vertices in the target eye image.
7. The apparatus of claim 5, wherein the coordinate mapping model is a model constructed based on Moving Least Squares (MLS).
8. The apparatus according to one of claims 5-7, wherein the insertion unit comprises:
an acquisition module configured to acquire a preset image;
a deformation module configured to deform the preset image based on the human eye key point data and the transformed auxiliary key point data, and determine the deformed preset image as an image to be inserted.
9. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201810879255.8A 2018-08-03 2018-08-03 Method and apparatus for inserting image Active CN109165571B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810879255.8A CN109165571B (en) 2018-08-03 2018-08-03 Method and apparatus for inserting image

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN201810879255.8A CN109165571B (en) 2018-08-03 2018-08-03 Method and apparatus for inserting image
US16/631,343 US20210150787A1 (en) 2018-08-03 2018-11-19 Method and device for inserting image
PCT/CN2018/116180 WO2020024485A1 (en) 2018-08-03 2018-11-19 Method and device for inserting image

Publications (2)

Publication Number Publication Date
CN109165571A CN109165571A (en) 2019-01-08
CN109165571B true CN109165571B (en) 2020-04-24

Family

ID=64898913

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810879255.8A Active CN109165571B (en) 2018-08-03 2018-08-03 Method and apparatus for inserting image

Country Status (3)

Country Link
US (1) US20210150787A1 (en)
CN (1) CN109165571B (en)
WO (1) WO2020024485A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110070017B (en) * 2019-04-12 2021-08-24 北京迈格威科技有限公司 Method and device for generating human face artificial eye image

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101779218A (en) * 2007-08-10 2010-07-14 株式会社资生堂 Makeup simulation system, makeup simulation apparatus, makeup simulation method, and makeup simulation program
CN107341435A (en) * 2016-08-19 2017-11-10 北京市商汤科技开发有限公司 Processing method, device and the terminal device of video image
WO2018012136A1 (en) * 2016-07-14 2018-01-18 パナソニックIpマネジメント株式会社 Makeup assistance device and makeup assistance method

Family Cites Families (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4833322B2 (en) * 2009-06-26 2011-12-07 株式会社バンダイナムコゲームス Image generating apparatus and print sticker manufacturing method
CN101789990A (en) * 2009-12-23 2010-07-28 宇龙计算机通信科技(深圳)有限公司 Method and mobile terminal for judging emotion of opposite party in conservation process
CN101826217A (en) * 2010-05-07 2010-09-08 上海交通大学 Rapid generation method for facial animation
US8605972B2 (en) * 2012-03-02 2013-12-10 Sony Corporation Automatic image alignment
CN102999929A (en) * 2012-11-08 2013-03-27 大连理工大学 Triangular gridding based human image face-lift processing method
JP6128309B2 (en) * 2013-02-01 2017-05-17 パナソニックIpマネジメント株式会社 Makeup support device, makeup support method, and makeup support program
US8971592B2 (en) * 2013-05-09 2015-03-03 Universidad De Chile Method for determining eye location on a frontal face digital image to validate the frontal face and determine points of reference
CN104036299B (en) * 2014-06-10 2018-06-19 电子科技大学 A kind of human eye contour tracing method based on local grain AAM
CN104537630A (en) * 2015-01-22 2015-04-22 厦门美图之家科技有限公司 Method and device for image beautifying based on age estimation
JP6583660B2 (en) * 2015-03-26 2019-10-02 パナソニックIpマネジメント株式会社 Image composition apparatus and image composition method
CN104778712B (en) * 2015-04-27 2018-05-01 厦门美图之家科技有限公司 A kind of face chart pasting method and system based on affine transformation
CN108292423B (en) * 2015-12-25 2021-07-06 松下知识产权经营株式会社 Partial makeup making, partial makeup utilizing device, method, and recording medium
CN105631423A (en) * 2015-12-29 2016-06-01 厦门瑞为信息技术有限公司 Method for identifying human eye state by use of image information
CN105678252A (en) * 2016-01-05 2016-06-15 安阳师范学院 Iteration interpolation method based on face triangle mesh adaptive subdivision and Gauss wavelet
CN106296571B (en) * 2016-07-29 2019-06-04 厦门美图之家科技有限公司 A kind of diminution wing of nose method, apparatus based on face grid and calculating equipment
CN107343211B (en) * 2016-08-19 2019-04-09 北京市商汤科技开发有限公司 Method of video image processing, device and terminal device
CN106210545A (en) * 2016-08-22 2016-12-07 北京金山安全软件有限公司 A kind of video capture method, device and electronic equipment
CN108093156B (en) * 2016-11-23 2020-11-13 汤长春 Image capturing apparatus
CN108205795A (en) * 2016-12-16 2018-06-26 北京酷我科技有限公司 Face image processing process and system during a kind of live streaming
CN108305317B (en) * 2017-08-04 2020-03-17 腾讯科技(深圳)有限公司 Image processing method, device and storage medium
CN113128449A (en) * 2017-08-09 2021-07-16 北京市商汤科技开发有限公司 Neural network training method and device for face image processing, and face image processing method and device
CN108171789A (en) * 2017-12-21 2018-06-15 迈吉客科技(北京)有限公司 A kind of virtual image generation method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101779218A (en) * 2007-08-10 2010-07-14 株式会社资生堂 Makeup simulation system, makeup simulation apparatus, makeup simulation method, and makeup simulation program
WO2018012136A1 (en) * 2016-07-14 2018-01-18 パナソニックIpマネジメント株式会社 Makeup assistance device and makeup assistance method
CN107341435A (en) * 2016-08-19 2017-11-10 北京市商汤科技开发有限公司 Processing method, device and the terminal device of video image

Also Published As

Publication number Publication date
WO2020024485A1 (en) 2020-02-06
US20210150787A1 (en) 2021-05-20
CN109165571A (en) 2019-01-08

Similar Documents

Publication Publication Date Title
CN106910247B (en) Method and apparatus for generating three-dimensional avatar model
CN106846497B (en) Method and device for presenting three-dimensional map applied to terminal
CN109255830B (en) Three-dimensional face reconstruction method and device
US9818216B2 (en) Audio-based caricature exaggeration
CN109272543B (en) Method and apparatus for generating a model
CN109308469B (en) Method and apparatus for generating information
CN108550181B (en) Method, system and equipment for online tracking and dense reconstruction on mobile equipment
CN108898186B (en) Method and device for extracting image
CN108363995A (en) Method and apparatus for generating data
CN108388889A (en) Method and apparatus for analyzing facial image
CN108491881A (en) Method and apparatus for generating detection model
CN109165571B (en) Method and apparatus for inserting image
US20210183165A1 (en) Image processing method and apparatus, electronic device, and computer-readable storage medium
WO2020155908A1 (en) Method and apparatus for generating information
WO2020211573A1 (en) Method and device for processing image
CN108876704A (en) The method, apparatus and computer storage medium of facial image deformation
US10970938B2 (en) Method and apparatus for generating 3D information
WO2020024483A1 (en) Method and apparatus for processing image
Ko et al. Eye gaze correction for video conferencing using Kinect v2
CN109754464B (en) Method and apparatus for generating information
CN109948397A (en) A kind of face image correcting method, system and terminal device
CN110874869B (en) Method and device for generating virtual animation expression
CN111524062A (en) Image generation method and device
CN110059624B (en) Method and apparatus for detecting living body
CN113223128A (en) Method and apparatus for generating image

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant