Method and electronic device for adding virtual item
Abstract
A method for adding a virtual item can include: acquiring classification identifiers of a plurality of pixel points in a target human face image, wherein the classification identifier comprises a first identifier of pixel points in a first human face part or a second identifier of pixel points in a second human face part; determining a target region in the target human face image based on the classification identifiers, wherein the target region is a region belonging to the first human face part; adding a virtual item to the target region; wherein the first human face part comprises an uncovered human face part, and the second human face part comprises a covered human face part or a non-human face part.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method for adding a virtual item, comprising:
acquiring classification identifiers of a plurality of pixel points in a target human face image, wherein the classification identifiers comprise a first identifier of pixel points in a first human face part or a second identifier of pixel points in a second human face part, the first human face part comprising an uncovered human face part, and the second human face part comprising a covered human face part or a non-human face part; determining a target region in the target human face image based on the classification identifiers, wherein the target region comprises the pixel points corresponding to the first identifier, and does not comprise the pixel points corresponding to the second identifier; and adding a virtual item to the target region.
2 . The method according to claim 1 , wherein acquiring the classification identifiers of the plurality of pixel points in the target human face image comprises:
acquiring features of the target human face image by extracting the features from the target human face image based on a pixel classification model; and determining the classification identifiers of the plurality of pixel points in the target human face image based on the features of the target human face image.
3 . The method according to claim 1 , wherein determining the target region in the target human face image comprises:
acquiring a first reference image based on the classification identifiers, wherein pixel values of pixel points in the first reference image are determined by the classification identifiers; determining a reference region in the first reference image, wherein the reference region comprises pixel points with the first identifier; and determining the target region according to the reference region in the target human face image.
4 . The method according to claim 1 , wherein determining the target region in the target human face image comprises:
acquiring a first reference image based on the classification identifiers, wherein pixel values of pixel points in the first reference image are determined by the classification identifiers; acquiring a second reference image by smoothing the first reference image; determining a reference region in the second reference image, wherein the reference region comprises pixel points with the first identifier; and determining the target region according to the reference region in the target human face image.
5 . The method according to claim 1 , wherein acquiring the classification identifiers of the plurality of pixel points in the target human face image comprises:
detecting key pixel points belonging to a human face part in the target human face image; determining a first human face image, wherein the first human face image comprises a region composed by the key pixel points; and determining classification identifiers of pixel points in the first human face image.
6 . The method according to claim 5 , wherein determining the first human face image comprises:
acquiring edge pixel points of the key pixel points in response to the key pixel points being located within a region of the human face part, wherein the edge pixel points are located on a contour of the human face part; and determining the first human face image comprising the region connected by the edge pixel points.
7 . The method according to claim 5 , wherein determining the target region in the target human face image comprises:
acquiring a third reference image based on the classification identifiers of the pixel points in the first human face image, wherein pixel values of pixel points in the third reference image are determined based on the classification identifiers of the pixel points in the first human face image; acquiring a fourth reference image by adding reference pixel points to outer side of the third reference image, wherein pixel values of the reference pixel points are related to the second identifier, the fourth reference image and the target human face image have same sizes, and a location of each pixel point of the third reference image in the fourth reference image is same as a location of a corresponding pixel point of the first human face image in the target human face image; determining a reference region in the fourth reference image; and determining, in the target human face image, a target region corresponding to the reference region, wherein the reference region comprises pixel points with pixel values being related to the first identifier in the fourth reference image.
8 . The method according to claim 5 , wherein determining the target region in the target human face image comprises:
acquiring a third reference image based on the classification identifiers of the pixel points in the first human face image, wherein pixel values of pixel points in the third reference image are determined based on the classification identifiers of the pixel points in the first human face image; acquiring a fifth reference image by smoothing the third reference image; acquiring a sixth reference image by adding reference pixel points to outer side of the fifth reference image, wherein pixel values of the reference pixel points are related to the second identifier, the sixth reference image and the target human face image have same sizes, and a location of each pixel point of the fifth reference image in the sixth reference image is same as a location of a corresponding pixel point of the first human face image in the target human face image; determining a reference region in the sixth reference image; and determining, in the target human face image, a target region corresponding to the reference region, wherein the reference region comprises pixel points with pixel values being related to the first identifier in the sixth reference image.
9 . The method according to claim 1 , wherein adding the virtual item to the target region comprises:
acquiring a reference image, wherein pixel values of pixel points in the reference image are determined by the classification identifiers; acquiring a first matrix, a second matrix, a third matrix and a fourth matrix, wherein:
elements of the first matrix are equal to pixel values of pixel points with the same position in the target human face image;
the second matrix is a same size as the first matrix, and all elements of the second matrix are equal to 1;
elements of the third matrix are equal to pixel values of pixel points with the same position in the reference image; and
elements of the fourth matrix are equal to pixel values of pixel points with the same position in the virtual item;
acquiring a fifth matrix based on: (i) the first matrix, the second matrix, the third matrix and the fourth matrix, and (ii) z=x*(a-mask)+y*mask, wherein the z is the fifth matrix, the x is the first matrix, the a is the second matrix, the y is the third matrix, and the mask is the fourth matrix; and generating, based on the fifth matrix, the target human face image added with the virtual item, wherein pixel values of pixel points in each location of the target human face image are equal to elements in a same location of the fifth matrix.
10 . An electronic device for adding a virtual item, comprising:
at least one processor; and a volatile or non-volatile memory configured to store at least one program comprising at least one instruction executable by the at least one processor; wherein the at least one instruction, when executed by the at least one processor, causes the at least one processor to perform a method comprising: acquiring classification identifiers of a plurality of pixel points in a target human face image, wherein the classification identifiers comprise a first identifier of pixel points in a first human face part or a second identifier of pixel points in a second human face part, the first human face part comprises an uncovered human face part, and the second human face part comprises a covered human face part or a non-human face part; determining a target region in the target human face image based on the classification identifiers, wherein the target region comprises the pixel points corresponding to the first identifier, and does not comprise the pixel points corresponding to the second identifier; and adding a virtual item to the target region.
11 . The electronic device according to claim 10 , wherein acquiring the classification identifiers of the plurality of pixel points in the target human face image comprises:
acquiring features of the target human face image by extracting the features from the target human face image based on a pixel classification model; and determining the classification identifiers of the plurality of pixel points in the target human face image based on the features of the target human face image.
12 . The electronic device according to claim 10 , wherein determining the target region in the target human face image comprises:
acquiring a first reference image based on the classification identifiers, wherein pixel values of pixel points in the first reference image are determined by the classification identifiers; determining a reference region in the first reference image, wherein the reference region comprises pixel points with the first identifier; and determining the target region according to the reference region in the target human face image.
13 . The electronic device according to claim 10 , wherein determining the target region in the target human face image comprises:
acquiring a first reference image based on the classification identifiers, wherein pixel values of pixel points in the first reference image are determined by the classification identifiers; acquiring a second reference image by smoothing the first reference image; determining a reference region in the second reference image, wherein the reference region comprises pixel points with the first identifier; and determining the target region according to the reference region in the target human face image.
14 . The electronic device according to claim 10 , wherein acquiring the classification identifiers of the plurality of pixel points in the target human face image comprises:
detecting key pixel points belonging to a human face part in the target human face image; determining a first human face image, wherein the first human face image comprises a region composed by the key pixel points; and determining classification identifiers of pixel points in the first human face image.
15 . The electronic device according to claim 14 , wherein determining the first human face image comprises:
acquiring edge pixel points of the key pixel points in response to the key pixel points being located within a region of the human face part, wherein the edge pixel points are located on a contour of the human face part; and determining the first human face image comprising the region connected by the edge pixel points.
16 . The electronic device according to claim 14 , wherein determining the target region in the target human face image comprises:
acquiring a third reference image based on the classification identifiers of the pixel points in the first human face image, wherein pixel values of pixel points in the third reference image are determined based on the classification identifiers of the pixel points in the first human face image; acquiring a fourth reference image by adding reference pixel points to outer side of the third reference image, wherein pixel values of the reference pixel points are related to the second identifier, the fourth reference image and the target human face image have same sizes, and a location of each pixel point of the third reference image in the fourth reference image is same as a location of a corresponding pixel point of the first human face image in the target human face image; determining a reference region in the fourth reference image; and determining, in the target human face image, a target region corresponding to the reference region, wherein the reference region comprises pixel points with pixel values being related to the first identifier in the fourth reference image.
17 . The electronic device according to claim 14 , wherein determining the target region in the target human face image comprises:
acquiring a third reference image based on the classification identifiers of the pixel points in the first human face image, wherein pixel values of pixel points in the third reference image are determined based on the classification identifiers of the pixel points in the first human face image; acquiring a fifth reference image by smoothing the third reference image; acquiring a sixth reference image by adding reference pixel points to outer side of the fifth reference image, wherein pixel values of the reference pixel points are related to the second identifier, the sixth reference image and the target human face image have same sizes, and a location of each pixel point of the fifth reference image in the sixth reference image is same as a location of a corresponding pixel point of the first human face image in the target human face image; determining a reference region in the sixth reference image; and determining, in the target human face image, a target region corresponding to the reference region, wherein the reference region comprises pixel points with pixel values being related to the first identifier in the sixth reference image.
18 . The electronic device according to claim 10 , wherein adding the virtual item to the target region comprises:
acquiring a reference image, wherein pixel values of pixel points in the reference image are determined by the classification identifiers; acquiring a first matrix, a second matrix, a third matrix and a fourth matrix, wherein:
elements of the first matrix are equal to pixel values of pixel points with the same position in the target human face image;
the second matrix is the same size as the first matrix, and all elements of the second matrix are equal to 1;
elements of the third matrix are equal to pixel values of pixel points with the same position in the reference image; and
elements of the fourth matrix are equal to pixel values of pixel points with the same position in the virtual item;
acquiring a fifth matrix based on: (i) the first matrix, the second matrix, the third matrix and the fourth matrix, and (ii) z=x*(a-mask)+y*mask, wherein the z is the fifth matrix, the x is the first matrix, the a is the second matrix, the y is the third matrix, and the mask is the fourth matrix; and generating, based on the fifth matrix, the target human face image added with the virtual item, wherein pixel values of pixel points in each location of the target human face image are equal to elements in a same location of the fifth matrix.
19 . A non-transitory computer-readable storage medium storing at least one program comprising at least one instruction therein, wherein the at least one instruction, when executed by a processor of an electronic device, causes the electronic device to perform a method comprising:
acquiring classification identifiers of a plurality of pixel points in a target human face image, wherein the classification identifiers comprise a first identifier of pixel points in a first human face part or a second identifier of pixel points in a second human face part, the first human face part comprises an uncovered human face part, and the second human face part comprises a covered human face part or a non-human face part; determining a target region in the target human face image based on the classification identifiers, wherein the target region comprises the pixel points corresponding to the first identifier, and does not comprise the pixel points corresponding to the second identifier; and adding a virtual item to the target region.
20 . The method according to claim 1 , wherein before adding the virtual item to the target region, the method further comprises:
adjusting a size of the virtual item according to a size of the target human face image, such that the virtual item and the target human face image have the same size.Join the waitlist — get patent alerts
Track US2023076109A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.