Welcome, Guest User :: Click here to login

Logo 67443

Lab 9A: Emoji Hunter (Android)

Due Date: November 25

Objectives

-- reinforce key lessons on applied machine learning
-- give students an opportunity to add Google ML Kit into a functioning app
-- allow students to interact with camera and the CameraX framework
-- reinforce previous lessons

README.md

Our goal is to create a simple game called Emoji Hunter that will use our camera to identity real world object that look like emojis. A sample of the gameplay can be seen below:

CoreML Emoji Hunter Game Play

To start, download the quick-start code for ML Kit Vision with additional documentation here. You'll notice that CameraX is only supported on API Level 21+ so you will need to create a virtual image of Android Lollipop to ensure the minimum required level and maximum number of devices and be sure to include Google Play Services. If you have difficulty getting the quick-start to run (like I did) then an alternative quick-start can be found using TensorFlow Lite with additional documentation here


When we start the Emoji Hunter game, our camera will be activated and the app will use ML Kit or TensorFlow Lite to determine the dominant object in the frame; if it matches the target emoji within the specified time (10 seconds), then we have success.

Please note that because it uses the camera, this game has to be built on a device -- the simulator is of limited value for running this app.

  1. Begin by creating refactoring the quickstart to be called EmojiHunter.

  2. We are going to use a pre-built models that Google provides.

  3. Create a new data class file called Emoji.kt in your and add in String variables for emoji and emojiName. You can then create an array of Emoji's called emojiObjects inside your model.

To the emojiObjects array, add at least 5 emoji models of your choosing. (Pro tip: laptops, pens, and books -- all pretty common for IS students -- are easy to find in a typical room and make good choices.) To add an emoji to an EmojiModel in Android Studio, use the keyboard combination of Cmd + Ctrl + Space (command-control-space) and you will see the emoji options pop up. Below is a sample:

Emoji("💻","laptop")
  1. This step already completed in the quick-start.

  2. This one too.

  3. Take a look at the image processing code and look at the documentation to see how it works.

What you see here is that as the camera is shaking ever so slightly in my hand (while looking at the pen in the top image), the model is constantly reevaluating based on the new input and getting close, but slightly different confidence values. For our purposes in the game, if the model has confidence above 50%, it's a match. 😉

  1. Edit the given view model to create the basic GameViewModel class adding onscreen elements for a countdown timer and buttons.

  2. Our game is time-dependent. Now create some methods which handle timing matters.

  3. And finally, add some game play methods to handle the logic of playing the basic game.

  4. You may have noticed that the amount of instructions in this lab has been minimal because a lot of the functionality of the app has been given given to you in the quick-start. The challenge comes in putting it all together.

  5. This step intentionally left blank.

  6. And this on too.

  7. With that done, we can build again and play our game. 👊

  8. If you have gotten this far, you've earned 21 points (which is just above the average for the oral exam). To get the last few points (if you want them), you can do the following (mix and match for a maximum of 25 points):

  • Launch Screen: you noticed that it takes a moment or two for the camera view set up and load, so customize the launch screen so that it has the app name in large, bold letters and your name and a one sentence description of the app below that. (1 pt)

  • Score: right now we don't keep score, but having a score (both the total emojis found and percent found, rounded to no decimal places) updated and displayed for the user is worth 2 more points. (2 pts)

  • Randomization: so it's less predictable, add 5 more emoji (10 minimum total) and randomly select the emoji that will hunted. (1 point)

  • Reset: like the famous slider game, we want to loop through those emojis until the user hits a reset button and resets the scores. You need to add another 5 emojis as well. This is worth 1 point, but presumes that the score functionality is in place.

Qapla'