Regarding snapchat filter challenge

When I read this glasses image using cv2.imread() method, it shows a whole black image.

How do I know which part of this image should be transparent when I assign this glasses to the detected eye part?

When I try to assign this image to detected part of eye by using following command:

before[ey-26:ey+eh+25, ex-56:ex+ew+56,:] = glasses
, then whole eye_detected rectangle becomes black.

Here I’ve attached my code and output image. And image in the right side is the real image that is opened in image viewer.

Hi @harshsharmajnv_9b70d236614796d5
Transparent PNG images have 4 channels; 3 for Red, Green and Blue (RGB) and one for Alpha. It turns out, when Opencv reads the transparent PNG images, it discards the ‘alpha’ channel or the information about transparency. It just renders the images as it is present in the RGB channels. So while working with the glasses.png file you need to take in consideraion the 4th (alpha) channel of the image
Here is the code that might help you,

Hope this might helps :slight_smile:

1 Like

Thanks a lot sir :pray:. This is really helpful.
I’m very happy to get my doubts clear with best solutions everytime I ask any doubt here.

Great to hear that :slight_smile:
@harshsharmajnv_9b70d236614796d5 If you face any issue you can reopen it any time you want for now I am closing this doubt

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.