Disclosure of Invention
An object of the embodiments of the present invention is to provide a method and an apparatus for processing an image, which are simple and convenient to operate and reduce the time consumption. The specific technical scheme is as follows:
the invention provides a picture processing method, which comprises the following steps:
obtaining a target decorative paster selected by a user for a target picture;
determining the type of a target human body area corresponding to the target decoration sticker according to the type information of the target decoration sticker;
identifying a target human body area of a figure displayed in the target picture, wherein the target human body area corresponds to the type of the target human body area;
calculating the size information to be utilized and the area to be added of the target decoration sticker in the target picture according to the identified target human body area and the type information of the target decoration sticker;
and adjusting the target decoration paster according to the size information to be utilized, and adding the adjusted target decoration paster to the area to be added of the target picture.
Optionally, the method further includes:
receiving an adjusting instruction sent by a user;
and responding to the adjusting instruction, and adjusting the area and/or the size of the added target ornament paper in the target picture.
Optionally, according to the type information of the target ornament sticker, determining the type of the target human body region corresponding to the target ornament sticker includes:
determining the human body area type corresponding to the type information of the target decoration sticker as the target human body area type corresponding to the target decoration sticker from a preset database;
the preset database stores the corresponding relation between the type information of the decorative sticker and the type of the human body area.
Optionally, the types of the target human body region are: eyes, nose, mouth or face.
Optionally, when the type of the target human body region is an eye, the identifying a target human body region of a person displayed in the target picture, which corresponds to the type of the target human body region, includes:
identifying a target face area in the target picture, and determining an area where eyes are located according to a first preset position relation between a face and the eyes;
or,
when the type of the target human body region is a nose, the identifying the target human body region of the person displayed in the target picture, which corresponds to the type of the target human body region, includes:
identifying a target face region in the target picture, and determining a region where a nose is located according to a second preset position relation between the face and the nose;
or,
when the type of the target human body area is mouth, the identifying the target human body area of the figure displayed in the target picture, which corresponds to the type of the target human body area, includes:
identifying a target face region in the target picture, and determining a region where the mouth is located according to a third preset position relation between the face and the mouth;
or,
when the type of the target human body region is a face, the identifying a target human body region of a person displayed in the target picture, which corresponds to the type of the target human body region, includes:
and identifying a target face area in the target picture and determining an area where the face is located.
Optionally, adding the adjusted target ornament sticker to the to-be-added area of the target picture includes:
determining a first reference point of the adjusted target ornament mark;
determining a second datum point corresponding to the first datum point in the area to be added;
and adding the adjusted target ornament paster in the area to be added of the target picture based on the first reference point and the second reference point.
The invention provides a picture processing device, comprising: the device comprises an obtaining module, a determining module, an identifying module, a calculating module and an adding module;
the obtaining module is used for obtaining a target ornament paper selected by a user for a target picture;
the determining module is used for determining the type of the target human body area corresponding to the target decoration sticker according to the type information of the target decoration sticker;
the identification module is used for identifying a target human body area of a figure displayed in the target picture, wherein the target human body area corresponds to the type of the target human body area;
the calculation module is used for calculating the size information to be utilized and the area to be added of the target decoration sticker in the target picture according to the identified target human body area and the type information of the target decoration sticker;
and the adding module is used for adjusting the target decoration sticker according to the size information to be utilized and adding the adjusted target decoration sticker to the area to be added of the target picture.
Optionally, the method further includes: the device comprises a receiving module and an adjusting module;
the receiving module is used for receiving an adjusting instruction sent by a user;
and the adjusting module is used for responding to the adjusting instruction and adjusting the area and/or the size of the added target ornament paper in the target picture.
Optionally, the determining module includes:
a first region type determining unit, configured to determine, from a preset database, a human body region type corresponding to the type information of the target decoration sticker as a target human body region type corresponding to the target decoration sticker;
the preset database stores the corresponding relation between the type information of the decorative sticker and the type of the human body area.
Optionally, the types of the target human body region are: eyes, nose, mouth or face.
Optionally, the identification module includes:
the eye identification unit is used for identifying a target human face area in the target picture when the type of the target human body area is eyes, and determining the area where the eyes are located according to a first preset position relation between the human face and the eyes;
or,
the identification module comprises:
the nose identification unit is used for identifying a target face region in the target picture when the type of the target human body region is a nose, and determining a region where the nose is located according to a second preset position relation between the face and the nose;
or,
the identification module comprises:
the mouth recognition unit is used for recognizing a target face region in the target picture when the type of the target human body region is a mouth, and determining a region where the mouth is located according to a third preset position relation between the face and the mouth;
or,
the identification module comprises:
and the face identification unit is used for identifying a target face area in the target picture and determining an area where the face is located when the type of the target human body area is the face.
Optionally, the adding module includes:
a first reference point determining unit, configured to determine a first reference point of the adjusted target ornament sticker after the adding module adjusts the target ornament sticker according to the size information to be utilized;
the second reference point determining unit is used for determining a second reference point corresponding to the first reference point in the area to be added;
and the adding unit is used for adding the adjusted target ornament paster in the area to be added of the target picture based on the first reference point and the second reference point.
Compared with the prior art, in the embodiment of the invention, the size information to be utilized and the area to be added of the target decoration sticker in the target picture are calculated according to the identified target human body area and the type information of the target decoration sticker, the target decoration sticker is adjusted according to the size information to be utilized, and the adjusted target decoration sticker is added to the area to be added of the target picture. Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to solve the problem of the prior art, embodiments of the present invention provide a method and an apparatus for processing an image.
First, a picture processing method provided by an embodiment of the present invention is described below.
It should be noted that the image processing method provided by the embodiment of the present invention is applied to a terminal device. In practical application, the terminal equipment can be a smart phone, a tablet computer, a notebook computer and the like, which are reasonable.
In addition, the functional software for implementing the image processing method provided by the embodiment of the invention can be independent client software for implementing decoration addition.
As shown in fig. 1, an image processing method provided in an embodiment of the present invention may include:
s101: and obtaining the target ornament mark selected by the user for the target picture.
The user can select one or more target decorative stickers according to the actual situation of the target picture, and the target decorative sticker selected by the user is obtained.
S102: and determining the type of the target human body area corresponding to the target decoration sticker according to the type information of the target decoration sticker.
Wherein, can classify the ornament sticker according to the human body region that the ornament sticker was decorated, for example: the decorative sticker may be classified into a type of decorative sticker (cap, hair, etc.) for decorating a face; decorative sticker types (glasses, eyebrows, etc.) that decorate the eyes; decorative sticker types (beard and pipe, etc.) that decorate the mouth.
Furthermore, after the target ornament sticker selected by the user for the target picture is obtained, the human body area decorated by the target ornament sticker can be determined according to the type of the ornament sticker to which the target ornament sticker belongs.
Specifically, in an implementation manner, determining the type of the target human body region corresponding to the target ornament sticker according to the type information of the target ornament sticker may include:
determining the human body area type corresponding to the type information of the target decoration sticker as the target human body area type corresponding to the target decoration sticker from a preset database;
wherein, the preset database stores the corresponding relationship between the type information of the decorative sticker and the type of the human body area.
The body region type may be, but is not limited to, eyes, nose, mouth, or face. In the preset database, the type of the decorative paster for decorating the face corresponds to the face, the type of the decorative paster for decorating the eyes corresponds to the eyes, the type of the decorative paster for decorating the mouth corresponds to the mouth, and the type of the decorative paster for decorating the nose corresponds to the nose.
After the type of the target decoration sticker is determined, the human body region type corresponding to the type can be found from a preset database, and the found human body region type is determined as the target human body region type corresponding to the target decoration sticker.
S103: and identifying a target human body area of the character displayed in the target picture, which corresponds to the type of the target human body area.
After the type of the target human body area is determined, the target human body area corresponding to the type of the target human body area is identified in the target picture, and then corresponding processing is executed according to the identified target human body area and the type of the target decorative sticker to determine the relevant adding information of the target decorative sticker.
Specifically, in one implementation, the target body region types may be: eyes, nose, mouth or face.
When the type of the target human body area is eyes, identifying the target human body area of the figure displayed in the target picture, which corresponds to the type of the target human body area, and the method comprises the following steps:
identifying a target face area in the target picture, and determining an area where eyes are located according to a first preset position relation between a face and the eyes;
or,
when the type of the target human body region is a nose, identifying the target human body region of the person displayed in the target picture, which corresponds to the type of the target human body region, includes:
identifying a target face region in the target picture, and determining a region where a nose is located according to a second preset position relation between the face and the nose;
or,
when the type of the target human body area is mouth, identifying the target human body area of the figure displayed in the target picture, which corresponds to the type of the target human body area, and the method comprises the following steps:
identifying a target face area in the target picture, and determining an area where the mouth is located according to a third preset position relation between the face and the mouth;
or,
when the type of the target human body area is a face, identifying the target human body area of the person displayed in the target picture, which corresponds to the type of the target human body area, and the method comprises the following steps:
and identifying a target face area in the target picture and determining an area where the face is located.
Due to the fact that the five sense organs of the person have certain position relations, the position relations between the face and the eyes, between the face and the nose and between the face and the mouth can be determined, after the target face area in the target picture is identified, the area where the eyes are located can be identified according to the position relation between the face and the eyes, the area where the nose is located can be identified according to the position relation between the face and the nose, and the area where the mouth is located can be identified according to the position relation between the face and the mouth.
It should be noted that, any existing face recognition algorithm may be used for recognizing the target face region in the target picture, which is not limited herein.
S104: and calculating the size information to be utilized and the area to be added of the target ornament paster in the target picture according to the identified target human body area and the type information of the target ornament paster.
In order to add the target ornament sticker to the target picture, it is necessary to determine the size information to be utilized and the area to be added of the target ornament sticker in the target picture.
When decorating the same target human body area, the sizes to be utilized and the areas to be added, which are required by different target decoration stickers, are different, for example: the hu and the pipe are both target decoration stickers for decorating the mouth, the hu needs to be placed on the upper portion of the mouth, the region to be added of the hu in the target picture is determined to be a region formed by a surrounding frame on the upper portion of the mouth, the size of the hu corresponds to the size of the mouth to be decorated, the pipe needs to be placed in the middle of the mouth, the region to be added of the pipe in the target picture is determined to be a region formed by a surrounding frame in the middle of the mouth, and the size of the pipe corresponds to the size of the mouth to be decorated.
S105: and adjusting the target decoration sticker according to the size information to be utilized, and adding the adjusted target decoration sticker to the area to be added of the target picture.
After determining the information of the size to be utilized and the area to be added of the target decoration sticker in the target picture, correspondingly amplifying or reducing the target decoration sticker to the calculated size to be utilized, and adding the amplified or reduced target decoration sticker to the area to be added of the target picture.
Specifically, in an implementation manner, adding the adjusted target ornament paper to the area to be added of the target picture may include:
determining a first reference point of the adjusted target ornament mark;
determining a second datum point corresponding to the first datum point in the area to be added;
and adding the adjusted target ornament paster in the area to be added of the target picture based on the first reference point and the second reference point.
The first reference point can be a center point, a gravity center point or any point capable of calibrating the position of the target decoration sticker, and the second reference point is a point on the area to be added corresponding to the first reference point.
Specifically, based on the first reference point and the second reference point, there are two ways to add the adjusted target ornament sticker to the area to be added of the target picture:
the first method is as follows: the adjusted target ornament paper can be added in the area to be added of the target picture by coinciding the first reference point with the second reference point.
For example: the target decorative sticker is glasses, the area to be added of the glasses in the target picture is an area formed by a surrounding frame which can surround the eyes of the person in the target picture, the size of the glasses corresponds to the size of the eyes of the person in the target picture, then the first datum point is a center point A of the glasses, the second datum point is a center point B of the eyes of the person in the target picture, A and B are overlapped, and the glasses are added to the area formed by the surrounding frame.
In a second mode, the adjusted target ornament sticker can be added in the area to be added of the target picture in a mode of a preset position relation between the first reference point and the second reference point.
For example: the target ornament sticker is a beard, the area to be added of the beard in the target picture is an area formed by a surrounding frame surrounding the upper portion of the mouth of the person in the target picture, the size of the beard corresponds to the size of the mouth of the person in the target picture, the first reference point is a center point A of the beard, the second reference point is a center point B of the mouth of the person in the target picture, and the beard is added to the area formed by the surrounding frame according to the position relationship between A and B due to the fact that the mouth of the person and the beard have a certain position relationship.
Compared with the prior art, in the embodiment of the invention, the size information to be utilized and the area to be added of the target decoration sticker in the target picture are calculated according to the identified target human body area and the type information of the target decoration sticker, the target decoration sticker is adjusted according to the size information to be utilized, and the adjusted target decoration sticker is added to the area to be added of the target picture.
Further, on the basis of the embodiment shown in fig. 1, as shown in fig. 2, another picture processing method provided by the present invention may further include:
s201: and receiving an adjusting instruction sent by a user.
Although the determined size to be utilized and the area to be added of the target decoration sticker can reach higher accuracy, the problem that the size information to be utilized and the area to be added of the target decoration sticker do not meet the requirements of the user may exist due to different requirements of different users on actual decoration, and in order to improve the use experience of the user, the user can finely adjust the target decoration sticker according to actual conditions. Specifically, after the user can select the target ornament sticker, the user performs position dragging operation and size zooming operation on the target ornament sticker, and correspondingly, the terminal device can receive a corresponding adjusting instruction sent by the user, and then subsequently responds to the adjusting instruction.
S202: and responding to the adjusting instruction, and adjusting the area and/or the size of the added target ornament paper in the target picture.
For example: the target ornament paper is a beard, the beard is added to the middle part of the mouth to cover the mouth, and the user can adjust the beard to the upper part of the mouth to enable the beard and the mouth to be matched more.
Therefore, the target ornament paster is adjusted by receiving the adjustment instruction aiming at the target ornament paster sent by the user, so that the adjusted target ornament paster better meets the requirement of the user.
With respect to the foregoing method embodiment, an embodiment of the present invention further provides an image processing apparatus, as shown in fig. 3, the apparatus may include: an obtaining module 301, a determining module 302, a recognizing module 303, a calculating module 304 and an adding module 305;
the obtaining module 301 is configured to obtain a target ornament sticker selected by a user for a target picture;
the determining module 302 is configured to determine a type of a target human body region corresponding to the target ornament sticker according to the type information of the target ornament sticker;
the identification module 303 is configured to identify a target human body region of a person displayed in the target picture, where the target human body region corresponds to the type of the target human body region;
the calculating module 304 is configured to calculate size information to be utilized and an area to be added of the target ornament sticker in the target picture according to the identified target human body area and the type information of the target ornament sticker;
the adding module 305 is configured to adjust the target ornament sticker according to the size information to be utilized, and add the adjusted target ornament sticker to the area to be added of the target picture.
Compared with the prior art, in the embodiment of the invention, the size information to be utilized and the area to be added of the target decoration sticker in the target picture are calculated according to the identified target human body area and the type information of the target decoration sticker, the target decoration sticker is adjusted according to the size information to be utilized, and the adjusted target decoration sticker is added to the area to be added of the target picture. Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
The determining module 302 may include:
a first region type determining unit, configured to determine, from a preset database, a human body region type corresponding to the type information of the target decoration sticker as a target human body region type corresponding to the target decoration sticker;
the preset database stores the corresponding relation between the type information of the decorative sticker and the type of the human body area.
The types of the target human body areas are as follows: eyes, nose, mouth or face.
The identification module may include:
the eye identification unit is used for identifying a target human face area in the target picture when the type of the target human body area is eyes, and determining the area where the eyes are located according to a first preset position relation between the human face and the eyes;
or,
the identification module may include:
the nose identification unit is used for identifying a target face region in the target picture when the type of the target human body region is a nose, and determining a region where the nose is located according to a second preset position relation between the face and the nose;
or,
the identification module may include:
the mouth recognition unit is used for recognizing a target face region in the target picture when the type of the target human body region is a mouth, and determining a region where the mouth is located according to a third preset position relation between the face and the mouth;
or,
the identification module may include:
and the face identification unit is used for identifying a target face area in the target picture and determining an area where the face is located when the type of the target human body area is the face.
The adding module 305 may include:
a first reference point determining unit, configured to determine a first reference point of the adjusted target ornament sticker after the adding module adjusts the target ornament sticker according to the size information to be utilized;
the second reference point determining unit is used for determining a second reference point corresponding to the first reference point in the area to be added;
and the adding unit is used for adding the adjusted target ornament paster in the area to be added of the target picture based on the first reference point and the second reference point.
Further, on the basis of the embodiment shown in fig. 3, as shown in fig. 4, another image processing apparatus provided by the present invention may further include: a receiving module 401 and an adjusting module 402;
the receiving module 401 is configured to receive an adjustment instruction sent by a user;
the adjusting module 402 is configured to adjust an area and/or a size of the added target ornament paper in the target picture in response to the adjusting instruction.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.