top of page

Project 2: Unconventional Interaction with KNN Classification

Writer: Alexis SandersAlexis Sanders

Process

So for this project, I had no idea what I wanted to do. I've been busy with working on my thesis project and working on stuff for my local data class, that I hadn't put much thought into what I was going to do for this class until Monday. I started looking around at Moon's code and the examples and references he gave until I took a look at Moon's examples. I found a game that used Handpose to classify a KNN model to play a rock, paper, and scissors game. I really liked how this game was structured, so I decided to use this code to create my own KNN version of rock paper scissors.


I started by using Moon's KNN basic sketch to get the basic code of KNN. I played around with the program and adjusted some of the numbers to determine how the code worked. I then changed the language on the screen to reflect when I needed for my game and started coding the model to read my hand when it was showing "rock", "paper, or "scissors". Once I got the model coded and figured out, I saved a model so I wouldn't have to keep starting from scratch every time the code reloaded. I then started to add images of rock paper and scissors to appear on the screen instead of the circles whenever the correct pose was recognized. I ran into some problems when I introduced the images because the webcam was using the image function so when I changed the features of the images, it also changed the web camera.


I was able to adjust this with Moon's help in rearranging my code. All that was left was to continue adjusting my model since it was really glitchy and I couldn't figure out a better way of structuring the code and the model so that it could read the hand positions better. I also added an alert to let the user know how to play at the beginning, a button to load the preset data, a button to start the data, and a button to submit the player's choice and reveal the computer's choice. I thought the buttons were more intuitive for users to use if they had no experience using KNN over using the keyboard.


I was also able to figure out how to add text onto the screen that tells you when you win or lose and I added an image of a hand to let the user know ideally where to put their hand for the best results. The final code is still a little glitchy, but the basic idea is there. For future iterations, I would use Handpose and pull the data from that to get rid of some of the glitches. I wasn't able to figure out how to work handpose in time, but I would like to learn about it more to create steadier results.


Here is a video example of how the code works:


References

Comments


bottom of page