A hand-tracking version of the classic Fruit Ninja game using OpenCV and MediaPipe.
Explore the features »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
OpenCV Fruit Ninja is an interactive, computer-vision based arcade game inspired by the classic Fruit Ninja. Instead of swiping on a touch screen, you use your actual hand movements captured by your webcam to slice fruits in real-time. The game leverages MediaPipe for accurate hand-tracking and OpenCV for rendering and computer vision operations.
Major frameworks and libraries used to bootstrap this project:
To get a local copy up and running, follow these simple steps.
Ensure you have Python 3.7 or higher installed on your system. You will also need a functional webcam.
- Clone the repository or download the source code files.
- Install the required Python packages:
pip install -r requirements.txt
- Run the game:
python fruit_ninja.py
- Make sure you are in a well-lit environment for optimal hand-tracking performance.
- Stand in front of your webcam ensuring your hands are clearly visible.
- Use your index finger to slice the fruits that appear on the screen.
- Try to slice as many fruits as possible to achieve a high score!
- Watch out! If you miss a fruit and it falls off the screen, the game is over.
- Press
Rto restart the game after a game over. - Press
Qto quit the game at any time.
- Real-Time Hand Tracking: Utilizes Google's MediaPipe for robust and low-latency hand tracking.
- Dynamic Gameplay: Multiple fruit types rendered with distinct colors and smooth physics.
- Visual Feedback: Satisfying slicing animations when a fruit is successfully cut.
- Score System: Tracks your current score to challenge yourself.
- Intuitive Controls: Replay or quit seamlessly directly from the game over screen.
Distributed under the Apache License 2.0. See LICENSE for more information.