This article will guide you to using MMSkeleton quickly and introduce you to testing real-time pose estimation with a camera.
- MMSkeleton: github.com/open-mmlab/…
The installation
First install MMDetection, MMDetection can be used.
Then install the MMSkeleton,
Enable the Python virtual environment
conda activate open-mmlab
# download MMSkeleton
git clone https://github.com/open-mmlab/mmskeleton.git
cd mmskeleton
# installation MMSkeleton
python setup.py develop
Install NMS op for Person Estimation
cd mmskeleton/ops/nms/
python setup_linux.py develop
cd. /.. /.. /Copy the code
Existing models, video testing
configuration
configs/pose_estimation/pose_demo.yaml
:
processor_cfg:
video_file: resource/data_example/ta_chi.mp4
detection_cfg:
model_cfg: ../mmdetection/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.py
checkpoint_file: ../mmdetection/checkpoints/cascade_rcnn_r50_fpn_1x_coco_20200316-3dc56deb.pth
bbox_thre: 0.8
Copy the code
The selected detection model is as follows:
- Cascade R-CNN, R-50-FPN, 1x
- config
- model
run
# verify that mmskeleton and mmdetection installed correctly
# python mmskl.py pose_demo [--gpus $GPUS]
python mmskl.py pose_demo --gpus 1
Copy the code
The results will be saved to work_dir/pose_demo/ ta_ch.mp4.
Existing model, WebCam test
configuration
configs/apis/pose_estimator.cascade_rcnn+hrnet.yaml
:
detection_cfg:
model_cfg: mmdetection/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.py
checkpoint_file: mmdetection/checkpoints/cascade_rcnn_r50_fpn_1x_coco_20200316-3dc56deb.pth
bbox_thre: 0.8
estimation_cfg:
model_cfg: mmskeleton/configs/pose_estimation/hrnet/pose_hrnet_w32_256x192_test.yaml
checkpoint_file: mmskeleton://pose_estimation/pose_hrnet_w32_256x192
data_cfg:
image_size:
- 192
- 256
pixel_std: 200
image_mean:
- 0.485
- 0.456
- 0.406
image_std:
- 0.229
- 0.224
- 0.225
post_process: true
Copy the code
Verify that the detection_CFG ESTIMation_CFG path is correct.
Write the code
Write webcam.py, the main code is as follows:
def main() :
args = parse_args()
win_name = args.win_name
cv.namedWindow(win_name, cv.WINDOW_NORMAL)
with Camera(args.cam_idx, args.cam_width, args.cam_height, args.cam_fps) as cam:
cfg = mmcv.Config.fromfile(args.cfg_file)
detection_cfg = cfg["detection_cfg"]
print("Loading model ...")
model = init_pose_estimator(**cfg, device=0)
print("Loading model done")
for frame in cam.reads():
res = inference_pose_estimator(model, frame)
res_image = pose_demo.render(
frame, res["joint_preds"], res["person_bbox"],
detection_cfg.bbox_thre)
cv.imshow(win_name, res_image)
key = cv.waitKey(1) & 0xFF
if key == 27 or key == ord("q") :break
cv.destroyAllWindows()
Copy the code
run
$ python webcam.py \ --cam_idx 2 --cam_width 640 --cam_height 480 --cam_fps 10 \ --cfg_file configs/apis/pose_estimator.cascade_rcnn+hrnet.yaml Args win_name: webcam cam_idx: 2 cam_width: 640 cam_height: Cam_fps: 10 cfg_file: configs/apis/pose_estimator.cascade_rcnn+hrnet.yaml CAM: 640.0x480.0 10.0 Loading Model... Loading modeldone
Copy the code
Effect,
Camera parameters, you can see the WebCam camera used.
More and more
- Awesome Human Pose Estimation
- Awesome Skeleton based Action Recognition
GoCoding personal practice experience sharing, can follow the public account!