A high-performance computer vision game where you play Fruit Ninja using your real hand as the blade! Built with Python, OpenCV, MediaPipe, and Pygame.
- Real-Time Hand Tracking: Uses MediaPipe to track your index finger with low latency.
- Physics-Based Gaming: Fruits launch and fall with gravity; blade collision uses robust line-segment detection for fast swipes.
- Visual Adjustments:
- Blade Trail: Dynamic cyan trail that follows your finger.
- Slicing Effects: Fruits split into two halves when sliced.
- Assets: Uses real fruit graphics (Apple, Banana, Watermelon, etc.).
- Gameplay Mechanics:
- Bombs: Avoid slicing the dark bombs with red fuses! (-5 points).
- Palm Pause: Show an Open Palm to the camera to Pause/Shield the blade (safety mechanism).
- Score System: Track your slicing performance.
- Python 3.7+
- Webcam
- Clone the repository (or download files).
- Install dependencies:
pip install -r requirements.txt
- Run the game:
python main.py
- Controls:
- Slice: Move your index finger across the screen to slice fruits. You must move fast enough to create a "cut".
- Pause: Open your hand (extend all 5 fingers) to pause the blade. This is useful if a bomb is in the way and you want to move your hand safely.
- Quit: Close the window or press
Alt+F4.
- Lag? ensure you have good lighting for the camera.
- Camera Error? The code uses
cv2.CAP_DSHOWfor Windows compatibility. If on Linux/Mac, you might need to remove that flag insensors.py.
Built with: