This project involves the use of image processing techniques to embed any mask on the face. I have created this project specially for the Halloween theme, but the code could be used for multiple themes as well.
I did not want to use any materials to celebrate my Halloween and do it for 0$. So i came up with this idea of developing a Halloween project using a few image processing techniques I've learnt over the past couple of years.
It first starts with selecting the character you want to become on Halloween for me it was V (from the movie V for vendetta), so I downloaded an image of the mask from google images and this is how i got started.
Second step involves face recognition. Well you want the mask to blend over your face properly. So first we use a face recognition algorithm using Haar-cascade technique. You can create your own training data set if you want to for face recognition. So after your face is detected you have the coordinates of your face saved.
Third step involves selecting a spooky background of your choice. Using weighted addition technique, the background blends over your entire image creating a Halloween background environment.
Since, the mask (step 1) that you choose can be of different sizes, It is important to resize it with the size of your detected face. So resize the mask to the size of your detected face. After resizing, you need to replace your face by the mask. But replacing the mask is not exactly the desired result, we need to blend the mask on the face. So we use a technique of padding. The reason behind using padding is that, we create a separate image, of the same size as that of the frame captured by camera and blend the padded image to the spooky background image. Since the position of the face is known, we just need to add zeros' to the mask and resize it to the same size as that of captured image from camera.
This is the final step of the project. Where the padded image needs to be added with the spooky background image in step 3. The addition uses the concept of added weights again so it is up to the user the ratio in which he wants to add both the images.The user has the opportunity to choose which ever mask or background he wants. I have tried with different backgrounds and a couple of masks and all of them worked for me.
Finally, I would indeed be grateful if the readers could suggest their esteemed feedback so that improvements could be done.
HAPPY HALLOWEEN !!
Comments