Snapchat Filter challenge

I am not able to figure out how to overlay the png image (mustache and glasses) on the face image. Could you guide me towards the particular method that I am supposed to use ? I understand that I will have to resize the image, but how do I overlay it as a png image (i.e. an image with transparent background)

Hey @mohitb, I hope this will help.

When your read glasses image using this statement

img=cv2.imread(“Train/glasses.png”,cv2.IMREAD_UNCHANGED))
print(img.shape)

You will notice that img has 4 channels and not 3. These channels are bgra. Where ‘a’ channel stores the opacity of channel. It will be greater than 0 if there is some opacity otherwise zero.

Next step is to resize this image, to the one having same width and height to that of nose/eyes detected.

Than you need to iterate on every pixels value on actual image from x to x+w and from y to y+h. And replace the pixel values to that of moustache/glasses image if ‘a’ channel value i.e. opacity value is greater than 0.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts :blush: