Live Video Facial Landmarks Detection Project using MediaPipe - Precursor for Future Projects
This Python project uses MediaPipe to perform real-time face landmark detection and visualize facial blendshapes from webcam video input. It leverages the face_landmarker_v2_with_blendshapes.task model to track facial landmarks and compute blendshape scores for animation or expression analysis.
- Real-time face landmark detection with MediaPipe's
FaceLandmarker - Visualizes face mesh, contours, and irises
- Plots facial blendshape scores as a horizontal bar chart
- Easy to run on webcam video input (can be modified for video files)
- Python 3.8+
- OpenCV
- NumPy
- Matplotlib
- MediaPipe with Tasks API
Install the required Python packages:
pip install opencv-python mediapipe matplotlib numpyThis project requires the face_landmarker_v2_with_blendshapes.task model file, which is not included in this repository.
You can download it from the official MediaPipe documentation:
👉 Download face_landmarker_v2_with_blendshapes.task
Make sure the model file is saved in your project directory and named:
face_landmarker_v2_with_blendshapes.task
Once dependencies are installed and the model file is in place, run the program with:
python face_landmark_live.pyNote: Replace
face_landmark_live.pywith your actual script filename if different.
Press q in the OpenCV window to quit the application.
- Captures frames from your webcam
- Converts frames to RGB and runs face landmark detection
- Annotates the frame with:
- Mesh tessellation
- Facial contours
- Iris landmarks
- Optionally, plots a blendshape bar chart (currently disabled in live mode for performance)
| Screenshot 1 | Screenshot 2 | Screenshot 3 |
|---|---|---|
![]() |
![]() |
![]() |
- To use a video file instead of webcam input, change this line:
cap = cv2.VideoCapture(0)to:
cap = cv2.VideoCapture('path_to_your_video.mp4')- To enable blendshape bar plots per frame (may slow down performance), you can insert this inside the video loop:
plot_face_blendshapes_bar_graph(detection_result.face_blendshapes[0])This project uses MediaPipe, which is licensed under the Apache 2.0 License.


