Hand-Gesture Controlled Snake Game

Interactive Game using Computer Vision (OpenCV + MediaPipe + Pygame)

Hand-Gesture Snake Game Main Image

Project Overview

This project develops an interactive version of the classic Snake game, controlled entirely through hand gestures detected via a webcam. Leveraging OpenCV for video processing and MediaPipe for robust hand tracking, players can guide the snake by simply moving their index finger. The game interface, including the snake, food, and score, is overlaid directly onto the live camera feed using Pygame, creating an engaging augmented reality (AR) like experience.

I built this application from scratch, focusing on integrating real-time computer vision with game logic. The core challenge involved accurately detecting hand landmarks, translating finger movements into snake commands, and seamlessly rendering game elements on top of the dynamic video stream. This project demonstrates practical application of computer vision for intuitive user interaction.

Key Features:

  • βœ‹ Hand-Gesture Control: Navigate the snake using the tip of your index finger detected by the webcam.
  • πŸŽ₯ Real-time Camera Overlay: The game is rendered directly on top of your live camera feed, appearing as a single, unified window.
  • 🐍 Classic Snake Gameplay: Grow the snake by eating food, avoid self-collision, and navigate wrapping-around boundaries.
  • ✨ Dynamic Snake Coloring: The snake's color changes progressively as you gain score.
  • 🍎 Emoji Food: Food items are represented by engaging emojis for a modern twist.
  • πŸ“Š Score Tracking: Keep track of your high score during gameplay.
  • ⏸️ Pause Functionality: Press 'P' to pause and unpause the game.
  • πŸ”„ Restart Option: Easily restart the game after a 'Game Over' by pressing 'R'.
  • πŸš€ Optimized Performance: Utilizes MediaPipe's efficient hand detection for smooth real-time performance.

Technologies Used:

Python, OpenCV, MediaPipe, Pygame, NumPy

πŸ“Ί Project Demo Video