多目标姿态估计
多目标姿态估计
一个openpose的姿态估计算法,这个算法可以检测人体的18个关节点。
安装OpenPose
这个是来自卡内基梅隆的开源算法,算法真的很鲁棒,不信来看看效果。
openpose这个算法集成Convolutional Pose Machines、Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields 和 Hand Keypoint Detection in Single Images 这三篇paper的研究。不得不说,效果的确是好啊。下面给出算法GitHub地址,安装教程在ReadMe也写得十分详细了。
GitHub地址
https://github.com/CMU-Perceptual-Computing-Lab/openpose
好的,大家根据Readme上的教程安装就好,官方算法是C++的,如果小伙伴还想用python版的就要去安装PyOpenPose。GitHub地址:https://github.com/FORTH-ModelBasedTracker/PyOpenPose
安装的教程也有人写好了:https://blog.csdn.net/xizero00/article/details/77294595
Features
- Functionality:
- 2D real-time multi-person keypoint detection:
- 15 or 18 or 25-keypoint body/foot keypoint estimation. Running time invariant to number of detected people.
- 6-keypoint foot keypoint estimation. Integrated together with the 25-keypoint body/foot keypoint detector.
- 2x21-keypoint hand keypoint estimation. Currently, running time depends on number of detected people.
- 70-keypoint face keypoint estimation. Currently, running time depends on number of detected people.
- 3D real-time single-person keypoint detection:
- 3-D triangulation from multiple single views.
- Synchronization of Flir cameras handled.
- Compatible with Flir/Point Grey cameras, but provided C++ demos to add your custom input.
- Calibration toolbox:
- Easy estimation of distortion, intrinsic, and extrinsic camera parameters.
- Single-person tracking for further speed up or visual smoothing.
- Input: Image, video, webcam, Flir/Point Grey and IP camera. Included C++ demos to add your custom input.
- Output: Basic image + keypoint display/saving (PNG, JPG, AVI, ...), keypoint saving (JSON, XML, YML, ...), and/or keypoints as array class.
- OS: Ubuntu (14, 16), Windows (8, 10), Mac OSX, Nvidia TX2.
- Training and datasets:
- Others:
- Available: command-line demo, C++ wrapper, and C++ API.
- Python API.
- Unity Plugin.
- CUDA (Nvidia GPU), OpenCL (AMD GPU), and CPU-only (no GPU) versions.
模型输出接口
要想用这个算法,肯定要找到它输出的接口啊。以PyOpenPose为例,输出接口可以在这个文件中找到:PyOpenPose/scripts/OpLoop.py。这个是实时检测的代码。
使用接口的用例代码如下:
op = OP.OpenPose((320, 240), (240, 240), (640, 480), "COCO", OPENPOSE_ROOT + os.sep + "models" + os.sep, 0, download_heatmaps)
op.detectPose(rgb)
res = op.render(rgb)
上面的是检测Pose的,还有detectFace、detectHands等等功能,如果加上这些的话,速度可能会有点感人,所以只用detectPose的话还好。
写游戏界面和逻辑
游戏界面就随意发挥了,资源网上也很多,有个素材网站叫爱给网,在上面搜索拳皇就会弹出很多相关的资源。
游戏逻辑呢,先要清楚是要根据的动作来触发游戏中动画人物的动作,根据关节位置的变化来触发,比如的手举过头顶要触发某个动作,那么手腕关节的Y坐标一定会比头顶的Y坐标要小(左上角为0,0坐标),根据关节点的位置变化也可以推断出其它动作。
关节点的坐标位置分布图如下:
所有关节点的信息会以一个张量形式返回,所以只要根据对应下标就能取到对应的坐标。