使用网络摄像头和Python + MediaPipe通过身体动作控制PC游戏
我一直在尝试构建一个通用的基于手势的游戏控制器——这个想法是让你可以用身体来玩PC游戏,而不是使用传统的控制器或键盘。
它使用了:
- MediaPipe进行身体姿势检测
- OpenCV进行图像处理
- 我编写的自定义Python管道,将手势映射到按键
- 一台标准的网络摄像头(放置在屏幕上方)——不需要VR硬件或特殊设备
这里有一个它与《罗马之子:崛起》一起运行的简短演示:
https://www.youtube.com/watch?v=0k5jMM-aK1M
我还在其他第三人称动作游戏中进行了测试(如《刺客信条》、《巫师》、《星球大战:绝地陨落秩序》)。该系统根据检测到的身体动作发送可配置的按键——例如:
- 踏步以移动角色
- 手臂动作进行攻击或防御
- 倾身以躲避或侧移
对于那些强调移动和时机而非精准瞄准的游戏,它的效果出乎意料地好。
我分享这个是因为:
- 我希望能得到对技术方案的反馈
- 我很好奇大家能想到哪些其他应用(除了游戏之外?)
- 我想找一些测试者来帮助完善系统,并在更多游戏中进行测试
最终,我希望将其转变为一个易于配置的工具——但目前它只是一个有趣的实验项目。
如果这里有人对代码、设计权衡或试用感兴趣,我很乐意分享更多细节。
查看原文
I’ve been experimenting with building a universal gesture-based game controller — the idea is to let you play PC games using your body instead of a traditional controller or keyboard.<p>It uses:<p>MediaPipe for body pose detection<p>OpenCV for image processing<p>A custom Python pipeline I wrote to map gestures → keypresses<p>A standard webcam (placed above the screen) — no VR hardware or special equipment needed<p>Here’s a short demo of it running with Ryse: Son of Rome:
https://www.youtube.com/watch?v=0k5jMM-aK1M<p>I’ve also tested it on other 3rd-person action games (Assassin’s Creed, The Witcher, Star Wars Jedi Fallen Order). The system sends configurable keypresses based on detected body movements — for example:<p>Stepping to move the character<p>Arm movements to attack or block<p>Leaning to dodge or strafe<p>It works surprisingly well for games that emphasize movement and timing over precision aiming.<p>I’m sharing this because:<p>I’d love feedback on the technical approach<p>I’m curious what other applications people can think of (beyond gaming?)<p>I’d like to find a few testers to help refine the system and test across more games<p>Eventually I’d like to turn this into an easy-to-configure tool — but for now it’s a fun experimental project.
If anyone here is interested in the code, the design tradeoffs, or trying it out, I’d be happy to share more details.