We are going to use Python with OpenCV and Google’s MediaPipe to track the face using a webcam (built-in webcam or any webcam connected to your laptop).

Install the packages (Python 3.12 recommended):

pip install mediapipe python-osc opencv-python

Tested with mediapipe 0.10.32, opencv-python 4.12.0.88, but should work for the latest version.

Python MediaPipe example

This is a simple example using the webcam to extract facial landmarks. Nose tip is extracted and its position is constantly printed out.

Control mouse cursor and keyboard

pip install pyautogui

Learn more