OpenCV Series — 10— Virtual Makeup — Apply contact lens to eyes

In this post , we are going to see how we can bring in effect of color contact lens in eyes using Dlib’s facial landmarks in a video feed from webcam. We can use various contact lens images and augment them over iris of the eyes in real time. Lot of Apple and Android’s photo & social media apps provide this filter functionality (e.g TikTok, Snapchat etc)

The below image is one of the sample PNG image that i chose for this project , make sure it has an alpha channel ( Don’t worry about the size we can resize it later)

Below is the code , I have placed the comments above each line of the code . The code can be improved as it does not handle occlusion well and even though it can augment the contact lens image over the eye ball it is not 100% perfect. Training a deep learning model specifically for this task might improve the accuracy.

Please go through my previous posts to get the details on facial landmark detection.

I have also shared my youtube video link for your reference, so you could understand how the code works.

Thanks for reading through this post, i hope it helps you , see you in the next post.




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rajathithan Rajasekar

Rajathithan Rajasekar


I like to write code in Python . Interested in cloud , dataAnalysis, computerVision, ML and deepLearning.