Snap filter doubt

How should I place the moustache on the face?

Hey @debjanihome, first of all when you load the nose haarcascade file and than run it to identify the nose, you can x,y,w,h. Now to place the moustache there, keep this things in mind.

Load the moustache image using,
img = plt.imread(’./Train/mustache.png’)
print(img.shape)
You will notice that img has 4 channels and not 3. These channels are rgba. 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 as that of nose file and keeping the height to width ratio same.

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

Hope this cleared your doubt. :blush:

1 Like

can you explain this coordinate? y+h-heightofmoustache
the moustache would be inside the nose box?