The inspiration for this particular program came as I wanted program something that my niece to enjoy as well. She loves this game, so I thought of writing a program for that, how hard it can be right?
The basic program where the computer chooses an option form three(Rock, paper and scissors) and you chooses one is pretty simple. All you need is to select a random number from 1 to 3, which you can do using 'random' module in Python. So, I thought of spicing the program using image recognition. So, I searched online to find how people has tackled this before, I knew someone would have tried this before. And look what I found.
It looks impressive, isn't it. The image recognition part is the tricky one, the robot actuation, if the API's are in place can be finished with three if else condition.
Pseudo code:
if Scissors show rock
elseif Rock show paper
elseif Paper show scissors
else do nothing
Coming back to the image recognition part, to detect the hand gestures there were several methods I found online. Broadly, some using mathematical models and others using machine learning. I found the machine learning to be interesting, well, there is a paradigm shift in the way we are tackling complex problems, rule based algorithms giving way to artificial intelligence based algorithms.
I used Tensor Flow to design a neural network for the image classification, there were 4 classes, namely rock, paper, scissors and none. Using OpenCV I made a image filter to track the skin tone, which I converted in to black and white image. This black and white image was used to train the neural network. I used close to 7500 images to train the network
Lessons learned:
Amount of data in the dataset is not important, rather it is the diversity in the data that is the most important. You can't expect the neural network to work better if you train with a large set of repetitive data points.
Once you know the limitations of the neural network, it is pretty easy to improve it with by training the data that failed, if you have the training and evaluation architecture built in.
Commentaires