A Python program using OpenCV, which provides the ability to interactively select makeup from a given set and overlay in a video stream from a video camera in real time.
The work was implemented using the PyCharm Community Edition 2023.1 development environment. To implement the program, the OpenCV Python library (pip install opencv-python) was used to process images and videos in real time. Haar cascades for face and eye recognition were also uploaded.
The algorithm of the program:
- Loading makeup images into computer memory.
- Loading Haar cascades for face and eye recognition into computer memory.
- Starting the video stream from the camera.
- Getting a frame from a video camera.
- Converting the frame to black and white format to improve face and eye recognition.
- Finding faces in the image using the Haar cascade for face recognition.
- Displaying of the found faces in the image.
- Finding the eyes on the face image using the Haar cascade for eye recognition.
- Displaying of makeup images on the eyes.
- If the "1", "2" or "3" key is pressed, selecting the appropriate makeup image.
- Scaling the makeup image according to the size of the eye.
- Applying an image of makeup to the eyes.
- Displaying a frame from a video camera with makeup applied on the eyes.
- If the "q" key is pressed, the program ends.
- Releasing of resources. The program uses a loop to perform steps 4-14 on each frame of the video stream until the "q" key is pressed.