How to improve FPS when using MediaPipe hand tracking with OpenCV in Python?
08:23 11 Mar 2026

I am building a simple AI hand tracking application using MediaPipe and OpenCV in Python.

The program reads frames from a webcam, processes them with MediaPipe Hands, and draws the hand landmarks on the screen.

However, I noticed that the FPS sometimes drops to around 15–20 FPS, which makes the tracking less smooth. I would like to understand if there are ways to improve the performance when using MediaPipe with OpenCV.

My environment:
- Python 3.10
- MediaPipe
- OpenCV

Here is a simplified version of my code:

```python 
import cv2 
import mediapipe as mp 
 
mp_hands = mp.solutions.hands 
hands = mp_hands.Hands() 
 
cap = cv2.VideoCapture(0) 
 
while True: 
    ret, frame = cap.read() 
    if not ret: 
        break 
 
    image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 
    results = hands.process(image) 
 
    if results.multi_hand_landmarks: 
        for hand_landmarks in results.multi_hand_landmarks: 
            mp.solutions.drawing_utils.draw_landmarks( 
                frame, hand_landmarks, mp_hands.HAND_CONNECTIONS 
            ) 
 
    cv2.imshow("Hand Tracking", frame) 
 
    if cv2.waitKey(1) & 0xFF == ord('q'): 
        break
python opencv machine-learning computer-vision mediapipe