ML Berry-Catcher Game

Alex Riabov

Aleksandr Riabov

Jan 31, 2023

Creating a Computer Vision Game:

Machine learning is an exciting field of technology that has been rapidly advancing over the years. As a tech enthusiast, I decided to dive into this field by creating a simple computer vision game on Raspberry Pi 4. In this blog post, I will share my journey and explain how I overcame various challenges to build this game.

Initial Research

To begin with, I had to explore different options for enabling machine learning on Raspberry Pi. Unfortunately, I discovered that the Raspberry Pi alone wasn't powerful enough for my project. I needed additional hardware to boost its capabilities. I found the Google Coral USB Accelerator with Edge TPU coprocessor to be the perfect solution for my needs. This hardware allowed high-speed machine learning on our Raspberry Pi.

Building Process

My next step was to develop the game itself. I started by writing the code to create a game where the player could catch falling berries. I wanted to add an element of motion control to the game, and for this, I decided to use computer vision through a camera. To achieve this, I chose the Raspberry Pi Camera and connected it to the camera port of the Raspberry Pi to enable the Coral to analyze images and detect motion.

Classifier

In order to make my model understand the different poses, I used datasets to teach the Python classifier cascade with OpenCV library. The model I chose could already detect 17 body points, so I created a dataset with a person performing these different poses. The dataset included 161 photos per pose. My goal was to detect five poses: No Pose, Stop, Left, Right, and Forward. I trained my model in Google Colab, which took about 7 hours, and achieved 96% accuracy.

Solution

After training the model, I added detection of each pose and handling it to move the catcher in the game. The detected motion was displayed on the Sense Hat with the data I retrieved from the classifier. The final result was a game that was not only fun to play, but also showcased the potential of machine learning and computer vision on Raspberry Pi.

Problems

During initial testing, I discovered that my model had low accuracy. However, I was able to overcome this challenge by increasing the number of images for each motion in the dataset. As a result, I achieved 98% accuracy, which greatly improved the overall performance of the game.

Conclusion

Creating this computer vision game on Raspberry Pi was an exciting and challenging project. By using machine learning and computer vision, I was able to create a game that was not only fun to play but also showcased the potential of this technology. I hope my experience inspires others to explore the possibilities of machine learning and computer vision on Raspberry Pi and other platforms.