Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Camera & Vision Modules

Gesture Recognition Using Camera and MediaPipe on Raspberry Pi

Gesture Recognition Using Camera and MediaPipe on Raspberry Pi

March 11, 2026 /Posted byJayesh Jain / 0

Gesture recognition enables hands-free control of robots, smart home devices, and interactive displays. Using MediaPipe Hands and a Raspberry Pi camera, you can detect 21 hand landmarks in real time. This gesture recognition camera MediaPipe Raspberry Pi tutorial covers installation, hand landmark detection, gesture classification, and practical applications for India maker projects.

Table of Contents

  • MediaPipe Hands Overview
  • Hardware Setup
  • Installation on Raspberry Pi
  • Detecting Hand Landmarks
  • Gesture Classification Logic
  • Practical Applications
  • Performance Optimisation
  • FAQ

MediaPipe Hands Overview

MediaPipe Hands detects 21 3D landmarks on each hand. Indices 0-4: thumb (wrist to tip), 5-8: index finger, 9-12: middle, 13-16: ring, 17-20: pinky. By analysing relative landmark positions, you can classify gestures: thumbs up, peace sign, fist, open palm, pointing, and custom gestures.

Hardware Setup

Arducam IMX219 8MP Camera Module

8MP Sony IMX219 sensor, Raspberry Pi CSI compatible. Sharp image quality for accurate hand landmark detection. Wide angle model available for close-range gesture recognition.

View Product

Waveshare IMX219-77 Camera Module

IMX219 sensor with 77-degree FOV, ideal for gesture recognition at arm’s length distance. Compatible with Raspberry Pi 4/5 and Jetson Nano.

View Product

Installation on Raspberry Pi

sudo apt update
sudo apt install -y python3-opencv python3-pip python3-picamera2
pip3 install mediapipe
python3 -c "import mediapipe as mp; print(mp.__version__)"

MediaPipe 0.10+ supports ARM64 natively. On 32-bit Raspberry Pi OS, use the mediapipe-rpi4 package.

Detecting Hand Landmarks

import cv2, mediapipe as mp, numpy as np
from picamera2 import Picamera2

mp_hands = mp.solutions.hands
mp_draw = mp.solutions.drawing_utils
hands = mp_hands.Hands(max_num_hands=2, min_detection_confidence=0.7, min_tracking_confidence=0.5)

picam2 = Picamera2()
picam2.configure(picam2.create_preview_configuration(main={'size':(640,480),'format':'BGR888'}))
picam2.start()

while True:
    frame = picam2.capture_array()
    rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    results = hands.process(rgb)
    if results.multi_hand_landmarks:
        for hl, hd in zip(results.multi_hand_landmarks, results.multi_handedness):
            mp_draw.draw_landmarks(frame, hl, mp_hands.HAND_CONNECTIONS)
            h, w = frame.shape[:2]
            lm = [[p.x*w, p.y*h] for p in hl.landmark]
            gesture = classify_gesture(lm)
            hand_type = hd.classification[0].label
            cv2.putText(frame, f'{hand_type}: {gesture}', (10,50),
                        cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0), 2)
    cv2.imshow('Gesture Recognition', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'): break
picam2.stop()
cv2.destroyAllWindows()

Gesture Classification Logic

def finger_up(lm, tip, pip_joint):
    return lm[tip][1] < lm[pip_joint][1]

def classify_gesture(lm):
    thumb = lm[4][0] < lm[3][0]
    idx = finger_up(lm, 8, 6)
    mid = finger_up(lm, 12, 10)
    rng = finger_up(lm, 16, 14)
    pnk = finger_up(lm, 20, 18)
    all4 = [idx, mid, rng, pnk]
    n = sum(all4)
    if not any([thumb]+all4): return 'Fist'
    if thumb and not any(all4): return 'Thumbs Up'
    if idx and not mid and not rng and not pnk: return 'Point'
    if idx and mid and not rng and not pnk: return 'Peace'
    if all(all4) and thumb: return 'Open Palm'
    return f'{n} Fingers'

Practical Applications

Smart home control: Fist = lights off, open palm = lights on, point up = fan speed increase. Connect GPIO outputs to relay modules for 220V appliance control common in Indian homes.

Robot arm control: Peace sign = gripper close, open palm = gripper open. Run gesture recognition on Pi and send commands to Arduino via serial.

Presentation remote: Point right = next slide, point left = previous. Use xdotool key Right on Raspberry Pi desktop for LibreOffice Impress control.

Arducam OV5642 Auto-Focus Camera

5MP OV5642 with motorised auto-focus. Ideal for gesture recognition at variable distances – keeps hand details sharp whether 20cm or 100cm from camera.

View Product

Performance Optimisation

MediaPipe on Raspberry Pi 4 runs at 8-15 FPS. To improve performance:

  • Reduce resolution to 320×240 for close-range use – achieves 25+ FPS
  • Set max_num_hands=1 – roughly doubles speed
  • Skip every 2nd frame – use tracking between full detections
  • Pi 5 – ARM Cortex-A76 gives ~3x throughput vs Pi 4

FAQ

Does MediaPipe work in Indian indoor lighting conditions?

Yes, but performance degrades under 50 lux. Add a small LED fill light. Flickering tube lights cause detection jitter – switch to LED lighting for consistent results.

Can I use a USB webcam instead of Pi Camera?

Yes. Replace Picamera2 with cv2.VideoCapture(0). CSI cameras are preferred for lower latency.

How do I train a custom gesture classifier?

Save landmark arrays to CSV with numpy.savetxt. Train scikit-learn’s RandomForestClassifier or SVM on your custom gestures. Inference runs at full frame rate on just 42 numbers per hand.

What is the maximum detection range?

MediaPipe reliably detects hands at 20-150cm. Beyond 150cm, landmark accuracy degrades. Crop and upscale the hand region for longer range detection.

Shop Camera & Vision Modules

Tags: computer vision gestures, gesture recognition MediaPipe, hand landmark detection Pi, MediaPipe Raspberry Pi, OpenCV hand detection
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Solar Battery Backup System: 1...
blog solar battery backup system 12v 100ah lifepo4 diy guide india 599344
blog smd footprint creation in kicad custom component library 599351
SMD Footprint Creation in KiCa...

Related posts

Svg%3E
Read more

Endoscope Camera Module: PCB Inspection and Industrial Use

April 1, 2026 0
An endoscope camera module is an invaluable tool for PCB inspection, industrial equipment maintenance, and quality control tasks where direct... Continue reading
Svg%3E
Read more

Number Plate Recognition System: ESP32-CAM ANPR Project India

April 1, 2026 0
Building a number plate recognition system with ESP32-CAM is an affordable approach to automatic number plate recognition (ANPR) for Indian... Continue reading
Svg%3E
Read more

Machine Vision with OpenCV: Raspberry Pi Object Detection Guide

April 1, 2026 0
Running OpenCV on a Raspberry Pi for object detection opens up countless applications, from industrial quality inspection to smart doorbell... Continue reading
Svg%3E
Read more

Arducam vs Raspberry Pi Camera: Which Camera Module to Choose

April 1, 2026 0
Choosing between Arducam and Raspberry Pi camera modules is one of the first decisions for any vision project. Both connect... Continue reading
Svg%3E
Read more

360-Degree Camera Stitching Project with OpenCV and Pi

March 11, 2026 0
Creating a 360-degree camera using OpenCV image stitching with Raspberry Pi is an ambitious computer vision project that combines multiple... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now