Tag Archives: fitness

Gamified boxing with Pi Fighter

Post Syndicated from Rob Zwetsloot original https://www.raspberrypi.org/blog/gamified-boxing-with-pi-fighter/

Gamifying boxing with a special punchbag that allows you to fight Luke Skywalker? Rob Zwetsloot starts a training montage to check it out.

Not Rob

Street Fighter

Did you know that the original version of Street Fighter had a variant where you could punch the buttons to get Ryu to attack? The harder you smacked the kick button, the more damage it would do. These apparently wore out very quickly, which is why watching Street Fighter tournaments these days is akin to watching someone playing the piano. Albeit with six buttons and a joystick.

What if you could bring this back? And combine it with other arcade classics and staples? Meet Richard Kirby’s Pi Fighter.

A new challenger!

“Pi Fighter is essentially a real-world old-school fighting video game,” Richard tells us. “The player chooses an opponent and challenges them to a sparring match. Each player has a certain number of health points that decrement each time the other player lands an attack. Instead of clicking a joystick or mouse button, the player hits a heavy bag. The strength of the hit is measured by an accelerometer. [A Raspberry] Pi translates the acceleration of the heavy bag (measured in G) into the number of health points to decrement from the opponent. [Raspberry] Pi runs your opponent, which attacks you — you don’t actually get hit, but your health points decrement each time they attack.”

Use a heavy bag to get a good workout and a good idea of your punch strength, Rocky IV style

It’s a remarkably simple idea, and it started off as just an app that used a smartphone’s accelerometer. Translating that to a Raspberry Pi is just a case of adding an accelerometer of its own.

3… 2… 1… Fight!

“I realised it could be used to measure the overall strength of a punch, but it was hard to know how that would translate into an actual punch, hence the idea to use a heavy bag,” Richard explains. “This appealed to me as I studied karate and always enjoyed hitting a heavy bag. It is always difficult to gauge your own strength, so I thought it would be useful to actually measure the force. The project ended up consuming a good amount of time, as you would expect when you are learning.”



Finish them?

While Pi Fighter is already used at events, Richard says “[i]t needs a bit of tuning and coding to get everything right […]. It could be a never-ending project for me. You can always fix things and make the software more robust, the user interface more usable, etc. It isn’t mass-rollout ready, but I have never had it fail at a key moment such as presenting at a Raspberry Jam or Raspberry Pint. It (mostly) gets better every time I put some effort into it.”

If you find yourself at Raspberry Pint in London, make sure to do a bit of a warm-up first — you might find yourself head-to-head in a boxing match with a Jedi. Here’s hoping they don’t know Teräs Käsi.

The post Gamified boxing with Pi Fighter appeared first on Raspberry Pi.

Yoga training with YogAI and a Raspberry Pi smart mirror | The MagPi issue 80

Post Syndicated from Rob Zwetsloot original https://www.raspberrypi.org/blog/yoga-training-with-yogai-and-a-raspberry-pi-smart-mirror-the-magpi-issue-80/

Running on a smart mirror, YogAI uses a database of postures, image recognition software, and the magic of mirrors to not only show users their current posture but to also teach them how to correct their posture to reach peak yogi-ness. Here’s Rob Zwetsloot from The MagPi magazine with more.

yogai

We’ve seen many ‘magic mirror’ projects over the past few years, featuring a TV screen behind the glass to show useful information, but YogAI takes the concept to a whole new level by providing an AI personal trainer to guide and correct your yoga positions.

Self-confessed fitness nuts Salma Mayorquin and Terry Rodriguez thought that having a personal trainer could be a way to keep track of their fitness progress, so why not try to make a virtual one? “With [deep learning] models like pose estimation, we figured there was a way we could make a program that could track how we were exercising and started experimenting from there,” says Terry.

“YogAI guides users through a flow of yoga poses, offering generally helpful advice when the camera senses a user not in the correct pose,” explains Salma. “At the heart, YogAI uses pose estimation to find reference key points on the body. This is used to understand and classify common yoga poses.”

Users interact with YogAI through both visual feedback via the mirror display, and a voice interface — using the Snips AIR voice assistant — which enables the user to give spoken commands to start, stop, pause, and restart a yoga session. YogAI also talks back through the Flite voice synthesiser to guide the yogi to achieve the correct poses.

While a prototype magic mirror only took the experienced makers a week to build, training the AI to recognise yoga poses in real time was a trickier task. “We need our computer vision models to run quickly so that we have enough resolution in time to identify the move,” reveals Terry.

Strike a pose

A Raspberry Pi 3 interprets the camera images in real time, detecting key body points to display the pose on the mirror and classify it using a deep-learning model trained with a dataset of around 35000 samples.

However, the pair found that the Pi could only run image inference at one frame every 4–5 seconds, resulting in lag. A workaround was soon found: “Shrinking our pose estimation models down using TensorFlow Lite, we were able to bring our frame rate from 0.2 fps to 2.5 fps,” says Salma. “For faster inference, we will look for ways to reduce the model further. We also believe upgrading to the Raspberry Pi Compute Module 3 will increase the performance significantly.”


“Overall, the accuracy across a dozen common poses is roughly 80%,” divulges Terry. “Not surprisingly, we find similar pose variants, e.g. warrior poses, can be a source of confusion. When the head/face is blocked, the pose estimates degrade, which impacts our classification of poses like downward dog.”

More intense exercise

As well as using the system for yoga, Salma and Terry are planning to adapt YogAI to monitor more energetic workouts. “We’re interested in strength training, and others have suggested dance and karate katas,” says Terry. “We think YogAI is well-positioned to perform more general health and personal wellness tasks.”

“We want to integrate with popular health wearables,” adds Salma. “A smart watch with an accelerometer and heart rate monitor can introduce a lot of important context to bring YogAI closer to our vision for a smart mirror yoga instructor and toward a personal wellness platform.”

More from The MagPi magazine

The MagPi magazine issue 80 is out today. Buy your copy now from the Raspberry Pi Press store, major newsagents in the UK, or Barnes & Noble, Fry’s, or Micro Center in the US. Or, download your free PDF copy from The MagPi magazine website.

Subscribe now

Subscribe to The MagPi magazine on a monthly, quarterly, or twelve-month basis to save money against newsstand prices!

Twelve-month print subscribers get a free Raspberry Pi 3A+, the perfect Raspberry Pi to try your hand at some of the latest projects covered in The MagPi magazine.

The post Yoga training with YogAI and a Raspberry Pi smart mirror | The MagPi issue 80 appeared first on Raspberry Pi.