CN109325908B - Image processing method and device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN109325908B
CN109325908B CN201811278366.XA CN201811278366A CN109325908B CN 109325908 B CN109325908 B CN 109325908B CN 201811278366 A CN201811278366 A CN 201811278366A CN 109325908 B CN109325908 B CN 109325908B
Authority
CN
China
Prior art keywords
image
position information
key point
photographed image
photographed
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
CN201811278366.XA
Other languages
Chinese (zh)
Other versions
CN109325908A (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 Sensetime Technology Development Co Ltd
Original Assignee
Beijing Sensetime Technology Development 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 Sensetime Technology Development Co Ltd filed Critical Beijing Sensetime Technology Development Co Ltd
Priority to CN201811278366.XA priority Critical patent/CN109325908B/en
Publication of CN109325908A publication Critical patent/CN109325908A/en
Application granted granted Critical
Publication of CN109325908B publication Critical patent/CN109325908B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • G06T3/147
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/161Detection; Localisation; Normalisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof

Abstract

The present disclosure relates to an image processing method and apparatus, an electronic device, and a storage medium, the method including: under the condition of receiving a photographing instruction, acquiring first position information of each key point in the preview image and a photographing image; acquiring a front image of a target object in the photographed image by using the first position information of each key point, and determining the second position information of each key point of the front image; and determining whether the second position information meets a preset condition, if so, adding a virtual effect according to the position corresponding to the second position information meeting the preset condition in the photographed image, otherwise, adding the virtual effect according to the third position information of each key point identified in the photographed image. The embodiment of the invention can accurately identify the virtual effect of the photographed image.

Description

Image processing method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of image processing, and in particular, to an image processing method and apparatus, an electronic device, and a storage medium.
Background
Currently, virtual reality technology or augmented reality technology is favored by many users due to its strong interactivity. For example, an electronic apparatus having an image capturing function may add virtual effects such as wearing selected hats, glasses, facial deformation, face thinning, beauty, slimming, wearing ornaments, and the like while taking a photograph. However, most of the current electronic devices only store the current preview frame image in order to obtain the effect of the virtual features when photographing, the resolution of the image resolution of the preview frame is low, and the virtual effect is not accurate enough.
Disclosure of Invention
The embodiment of the disclosure provides an image processing method and device, electronic equipment and a storage medium, wherein the position of a key point in an image can be accurately identified, so that a virtual effect can be accurately realized.
According to an aspect of the present disclosure, there is provided an image processing method including:
under the condition of receiving a photographing instruction, acquiring first position information of each key point in the preview image and a photographing image;
acquiring a front image of a target object in the photographed image by using the first position information of each key point, and determining the second position information of each key point of the front image;
and determining whether the second position information meets a preset condition, if so, adding a virtual effect according to the position corresponding to the second position information meeting the preset condition in the photographed image, otherwise, adding the virtual effect according to the third position information of each key point identified in the photographed image.
In one possible implementation manner, the obtaining the front image of the target object in the photographed image by using the first position information of each key point, and determining the second position information of each key point of the front image includes:
According to the image parameters of the photographed image, converting the first position information of each key point into fourth position information which is adaptive to the image parameters of the photographed image;
and obtaining a front image of the target object in the photographed image according to the fourth position information of each key point matched with the image parameters of the photographed image, and determining second position information of each key point of the front image.
In a possible implementation manner, the converting the first position information of each key point into fourth position information adapted to the image parameters of the photographed image according to the image parameters of the photographed image includes at least one of the following ways:
scaling the first position information of each key point in the preview image according to the resolution of the photographed image to obtain each fourth position information;
performing offset processing on the first position information of each key point in the preview image according to the offset between the corresponding key points in the photographed image and the preview image to obtain each fourth position information;
and scaling the first position information of each key point in the preview image according to the resolution of the photographed image, and performing offset processing on the first position information of each key point after scaling based on the offset between the first position information of the key point after scaling and the position information of the corresponding key point on the photographed image to obtain the fourth position information.
In a possible implementation manner, the obtaining the front image of the target object in the photographed image according to the fourth position information of each key point adapted to the image parameters of the photographed image includes:
determining an image area of a target object in the photographed image;
and obtaining a front image of the target object of the photographed image by affine transformation by using the fourth position information of each key point and a standard image, wherein the standard image comprises at least one of a standard face image, a standard limb image and a standard posture image.
In one possible implementation manner, the obtaining the front image of the target object of the photographed image by affine transformation using the fourth location information of each key point and a standard image includes:
comparing the fourth position information of each key point with the standard position information of each key point in the standard image to obtain a correction matrix for adjusting the photographed image, wherein the correction matrix comprises adjustment parameters of the positions of each key point;
and correcting the target object of the photographed image based on the correction matrix to obtain a front image of the target object of the photographed image.
In a possible implementation manner, the adding a virtual effect according to a position corresponding to the second position information satisfying the preset condition in the photographed image includes:
if the second position information meets the preset condition, determining fifth position information corresponding to the second position information in the photographed image according to the correction matrix;
and adding virtual features according to the fifth position information of each key point.
In a possible implementation manner, the determining whether the second position information meets a preset condition includes:
obtaining the confidence of the second position information;
and determining that the second position information meets a preset condition under the condition that the confidence coefficient of the second position information is larger than or equal to the confidence coefficient threshold value.
In a possible implementation manner, the determining whether the second position information meets a preset condition further includes:
repeatedly executing the fourth position information of each key point adapted to the image parameters of the photographed image under the condition that the confidence coefficient of the second position information is smaller than the confidence coefficient threshold value, obtaining a front image of a target object in the photographed image and identifying the second position information of each key point of the front image;
And if the number of times of repeated execution reaches the number of times threshold, determining that the confidence coefficient of the determined second position information is still smaller than the confidence coefficient threshold, determining that the second position information does not meet the preset condition, and determining that the confidence coefficient of the obtained second position information is larger than or equal to the confidence coefficient threshold in the repeated execution process, and determining that the second position information with the confidence coefficient larger than or equal to the confidence coefficient threshold meets the preset condition.
In one possible embodiment, the method further comprises:
and determining the virtual feature to be added based on the received selection information so as to add the virtual feature according to the second position information or add the virtual feature according to the third position information.
In one possible embodiment, the method further comprises:
and acquiring first position information of each key point in the preview image and third position information of each key point in the photographed image by using the neural network model.
According to a second aspect of the present disclosure, there is provided an image processing apparatus including:
the acquisition module is used for acquiring the first position information of each key point in the preview image and the photographed image under the condition of receiving the photographing instruction;
The determining module is used for obtaining a front image of the target object in the photographed image by using the first position information of each key point and determining the second position information of each key point of the front image;
and the virtual module is used for determining whether the second position information meets the preset condition, if so, adding a virtual effect according to the position corresponding to the second position information meeting the preset condition in the photographed image, otherwise, adding the virtual effect according to the third position information of each key point identified in the photographed image.
In one possible implementation, the determining module includes:
the conversion unit is used for converting the first position information of each key point into fourth position information which is matched with the image parameters of the photographed image according to the image parameters of the photographed image; and
and the key point determining unit is used for obtaining a front image of a target object in the photographed image according to the fourth position information of each key point matched with the image parameters of the photographed image and determining second position information of each key point of the front image.
In a possible implementation manner, the conversion unit is further configured to perform the conversion of the first location information of each key point into fourth location information adapted to the image parameters of the photographed image according to at least one of the following manners:
Scaling the first position information of each key point in the preview image according to the resolution of the photographed image to obtain each fourth position information;
performing offset processing on the first position information of each key point in the preview image according to the offset between the corresponding key points in the photographed image and the preview image to obtain each fourth position information;
and scaling the first position information of each key point in the preview image according to the resolution of the photographed image, and performing offset processing on the first position information of each key point after scaling based on the offset between the first position information of the key point after scaling and the position information of the corresponding key point on the photographed image to obtain the fourth position information.
In a possible implementation manner, the keypoint determining unit is further configured to determine an image area of the target object in the photographed image, and obtain, by using the fourth location information of each keypoint and a standard image, a front image of the target object in the photographed image by affine transformation, where the standard image includes at least one of a standard face image, a standard limb image, and a standard pose image.
In a possible implementation manner, the key point determining unit is further configured to compare the fourth location information of each key point with the standard location information of each key point in the standard image, so as to obtain a correction matrix for adjusting the photographed image, where the correction matrix includes adjustment parameters for positions of each key point; and
and correcting the target object of the photographed image based on the correction matrix to obtain a front image of the target object of the photographed image.
In a possible implementation manner, the virtual module is further configured to determine, according to the correction matrix, fifth location information corresponding to the second location information in the photographed image, where the second location information meets a preset condition; and adding virtual features according to the fifth position information of each key point.
In a possible implementation manner, the virtual module is further configured to obtain a confidence level of the second location information, and determine that the second location information meets a preset condition when the confidence level of the second location information is greater than or equal to the confidence level threshold.
In a possible implementation manner, the virtual module is further configured to repeatedly execute the fourth location information of each key point adapted to the image parameter of the photographed image, obtain a front image of the target object in the photographed image, and identify second location information of each key point of the front image, where the confidence level of the second location information is less than the confidence level threshold;
When the number of times of repeated execution reaches a number of times threshold, determining that the second position information does not meet a preset condition when the determined confidence level of the second position information is still smaller than the confidence level threshold, and determining that the second position information with the confidence level greater than or equal to the confidence level threshold meets the preset condition when the obtained confidence level of the second position information is greater than or equal to the confidence level threshold in the repeated execution process.
In one possible embodiment, the apparatus further comprises:
a receiving module for receiving selection information;
the virtual module is further configured to determine a virtual feature to be added based on the received selection information, so as to add the virtual feature according to the second location information, or add the virtual feature according to the third location information.
In one possible implementation manner, the obtaining module is further configured to obtain, using the neural network model, first location information of each key point in the preview image, and third location information of each key point in the photographed image.
According to a third aspect of the present disclosure, there is provided an electronic apparatus, characterized by comprising:
a processor;
a memory for storing processor-executable instructions;
Wherein the processor is configured to: performing the method of any of the first aspects.
According to a fourth aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the method of any one of the first aspects.
The embodiment of the disclosure can realize the tracking of the preview image, and the addition of the virtual characteristics of the photographed image can be realized by combining the tracking result of the preview image, so that the virtual effect can be accurately realized. The method comprises the steps of firstly obtaining a front image corresponding to a target object in a photographed image according to image parameters of the photographed image, determining whether second position information of each key point in the front image meets preset conditions or not, realizing virtual effects in the photographed image according to the second position information determined by tracking of the preview image if the second position information meets the preset conditions, and directly realizing the virtual effects according to positions of the key points identified in the photographed image if the second position information does not meet the preset conditions.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the technical aspects of the disclosure.
FIG. 1 shows a flow chart of an image processing method according to an embodiment of the present disclosure;
fig. 2 shows a flowchart of step S200 in an image processing method according to an embodiment of the present disclosure;
fig. 3 shows a process schematic diagram of step S201 in an image processing method according to an embodiment of the present disclosure;
fig. 4 shows a flowchart of step S202 in an image processing method according to an embodiment of the present disclosure;
fig. 5 shows a flowchart of step S2022 in an image processing method according to an embodiment of the present disclosure;
FIG. 6 illustrates a front-to-back contrast diagram for performing correction of a face region of a target object in accordance with an embodiment of the present disclosure;
FIG. 7 illustrates a flowchart of determining whether the second location information satisfies a preset condition in accordance with an embodiment of the present disclosure;
Fig. 8 illustrates a flowchart of adding a virtual effect according to second position information in step S400 in an image processing method according to an embodiment of the present disclosure;
fig. 9 shows a block diagram of an image processing apparatus according to an embodiment of the present disclosure;
fig. 10 shows a block diagram of an electronic device 800, according to an embodiment of the disclosure;
fig. 11 shows a block diagram of an electronic device 1900 according to an embodiment of the disclosure.
Detailed Description
Various exemplary embodiments, features and aspects of the disclosure will be described in detail below with reference to the drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Although various aspects of the embodiments are illustrated in the accompanying drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Furthermore, numerous specific details are set forth in the following detailed description in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements, and circuits well known to those skilled in the art have not been described in detail in order not to obscure the present disclosure.
It will be appreciated that the above-mentioned method embodiments of the present disclosure may be combined with each other to form a combined embodiment without departing from the principle logic, and are limited to the description of the present disclosure.
Fig. 1 shows a flowchart of an image processing method according to an embodiment of the present disclosure, wherein the image processing method may include:
s100: under the condition of receiving a photographing instruction, acquiring first position information of each key point in the preview image and a photographing image;
s200: acquiring a front image of a target object in the photographed image by using the first position information of each key point, and determining the second position information of each key point of the front image;
s300: and determining whether the second position information meets a preset condition, if so, adding a virtual effect according to the position corresponding to the second position information meeting the preset condition in the photographed image, otherwise, adding the virtual effect according to the third position information of each key point determined from the photographed image.
The image processing method provided by the embodiment of the disclosure may be applied to an electronic device capable of performing photographing or image capturing operation, particularly an electronic device capable of adding a virtual feature to achieve a virtual effect when photographing or image capturing, where the electronic device may include a mobile phone, a camera, a beauty device, an AR image capturing device, and the like, but the embodiment of the disclosure is not limited thereto. In addition, the embodiment of the disclosure can be applied to the embodiment of shooting the image of the person, namely, the virtual feature can be added through the recognition of the facial feature, or the virtual special effect of the key points of the hand and the limb can be also applied to the embodiment of slimming, body beautifying, face beautifying and the like, and the embodiment of the disclosure can be applied to realize the virtual effect as long as the condition of shooting the person is involved.
In the embodiment of the disclosure, a photographed image can be previewed in real time in the process of performing photographing operation, and a user can adjust photographing parameters according to the state of the previewed image, wherein the photographing parameters can include angle, brightness, exposure time and the like. The user can also select the virtual effect to be presented, and the virtual effect can be previewed in real time through the preview image. Therefore, the user can adjust the photographing parameters and the selected virtual effect when previewing the image, and based on this, the embodiment of the disclosure can acquire the preview image of one frame before the photographing operation is performed and the photographing image of the photographing result when receiving the photographing instruction. The preview image and the photographed image are closest in similarity, so that the embodiment of the disclosure can determine the positions of key points in the photographed image by combining the preview image, and has the characteristic of higher precision. In addition, the image processing method in the embodiment of the present disclosure may be applied in a case where a photographic subject is a person.
The process of obtaining the preview image is described in detail herein, the user may select a virtual effect to be achieved before photographing, such as selecting an added virtual feature, a virtual scene where the virtual feature is located, a beautifying effect, a body beautifying effect, a slimming effect, and a photographing parameter that may also adjust brightness and a photographing angle, which may be presented in a preview manner before photographing operation. And when the user is satisfied with the preview effect, executing photographing operation. The embodiment of the disclosure can execute the real-time buffering of the preview image in the process of previewing (before receiving the photographing instruction), acquire the last preview image when receiving the photographing instruction and not acquiring the photographing image when receiving the photographing instruction, and execute the optimization of the key points of the acquired photographing image by utilizing the preview image. The resolution ratio and the image size of the preview image and the photographed image are different, so that after the preview image and the photographed image are acquired, the position information of the key points in the preview image can be adaptively adjusted based on the image parameters of the photographed image, so that the positions of the key points in the adjusted preview image are adapted to the image parameters of the photographed image. Among them, the image parameters may include resolution, size parameters of the image, and the like, but the embodiment of the present disclosure is not limited thereto.
Under the condition that a photographing instruction is received, first position information of each key point in a preview image of a frame before the photographing image is acquired can be identified, and photographing operation can be performed according to the photographing instruction to acquire the photographing image. The key points may be pre-configured key objects, for example, for facial images, may include key points of eyes, eyebrows, nose, ears, lips, etc., or for hand images, may include key points of fingers, palm, etc., and for different photographed images, locations of different key points may be identified, for example, also may include shoulders, necks, hips, wrists, etc., which is not specifically limited in this disclosure. The preview image may be input to a neural network model, and the first location information of each key point may be identified according to the neural network model, which may include a convolutional neural network model. In addition, the positions of the key points may be represented in the form of coordinates, such as two-dimensional or three-dimensional coordinates, and may be specifically set according to requirements, and the embodiments of the present disclosure are not limited.
In addition, the received photographing instruction may include information of the virtual effect to be added. When the user triggers the photographing key, the electronic device can also acquire the information of the currently selected virtual effect, and generate a photographing instruction based on the information of the virtual effect. So that a virtual effect can be added according to the determined location information of the key point when step S300 is performed.
After the preview image and the photographed image are acquired, step S200 may be performed. Fig. 2 is a flowchart illustrating a step S200 in an image processing method according to an embodiment of the present disclosure, where the obtaining a front image of a target object in the photographed image according to the first location information using each key point and determining second location information of each key point of the front image in the embodiment of the present disclosure (step S200) may include:
s201: according to the image parameters of the photographed image, converting the first position information of each key point into fourth position information which is adaptive to the image parameters of the photographed image;
s202: obtaining a front image of a target object in the photographed image according to the fourth position information of each key point matched with the image parameters of the photographed image and determining second position information of each key point of the front image
In the embodiment of the disclosure, since the parameters of the image in the preview state (preview image) and the photographed image obtained by photographing may be different, for example, the size and resolution of the image may be different, and at this time, the parameters of the preview image and the photographed image need to be adapted, so that the positions of the corresponding key points are conveniently associated. Therefore, in the case where the image parameters of the photographed image and the preview image are different, the first position information of each key point in the preview image acquired in step S100 needs to be converted into fourth position information adapted to the photographed image according to the image parameters of the photographed image. Wherein, according to the parameter difference of the photographed image and the preview image, step S201 of the embodiment of the present disclosure may include at least one of the following ways:
a) Scaling the first position information of each key point in the preview image according to the resolution of the photographed image to obtain each fourth position information;
when the resolution ratio between the photographed image and the preview image is in a multiple relationship, the first position information can be converted in a mode a. For example, when the resolution of the preview image is a×b and the resolution of the photographed image is ka×kb, the first position information of each key point of the preview image may be enlarged or reduced. For example, when K is greater than 1, that is, the first position information is subjected to the enlargement processing, and when K is less than 1, the first position information is subjected to the reduction processing. When the coordinates of the first position information are (x, y), the coordinates of the fourth position information after the scaling process may be (Kx, ky).
b) Performing offset processing on the first position information of each key point in the preview image according to the offset between the corresponding key points in the photographed image and the preview image to obtain each fourth position information;
when the length or width between the photographed image and the preview image is the same, each piece of first position information may be converted in the b-mode. When the lengths of the photographed image and the preview image are the same, the offset processing may be performed on each first position information according to the offset in the width direction, and when the widths of the photographed image and the preview image are the same, the offset processing may be performed on the first position information according to the offset in the length direction. For example, when the resolution of the preview image is a×b and the resolution of the photographed image is a×b+c, it means that the lengths of the preview image and the photographed image are the same and the widths are different, and C is the offset between the two, that is, the offset of the corresponding key point, and at this time, the first position information may be offset according to C, and the coordinates of the obtained fourth position information are (x, y+c). When the resolution of the preview image is a×b and the resolution of the photographed image is (a+c) ×b, it indicates that the widths of the preview image and the photographed image are the same and the lengths are different, and C is the offset between the two, that is, the offset of the corresponding key point, where the coordinates of the fourth position information obtained by performing offset processing on the first position information according to C are (x+c, y). Wherein, C can be positive number or negative number, and corresponding conversion process can be executed according to different conditions.
c) And scaling the first position information of each key point in the preview image according to the resolution of the photographed image, and performing offset processing on the first position information of each key point after scaling based on the offset between the first position information of the key point after scaling and the position information of the corresponding key point on the photographed image to obtain the fourth position information.
Wherein when the length and width of the photographed image and the preview image are different, the fourth position information can be determined in the C-manner. For example, if the resolution of the photographed image is generally much greater than that of the preview image, the first position information may be enlarged, so that the enlarged first position information is the same as the width and/or length of the photographed image. Fig. 3 shows a process diagram of step S201 in an image processing method according to an embodiment of the present disclosure.
The disclosed embodiments may determine the multiple of the scaling process by a first formula, wherein the expression of the first formula includes: scale=min (w 2/h2, w1/h 1). Where scale is a multiple of the scaling process, (w 2, h 2) is the resolution (size) of the photographed image, (w 1, h 1) is the resolution (size) of the preview image, and min is a small-valued function. That is, the multiple of the scaling process may be a smaller value of a first ratio between the length of the photographed image and the length of the preview image, and a second ratio between the width of the photographed image and the width of the preview image. In addition, the zooming processing of the preview image according to the embodiment of the present disclosure includes zooming processing of coordinates of key points in the preview image, that is, zooming coordinates of first position information of each key point in the preview image according to a zoom multiple. The number of keypoints in the preview image may guarantee the features of the preview image and not distort the preview image. For example, the number of keypoints may be tens, which is not limiting of the embodiments of the present disclosure.
As shown in fig. 3, the preview image obtained in the embodiment of the present disclosure may be a, where the resolution of a may be 720×1280, and the resolution of the photographed image may be 3000×4000, and the first location information of each key point in the preview image may be obtained (when a photographing instruction is received or when the preview image is received), so that the scaling process may be performed on the first location information of each key point in the preview image a according to the resolution of the photographed image in step S201. The first coordinate (first position information) of each key point on the preview image can be adjusted according to the resolution of the photographed image, the relative position of each key point is ensured to be unchanged, and the first position information scaling processing is realized. For example, since the scaling factor min (3000/720,4000/1280) =3.125 may be determined first, the first coordinates of each key point in the preview image may be enlarged so that the scaling factor is 3.125. For example, the first coordinates of the keypoints on the preview image are (x, y), the coordinates of the keypoints after the enlargement processing are (3.125×x,3.125×y), and the scaling of the keypoints of the preview image a onto the map B having the resolution of 2250×4000 corresponds to obtaining the first position information (B) of each of the keypoints after the scaling processing. The above examples are merely exemplary illustrations of preview image scaling processes according to embodiments of the present disclosure, and are not intended to be a specific limitation of the embodiments of the present disclosure.
After the scaling processing of the preview image is performed, the offset processing may be further performed on the first position information of the preview image after the scaling processing according to the size or specification of the photographed image. For example, after the scaling, the aspect ratio of the obtained scaled preview image may be different from that of the photographed image, and in this case, the first image matched with the photographed image may be obtained by performing offset processing on the first position information of each key point after the scaling. For example, corresponding keypoints may be determined in the preview image and the photographed image, respectively, and the positional offset between the two keypoints is an offset by which the offset processing is performed. For example, the offset processing may be performed according to an offset amount between the first key point of the upper left corner of the preview image and the first key point of the upper left corner in the photographed image. Alternatively, the offset processing may be performed based on the amount of offset between the key points in the center of the preview image and the key points in the center of the photographed image. That is, the offset used when performing the offset processing in the embodiment of the present disclosure may be a position offset between two corresponding key points in the preview image and the photographed image, and based on the position offset between the two reference points, the first position information of each key point in the preview image after the scaling processing may be offset according to the position offset, so as to obtain fourth position information. Wherein, in the embodiment of the present disclosure, the offset may be determined by a second formula, where the second formula may include: when the aspect ratio of the photographed image is greater than that of the zoomed preview image, it is described that the offset in the length direction needs to be performed, and at this time, offset= (w 2-w1 scale)/2, where offset is the offset, w2 is the length of the photographed image, w1 is the length of the preview image, and scale is the zoom multiple. In addition, when the aspect ratio of the photographed image is smaller than that of the zoomed preview image, it is described that the offset in the width direction needs to be performed, at which time offset= (h 2-h1 scale)/2, where offset is the offset, h2 is the width of the photographed image, h1 is the width of the preview image, scale is the zoom multiple. The first position information offset operation after each scaling process can be executed in the above manner, so that the fourth position information matched with the image parameters of the photographed image is obtained. At this time, each fourth position information may be mapped onto the photographed image, and the display of the virtual effect of the photographed image may be performed.
As shown in fig. 3, after the first position information of the scaling process is obtained, it is determined that the offset in the length direction needs to be performed, where the offset may be (3000-720×3.125)/2=375, the position coordinates of each key point in b may be (3.25×x,3.25×y), and the fourth position information (position coordinates) of the corresponding key point in C obtained after the offset operation is performed may be (3.25×x+375,3.25×y), where the fourth position information of each key point in C is adapted to the parameters of the photographed image.
By the configuration, the matching operation of the first position information of each key point in the preview image and the image parameters of the photographed image can be completed, and the obtained fourth position information is the same as the resolution of the photographed image. In addition, after the fourth position information is obtained, it may be further determined whether the fourth position information can be used to realize a virtual effect of the photographed image.
After the first position information is converted into fourth position information adapted to the photographed image through step S201, a front image of the photographed image may be obtained according to the fourth position information, and second position information of each key point of the front image is determined.
Fig. 4 shows a flowchart of step S202 in an image processing method according to an embodiment of the present disclosure. Wherein the obtaining the front image of the target object in the photographed image and determining the second position information of each key point of the front image according to the fourth position information of each key point adapted to the image parameters of the photographed image (step S202) may include:
s2021: determining an image area of a target object in the photographed image;
s2022: and obtaining a front image of the target object in the photographed image by utilizing the fourth position information of each key point and a standard image in an affine transformation mode, wherein the standard image comprises at least one of a standard face image, a standard gesture image and a standard gesture image.
First, the target object in the embodiment of the present disclosure may be a location object to be displayed with a virtual effect in a captured image, which may include only the location object to be displayed with the virtual effect, or may include all the user objects. The target object may be a face, for example, when performing face thinning, face beautification, and virtual facial feature addition. The image area of the target object determined in step S2021 at this time is a face area in the photographed image. Alternatively, when the virtual effect of the limb portion such as the gesture is performed, the hand region may be set as the target object, and the image region of the target object determined in step S2021 may be the hand region in the photographed image. That is, an image region including a target object may be selected in the embodiments of the present disclosure.
In step S2022, the processing of the target object in the image area described above may be performed in combination with the fourth position information and the standard image, resulting in a front image of the target object. For example, when the target object is a face, since the photographed image may be a side face of the user during photographing, or the user is faced upward or downward, only a part of the photographed image may be the face, or the angle of the face object may be skewed, and the photographed target object may not be a standard front image, and at this time, the front image of the target object in the photographed image may be obtained through affine transformation by combining the fourth position information and the standard face image. Or when the target object is a hand, in the same shooting process, the shot hand may only include a part of hand image, and at this time, the hand image in the shot image may be adjusted to be the front hand image through affine transformation according to the obtained fourth position information and the standard limb image (such as the standard hand image). Wherein the method comprises the steps of
Wherein the embodiment of the present disclosure may obtain the front image of the target object by affine transformation, fig. 5 shows a flowchart of step S2022 in the image processing method according to the embodiment of the present disclosure, wherein the obtaining the front image of the target object of the photographed image by affine transformation using the fourth location information of each key point and the standard image (step S2022) may include:
S20221: comparing the fourth position information of each key point with the standard position information of each key point in the standard image to obtain a correction matrix for adjusting the photographed image, wherein the correction matrix comprises adjustment parameters of the positions of each key point;
s20222: and correcting the target object of the photographed image based on the correction matrix to obtain a front image of the target object of the photographed image.
Wherein a correction matrix can be obtained from the fourth position information and the standard image by means of affine transformation, which correction matrix can be used for generating the front image. For example, when the target object is a face, the fourth position information of each key point may be compared with the standard position information of the key point of the standard face, and for example, a correction matrix may be formed by using a difference between the fourth position information of each key point on the standard face and the coordinate position of the corresponding key point on the standard face image. And correcting the image area of the target object in the photographed image into a front face image by using the correction matrix, and carrying out normalization operation on the face image. The principle of affine transformation the presently disclosed embodiments are not described in detail herein, and a person skilled in the art may derive a correction matrix for obtaining a frontal image by affine transformation according to prior art means.
Fig. 6 illustrates a front-rear comparison diagram in which correction of a face region of a target object is performed according to an embodiment of the present disclosure, wherein as can be seen from fig. 6, the face region in the left image is tilted to the left, and a right-side diagram, which is a front face image corrected based on a face image of the left-side diagram, can be obtained through step S202 of the embodiment of the present disclosure.
After the front image of the normalized target object of the photographed image is obtained, the second location information of each key point in the front image may be identified, for example, by a deep learning algorithm, or may be otherwise performed, for example, by a feature recognition algorithm, or the like. After each second position information is obtained, it may be determined whether each second position information satisfies a preset condition, if so, a virtual effect may be added according to the second position information, and if not, the addition of the virtual effect may be directly performed according to the photographed image.
Fig. 7 illustrates a flowchart of determining whether the second position information satisfies a preset condition according to an embodiment of the present disclosure. Wherein, step S300 may include:
s301: obtaining the confidence of the second position information;
S302: and determining that the second position information meets a preset condition under the condition that the confidence coefficient of the second position information is larger than or equal to the confidence coefficient threshold value.
In the embodiment of the disclosure, the neural network model may be used to determine the second location information of each key point in the front image of the target object in the photographed image, where the neural network model may correspondingly determine the Score (confidence) of each second location information while determining the second location information of each key point in the front image, and further may determine the confidence of each second location information and compare with the confidence threshold. The confidence degree refers to the accuracy of the determination of the second position information by the neural network, and the determination manner of the confidence degree can be implemented by a person skilled in the art according to the prior art, and the embodiment of the disclosure is not specifically limited.
In the embodiment of the disclosure, if the confidence coefficient of the obtained second location information is greater than the confidence coefficient threshold, that is, the confidence coefficient representing the current second location information is high (higher accuracy), the location of the key point is tracked, and it may be determined that the second location information meets the preset condition. Otherwise, if the confidence level of the second position information is less than or equal to the confidence level threshold, step S303 is executed, where when the confidence level of the second position information is less than or equal to the confidence level threshold, the second position information representing the current obtained second position information is inaccurate, and the face region needs to be continuously scratched into the next cycle, and convergence is repeated (i.e. step S202 is repeatedly executed until the second position information with the confidence level higher than the threshold is identified.
Wherein each time S202 is repeatedly performed, the image area of the determined target object is different, for example, the range of the selected image area is enlarged, and the like.
Through the configuration of the embodiment of the disclosure, whether the second position information meets the preset condition can be judged according to whether the second position information which is larger than the confidence coefficient threshold value can be determined in the front image, if the confidence coefficient of the second position information is larger than or equal to the confidence coefficient threshold value, the second position information meets the preset condition, and if the confidence coefficient of the second position information is still smaller than the confidence coefficient threshold value when the number of times of repetition reaches the threshold value, the second position information does not meet the preset condition.
When the second position information meets the preset condition, a virtual effect can be added in the photographed image according to the second position information meeting the preset condition, and if the second position information does not meet the preset condition, a virtual effect is added in the photographed image according to the third position information identified by the photographed image.
Wherein fig. 8 shows a flowchart of adding a virtual effect according to second position information in step S300 in an image processing method according to an embodiment of the present disclosure. In step 300, adding a virtual feature according to the second position information of each key point includes:
S304: if the second position information meets the preset condition, determining fifth position information corresponding to the second position information in the photographed image according to the correction matrix;
s305: and adding virtual features according to the fifth position information.
Since in the embodiment shown in fig. 6, the determined second position information is the key point of the front image of the target object in the photographed image, it is necessary to convert the key point of the front image into the key point of the target object in the photographed image. Wherein, fifth position information corresponding to the second position information may be obtained according to the correction matrix inversion operation determined in step S20221, and further, a virtual effect may be added according to the position of the fifth position information.
Wherein, the virtual features to be added can realize any AR effect, such as wearing caps, glasses, red lips, glasses magnification, facial deformation, and the like. The user may select an AR effect that is desired to be added, which is not limited by the embodiments of the present disclosure. The embodiment of the disclosure can also determine the virtual feature to be added based on the received selection information, so as to add the virtual feature according to the position of the second position information or add the virtual feature according to the position of the third position information.
When the second position information does not meet the preset condition, a neural network model can be utilized to identify third position information of each key point in the photographed image, and the addition of virtual features in the photographed image is realized according to the third position information, wherein the neural network model comprises a deep learning neural network model.
The identification of the key points of each image in the embodiment of the disclosure can be performed according to the deep learning neural network model, and has the characteristic of high precision. But the embodiments of the present disclosure are not limited thereto.
In addition, in the embodiment of the present disclosure, the facial feature information of the photographed person may be saved and assigned a unique identification, for example, the facial feature information may include second position information satisfying a preset condition, or third position information of the person object in the photographed image. If the photographed image includes a plurality of person objects, that is, a plurality of faces, the recognized faces may be identified according to second position information satisfying a preset condition or the photographed image, that is, a preset Identification (ID) is allocated to the recognized faces, so as to distinguish each person, and each facial feature information is stored accordingly.
In the subsequent photographing process, whether the person object included in the photographed image has the recognized person or not can be recognized first, and if the person object has the recognized person, the virtual feature is added directly according to the corresponding position information, so that the adding effect of the virtual feature corresponding to the same person is ensured.
The embodiment of the disclosure can realize the tracking of the preview image, and the addition of the virtual characteristics of the photographed image can be realized by combining the tracking result of the preview image, so that the virtual effect can be accurately realized. The method comprises the steps that first, second position information of each key point in a front image corresponding to a photographed image can be obtained according to image parameters of the photographed image on position information of each key point in a preview image, when the second position information can be used for executing key positioning, namely preset conditions are met, virtual effects can be achieved in the photographed image according to the second position information determined by tracking of the preview image, if the second position information does not meet the preset conditions, third position information of each key point in the photographed image can be directly identified, and virtual effects can be achieved according to the third position information. According to the embodiment of the disclosure, accurate correspondence of added virtual features can be ensured, and even under the condition that the features in a photographed image cannot be accurately identified due to movement of a photographed object in the moment of photographing and corresponding virtual effects cannot be accurately added in the prior art, key points can be tracked and positioned through a preview image, so that positions of the key points can be accurately tracked and identified, and the probability that virtual effects cannot be effectively added or virtual effects cannot be added is reduced.
It will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
In addition, the disclosure further provides an image processing apparatus, an electronic device, a computer readable storage medium, and a program, where the foregoing may be used to implement any one of the image processing methods provided in the disclosure, and corresponding technical schemes and descriptions and corresponding descriptions referring to method parts are not repeated.
Fig. 9 shows a block diagram of an image processing apparatus according to an embodiment of the present disclosure, as shown in fig. 9, including:
the acquiring module 10 is configured to acquire, when a photographing instruction is received, first position information of each key point in the preview image and a photographed image;
a determining module 20, configured to obtain a front image of a target object in the photographed image using the first location information of each key point, and determine second location information of each key point of the front image;
and a virtual module 30, configured to determine whether the second position information meets a preset condition, if so, add a virtual effect according to a position in the photographed image corresponding to the second position information meeting the preset condition, and otherwise add a virtual effect according to third position information of each key point identified from the photographed image.
In one possible implementation, the determining module includes:
the conversion unit is used for converting the first position information of each key point into fourth position information which is matched with the image parameters of the photographed image according to the image parameters of the photographed image; and
and the key point determining unit is used for obtaining a front image of a target object in the photographed image according to the fourth position information of each key point matched with the image parameters of the photographed image and determining second position information of each key point of the front image.
In a possible implementation manner, the conversion unit is further configured to perform the conversion of the first location information of each key point into fourth location information adapted to the image parameters of the photographed image according to at least one of the following manners:
scaling the first position information of each key point in the preview image according to the resolution of the photographed image to obtain each fourth position information;
performing offset processing on the first position information of each key point in the preview image according to the offset between the corresponding key points in the photographed image and the preview image to obtain each fourth position information;
And scaling the first position information of each key point in the preview image according to the resolution of the photographed image, and performing offset processing on the first position information of each key point after scaling based on the offset between the first position information of the key point after scaling and the position information of the corresponding key point on the photographed image to obtain the fourth position information.
In a possible implementation manner, the keypoint determining unit is further configured to determine an image area of the target object in the photographed image, and obtain, by using the fourth location information of each keypoint and a standard image, a front image of the target object in the photographed image by affine transformation, where the standard image includes at least one of a standard face image, a standard limb image, and a standard pose image.
In a possible implementation manner, the key point determining unit is further configured to compare the fourth location information of each key point with the standard location information of each key point in the standard image, so as to obtain a correction matrix for adjusting the photographed image, where the correction matrix includes adjustment parameters for positions of each key point; and
And correcting the target object of the photographed image based on the correction matrix to obtain a front image of the target object of the photographed image.
In a possible implementation manner, the virtual module is further configured to determine, according to the correction matrix, fifth location information corresponding to the second location information in the photographed image, where the second location information meets a preset condition; and adding virtual features according to the fifth position information of each key point.
In a possible implementation manner, the virtual module is further configured to obtain a confidence level of the second location information, and determine that the second location information meets a preset condition when the confidence level of the second location information is greater than or equal to the confidence level threshold.
In a possible implementation manner, the virtual module is further configured to repeatedly execute the fourth location information of each key point adapted to the image parameter of the photographed image, obtain a front image of the target object in the photographed image, and identify second location information of each key point of the front image, where the confidence level of the second location information is less than the confidence level threshold;
When the number of times of repeated execution reaches a number of times threshold, determining that the second position information does not meet a preset condition when the determined confidence level of the second position information is still smaller than the confidence level threshold, and determining that the second position information with the confidence level greater than or equal to the confidence level threshold meets the preset condition when the obtained confidence level of the second position information is greater than or equal to the confidence level threshold in the repeated execution process.
In one possible embodiment, the apparatus further comprises:
a receiving module for receiving selection information;
the virtual module is further configured to determine a virtual feature to be added based on the received selection information, so as to add the virtual feature according to the second location information, or add the virtual feature according to the third location information.
In one possible implementation manner, the obtaining module is further configured to obtain, using the neural network model, first location information of each key point in the preview image, and third location information of each key point in the photographed image.
In some embodiments, a function or a module included in an apparatus provided by the embodiments of the present disclosure may be used to perform a method described in the foregoing method embodiments, and a specific implementation thereof may refer to the description of the foregoing method embodiments, which is not repeated herein for brevity
The disclosed embodiments also provide a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the above-described method. The computer readable storage medium may be a non-volatile computer readable storage medium.
The embodiment of the disclosure also provides an electronic device, which comprises: a processor; a memory for storing processor-executable instructions; wherein the processor is configured as the method described above.
The electronic device may be provided as a terminal, server or other form of device.
Fig. 10 shows a block diagram of an electronic device 800, according to an embodiment of the disclosure. For example, electronic device 800 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to fig. 10, an electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen between the electronic device 800 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. When the electronic device 800 is in an operational mode, such as a shooting mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 further includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the electronic device 800. For example, the sensor assembly 814 may detect an on/off state of the electronic device 800, a relative positioning of the components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in position of the electronic device 800 or a component of the electronic device 800, the presence or absence of a user's contact with the electronic device 800, an orientation or acceleration/deceleration of the electronic device 800, and a change in temperature of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices, either wired or wireless. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 804 including computer program instructions executable by processor 820 of electronic device 800 to perform the above-described methods.
Fig. 11 shows a block diagram of an electronic device 1900 according to an embodiment of the disclosure. For example, electronic device 1900 may be provided as a server. Referring to FIG. 11, electronic device 1900 includes a processing component 1922 that further includes one or more processors and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by processing component 1922. The application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions. Further, processing component 1922 is configured to execute instructions to perform the methods described above.
The electronic device 1900 may also include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input/output (I/O) interface 1958. The electronic device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, or the like.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 1932, including computer program instructions executable by processing component 1922 of electronic device 1900 to perform the methods described above.
The present disclosure may be a system, method, and/or computer program product. The computer program product may include a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement aspects of the present disclosure.
The computer readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: portable computer disks, hard disks, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static Random Access Memory (SRAM), portable compact disk read-only memory (CD-ROM), digital Versatile Disks (DVD), memory sticks, floppy disks, mechanical coding devices, punch cards or in-groove structures such as punch cards or grooves having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media, as used herein, are not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., optical pulses through fiber optic cables), or electrical signals transmitted through wires.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
Computer program instructions for performing the operations of the present disclosure can be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, c++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present disclosure are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information of computer readable program instructions, which can execute the computer readable program instructions.
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts 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 disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). 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 foregoing description of the embodiments of the present disclosure has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the technical improvement of the technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (20)

1. An image processing method, comprising:
under the condition of receiving a photographing instruction, acquiring first position information of each key point in the preview image and a photographing image;
acquiring a front image of a target object in the photographed image by using the first position information of each key point, and determining the second position information of each key point of the front image;
determining whether the second position information meets a preset condition, if so, adding a virtual effect according to the position corresponding to the second position information meeting the preset condition in the photographed image, otherwise, adding the virtual effect according to the third position information of each key point identified in the photographed image;
The adding the virtual effect according to the position corresponding to the second position information meeting the preset condition in the photographed image comprises the following steps:
if the second position information meets the preset condition, determining fifth position information corresponding to the second position information in the photographed image according to a correction matrix, wherein the correction matrix is obtained according to fourth position information and a standard image, and the fourth position information is obtained through matching operation of the first position information of each key point and image parameters of the photographed image;
and adding virtual features according to the fifth position information of each key point.
2. The method of claim 1, wherein obtaining a front image of the target object in the photographed image using the first location information of each key point, and determining the second location information of each key point of the front image, comprises:
according to the image parameters of the photographed image, converting the first position information of each key point into fourth position information which is adaptive to the image parameters of the photographed image;
and obtaining a front image of the target object in the photographed image according to the fourth position information of each key point matched with the image parameters of the photographed image, and determining second position information of each key point of the front image.
3. The method according to claim 2, wherein the converting the first location information of each key point into fourth location information adapted to the image parameters of the photographed image according to the image parameters of the photographed image includes at least one of the following ways:
scaling the first position information of each key point in the preview image according to the resolution of the photographed image to obtain each fourth position information;
performing offset processing on the first position information of each key point in the preview image according to the offset between the corresponding key points in the photographed image and the preview image to obtain each fourth position information;
and scaling the first position information of each key point in the preview image according to the resolution of the photographed image, and performing offset processing on the first position information of each key point after scaling based on the offset between the first position information of the key point after scaling and the position information of the corresponding key point on the photographed image to obtain the fourth position information.
4. A method according to claim 2 or 3, wherein said obtaining a front image of a target object in the photographed image based on the fourth location information of each key point adapted to the image parameters of the photographed image comprises:
Determining an image area of a target object in the photographed image;
and obtaining a front image of the target object of the photographed image by affine transformation by using the fourth position information of each key point and a standard image, wherein the standard image comprises at least one of a standard face image, a standard limb image and a standard posture image.
5. The method according to claim 4, wherein obtaining the front image of the target object of the photographed image by affine transformation using the fourth location information of each key point and a standard image includes:
comparing the fourth position information of each key point with the standard position information of each key point in the standard image to obtain a correction matrix for adjusting the photographed image, wherein the correction matrix comprises adjustment parameters of the positions of each key point;
and correcting the target object of the photographed image based on the correction matrix to obtain a front image of the target object of the photographed image.
6. A method according to claim 2 or 3, wherein said determining whether the second position information meets a preset condition comprises:
Obtaining the confidence of the second position information;
and determining that the second position information meets a preset condition under the condition that the confidence coefficient of the second position information is larger than or equal to the confidence coefficient threshold value.
7. The method of claim 6, wherein the determining whether the second location information satisfies a preset condition further comprises:
repeatedly executing the fourth position information of each key point adapted to the image parameters of the photographed image under the condition that the confidence coefficient of the second position information is smaller than the confidence coefficient threshold value, obtaining a front image of a target object in the photographed image and identifying the second position information of each key point of the front image;
and if the number of times of repeated execution reaches the number of times threshold, determining that the confidence coefficient of the determined second position information is still smaller than the confidence coefficient threshold, determining that the second position information does not meet the preset condition, and determining that the confidence coefficient of the obtained second position information is larger than or equal to the confidence coefficient threshold in the repeated execution process, and determining that the second position information with the confidence coefficient larger than or equal to the confidence coefficient threshold meets the preset condition.
8. A method according to any one of claims 1-3, characterized in that the method further comprises:
and determining the virtual feature to be added based on the received selection information so as to add the virtual feature according to the second position information or add the virtual feature according to the third position information.
9. A method according to any one of claims 1-3, characterized in that the method further comprises:
and acquiring first position information of each key point in the preview image and third position information of each key point in the photographed image by using the neural network model.
10. An image processing apparatus, comprising:
the acquisition module is used for acquiring the first position information of each key point in the preview image and the photographed image under the condition of receiving the photographing instruction;
the determining module is used for obtaining a front image of the target object in the photographed image by using the first position information of each key point and determining the second position information of each key point of the front image;
the virtual module is used for determining whether the second position information meets preset conditions, if so, adding a virtual effect according to the position corresponding to the second position information meeting the preset conditions in the photographed image, otherwise, adding the virtual effect according to third position information of each key point identified in the photographed image;
The virtual module is further configured to determine, when the second position information meets a preset condition, fifth position information corresponding to the second position information in the photographed image according to a correction matrix, where the correction matrix is obtained according to fourth position information and a standard image, and the fourth position information is obtained through a matching operation of the first position information of each key point and image parameters of the photographed image; and adding virtual features according to the fifth position information of each key point.
11. The apparatus of claim 10, wherein the determining module comprises:
the conversion unit is used for converting the first position information of each key point into fourth position information which is matched with the image parameters of the photographed image according to the image parameters of the photographed image; and
and the key point determining unit is used for obtaining a front image of a target object in the photographed image according to the fourth position information of each key point matched with the image parameters of the photographed image and determining second position information of each key point of the front image.
12. The apparatus according to claim 11, wherein the converting unit is further configured to perform the conversion of the first position information of each key point into fourth position information adapted to the image parameters of the photographed image according to at least one of:
Scaling the first position information of each key point in the preview image according to the resolution of the photographed image to obtain each fourth position information;
performing offset processing on the first position information of each key point in the preview image according to the offset between the corresponding key points in the photographed image and the preview image to obtain each fourth position information;
and scaling the first position information of each key point in the preview image according to the resolution of the photographed image, and performing offset processing on the first position information of each key point after scaling based on the offset between the first position information of the key point after scaling and the position information of the corresponding key point on the photographed image to obtain the fourth position information.
13. The apparatus according to claim 11 or 12, wherein the key point determination unit is further configured to determine an image area of the target object in the photographed image, and obtain a front image of the target object of the photographed image by affine transformation using the fourth position information of each key point and a standard image including at least one of a standard face image, a standard limb image, and a standard pose image.
14. The apparatus according to claim 13, wherein the key point determining unit is further configured to compare the fourth location information of each key point with standard location information of each key point in a standard image, to obtain a correction matrix for adjusting the photographed image, where the correction matrix includes adjustment parameters for positions of each key point; and
and correcting the target object of the photographed image based on the correction matrix to obtain a front image of the target object of the photographed image.
15. The apparatus according to claim 11 or 12, wherein the virtual module is further configured to obtain a confidence level of the second location information, and determine that the second location information meets a preset condition if the confidence level of the second location information is greater than or equal to the confidence threshold.
16. The apparatus according to claim 15, wherein the virtual module is further configured to repeatedly perform the fourth location information according to each key point adapted to the image parameter of the photographed image, obtain a front image of the target object in the photographed image, and identify second location information of each key point of the front image, if the confidence of the second location information is smaller than the confidence threshold;
When the number of times of repeated execution reaches a number of times threshold, determining that the second position information does not meet a preset condition when the determined confidence level of the second position information is still smaller than the confidence level threshold, and determining that the second position information with the confidence level greater than or equal to the confidence level threshold meets the preset condition when the obtained confidence level of the second position information is greater than or equal to the confidence level threshold in the repeated execution process.
17. The apparatus according to any one of claims 10-12, wherein the apparatus further comprises:
a receiving module for receiving selection information;
the virtual module is further configured to determine a virtual feature to be added based on the received selection information, so as to add the virtual feature according to the second location information, or add the virtual feature according to the third location information.
18. The apparatus of any of claims 10-12, wherein the obtaining module is further configured to obtain first location information for each keypoint in the preview image and third location information for each keypoint in the photographed image using the neural network model.
19. An electronic device, comprising:
A processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to: performing the method of any one of claims 1 to 9.
20. A computer readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the method of any of claims 1 to 9.
CN201811278366.XA 2018-10-30 2018-10-30 Image processing method and device, electronic equipment and storage medium Active CN109325908B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811278366.XA CN109325908B (en) 2018-10-30 2018-10-30 Image processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811278366.XA CN109325908B (en) 2018-10-30 2018-10-30 Image processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109325908A CN109325908A (en) 2019-02-12
CN109325908B true CN109325908B (en) 2023-07-21

Family

ID=65259769

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811278366.XA Active CN109325908B (en) 2018-10-30 2018-10-30 Image processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109325908B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110610178A (en) * 2019-10-09 2019-12-24 Oppo广东移动通信有限公司 Image recognition method, device, terminal and computer readable storage medium
CN110717452B (en) * 2019-10-09 2022-04-19 Oppo广东移动通信有限公司 Image recognition method, device, terminal and computer readable storage medium
CN112532875B (en) * 2020-11-24 2022-08-19 展讯通信(上海)有限公司 Terminal device, image processing method and device thereof, and storage medium
CN112530019B (en) * 2020-12-11 2023-03-14 中国科学院深圳先进技术研究院 Three-dimensional human body reconstruction method and device, computer equipment and storage medium
CN113096152B (en) * 2021-04-29 2022-04-01 北京百度网讯科技有限公司 Multi-object motion analysis method, device, equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104537630A (en) * 2015-01-22 2015-04-22 厦门美图之家科技有限公司 Method and device for image beautifying based on age estimation
CN106612396A (en) * 2016-11-15 2017-05-03 努比亚技术有限公司 Photographing device, photographing terminal and photographing method
CN107958439A (en) * 2017-11-09 2018-04-24 北京小米移动软件有限公司 Image processing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105120144A (en) * 2015-07-31 2015-12-02 小米科技有限责任公司 Image shooting method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104537630A (en) * 2015-01-22 2015-04-22 厦门美图之家科技有限公司 Method and device for image beautifying based on age estimation
CN106612396A (en) * 2016-11-15 2017-05-03 努比亚技术有限公司 Photographing device, photographing terminal and photographing method
CN107958439A (en) * 2017-11-09 2018-04-24 北京小米移动软件有限公司 Image processing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《基于Android系统的相机特效软件的设计与实现》;祁鹏;《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑(月刊)2018年第04期》;20180415;全文 *

Also Published As

Publication number Publication date
CN109325908A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
CN110084775B (en) Image processing method and device, electronic equipment and storage medium
CN109325908B (en) Image processing method and device, electronic equipment and storage medium
CN109784255B (en) Neural network training method and device and recognition method and device
CN109087238B (en) Image processing method and apparatus, electronic device, and computer-readable storage medium
CN107680033B (en) Picture processing method and device
CN108470322B (en) Method and device for processing face image and readable storage medium
CN111553864B (en) Image restoration method and device, electronic equipment and storage medium
CN107944367B (en) Face key point detection method and device
CN109840939B (en) Three-dimensional reconstruction method, three-dimensional reconstruction device, electronic equipment and storage medium
JP2016531361A (en) Image division method, image division apparatus, image division device, program, and recording medium
EP3575862A1 (en) Method and device for adjusting lens position
CN107341777B (en) Picture processing method and device
US11308692B2 (en) Method and device for processing image, and storage medium
CN111243011A (en) Key point detection method and device, electronic equipment and storage medium
CN107967459B (en) Convolution processing method, convolution processing device and storage medium
CN112767288A (en) Image processing method and device, electronic equipment and storage medium
CN107239758B (en) Method and device for positioning key points of human face
US9665925B2 (en) Method and terminal device for retargeting images
CN110826463B (en) Face recognition method and device, electronic equipment and storage medium
US11252341B2 (en) Method and device for shooting image, and storage medium
CN113315904B (en) Shooting method, shooting device and storage medium
CN115601316A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN114666490B (en) Focusing method, focusing device, electronic equipment and storage medium
CN114550261A (en) Face recognition method and device, electronic equipment and storage medium
CN114445298A (en) Image processing method and device, electronic equipment and storage medium

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