多目標姿態估計
一個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坐標),根據關節點的位置變化也可以推斷出其它動作。
關節點的坐標位置分布圖如下:
所有關節點的信息會以一個張量形式返回,所以只要根據對應下標就能取到對應的坐標。