关于javascript:MMSkeleton-快速开始使用-WebCam-测试

41次阅读

共计 2469 个字符,预计需要花费 7 分钟才能阅读完成。

本文将疏导疾速应用 MMSkeleton,介绍用摄像头测试实时姿势预计。

  • MMSkeleton: https://github.com/open-mmlab…

装置

首先装置 MMDetection,可见 MMDetection 应用。

而后装置 MMSkeleton,

# 启用 Python 虚拟环境
conda activate open-mmlab

# 下载 MMSkeleton
git clone https://github.com/open-mmlab/mmskeleton.git
cd mmskeleton

# 装置 MMSkeleton
python setup.py develop

# 装置 nms op for person estimation
cd mmskeleton/ops/nms/
python setup_linux.py develop
cd ../../../

现有模型,视频测试

配置

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

选用的检测模型,如下:

  • Cascade R-CNN, R-50-FPN, 1x

    • config
    • model

运行

# verify that mmskeleton and mmdetection installed correctly
# python mmskl.py pose_demo [--gpus $GPUS]
python mmskl.py pose_demo --gpus 1

后果将会存到 work_dir/pose_demo/ta_chi.mp4

现有模型,WebCam 测试

配置

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

确认 detection_cfg estimation_cfg 的门路正确。

写码

编写 webcam.py,次要代码如下:

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()

运行

$ 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: 480
  cam_fps: 10
  cfg_file: configs/apis/pose_estimator.cascade_rcnn+hrnet.yaml
CAM: 640.0x480.0 10.0
Loading model ...
Loading model done

成果,

摄像头参数,可见 WebCam 摄像头应用。

更多

  • Awesome Human Pose Estimation
  • Awesome Skeleton based Action Recognition

GoCoding 集体实际的教训分享,可关注公众号!

正文完
 0