"Hair" is a GUI application where you can experiment with different hair styles real time. It is made using open-cv and tkinter.
To use this GUI, start by running gui.py
. You will see a starting screen that looks like this:
Next, click "start" and it will take you to a page where you can click on multiple buttons, each representing a certain hair style.
Fade
Mushroom cut
Bangs
Anime
Afro
Once you click on a button, the camera will start and you'll get another window where you should see the hair style you selected in real time. If another person is next to you, you should see them with the hair style as well. Press esc to close this window.
(If you don't see the hair style, make sure your at least 2 feet from the device and be sure your lighting is decent)
The GUI itself is pretty straightforward. In gui.py
there is simply an image placed in the background and another image that i've made into a button. When you click this button, it goes to the next file functionality.py
through an import import functionality
. In functionality.py
there are just a couple more buttons which are binded to the function cam(hair)
which essentially imports video.py
and calls the specific hair style selected.
Most of the magic happens in video.py
.
Basically, you open the camera, set the frame width and height, and then use the haarcascades model to identify where the face is in the live camera. Next, I used a pre-set x and y which I added to the default x and y values of where the face lies. In short, it detects the face, then goes up about 50 pixels (the top of the head) and places an overlay of the hair style selected.
You can experiment with this by adding your own hair overlays and create your own icons.