Building a Hand Gesture Game
How to make a more immersive game.
Join the DZone community and get the full member experience.Join For Free
Have you already piled the products you want to buy into your online shopping cart? What if you're feeling a little more frugal and want to save your hard-earned cash instead? Fortunately, there is Crazy Shopping Cart, a fast-paced and addictive virtual shopping game that integrates HUAWEI ML Kit's hand keypoint detection service to allow you to control a virtual shopping cart using hand gestures. In this post, I'll show you how the game's hand gesture control feature was developed using ML Kit.
How to Play
Players perform hand gestures to control the left-right movement of a shopping cart and collect as many items as possible. The cart speeds up every 15 seconds.
Looks fun right? Let's take a look at how the game's hand gesture control system is developed.
1. Configure the Maven repository address.
Open the build.gradle file in the root directory of your Android Studio project.
2. Perform integration in full SDK mode.
After integrating the SDK, add the following configuration to the file header:
Add apply plugin: 'com.huawei.agconnect' after apply plugin: 'com.android.application'.
3. Create a hand keypoint analyzer.
4. Create the detection result processing class HandKeypointTransactor.
5. Set the detection result processor, and bind it to the analyzer.
6. Create a LensEngine instance.
7. Call the run method to start the camera and read video streams for detection.
8. After the detection is complete, stop the analyzer, and release detection resources.
As you can see, the development process is really simple and fast. In addition to adding hand gesture control to your mobile games, ML Kit's hand keypoint detection service also has many other useful applications. For example, users can add cute or funny special effects to their videos when using short-video apps with this service integrated. Also, users of smart home apps with this service integrated can customize the hand gestures they use to remotely control appliances.
Try the service out for yourself now by integrating HUAWEI ML Kit with your own apps.
Official website of Huawei Developers
HMS Core official community on Reddit
Discussions on Stack Overflow
Opinions expressed by DZone contributors are their own.