Inspiration
Our take of the classic snake game that was popular back in the nokia era, we wanted to better immerse ourselves (literally) into this classic beauty. What better way to immerse yourself that one step from VR? Your face :)
What it does
Eye Tracker Functionality:
- The code uses the mediapipe library to detect and track facial landmarks, particularly focusing on specific points related to the eyes and nose.
- It captures video frames from the default camera using OpenCV (
cv2). - For each detected face, it extracts 2D and 3D coordinates of the relevant facial landmarks.
- Utilizing this information, it calculates the rotation angles of the user's head in three dimensions (x, y, z).
- The code then determines the user's head orientation (looking left, right, up, down, or forward) based on the calculated angles.
- The result is stored in a shared variable (
shared_direction) managed by the multiprocessing.Manager.
Snake Game Functionality:
- The code uses the pygame library to create a simple Snake game.
- The Snake class manages the snake's position, length, and direction. The direction is determined by the shared variable (
shared_direction) from the eye tracker. - The Fruit class represents the target for the snake to eat. Its position is randomized when the snake consumes it.
- The main loop updates the snake's position, checks for collisions (e.g., with the fruit), and renders the game screen.
Multiprocessing:
- The multiprocessing library is employed to run the eye tracker and snake game concurrently in separate processes.
- A Manager is used to create a shared variable (
shared_direction) that allows communication between these processes. - This ensures that the eye tracker process can update the shared variable with the user's head orientation, and the snake game process can read this information to adjust the snake's direction.
In summary, this code creates an interactive application where the user's head movements are tracked in real-time using the eye tracker, and this information is used to control the direction of a snake in a game. The two functionalities run concurrently in separate processes, communicating through a shared variable. The result is a unique combination of computer vision and gaming elements.
Accomplishments that we're proud of
The snake game is a simple and straightforward game with limited functionality, it embraces the simplicity of old retro games back when mobile phones were still in development, and we managed to integrate it with a form of modern technology that lets you "feel" the game.
Comments
Do enjoy the game with your fullest might (quite literally again) a form that forces you to move and feel the movements of your cute green snake. What was once your fingers is now your full face!
Log in or sign up for Devpost to join the conversation.