We provide a webcam demo tool which integrartes detection and 2D pose estimation for humans and animals. It can also apply fun effects like putting on sunglasses or enlarging the eyes, based on the pose estimation results.
Launch the demo from the mmpose root directory:
# Run webcam demo with GPU
python demo/webcam_api_demo.py
# Run webcam demo with CPU
python demo/webcam_api_demo.py --cpu
The command above will use the default config file demo/webcam_cfg/human_pose.py
. You can also specify the config file in the command:
python demo/webcam_api_demo.py --config demo/webcam_cfg/human_pose.py
Hotkey | Function |
---|---|
v | Toggle the pose visualization on/off. |
h | Show help information. |
m | Show the monitoring information. |
q | Exit. |
Note that the demo will automatically save the output video into a file webcam_api_demo.mp4
.
Detailed configurations can be found in the config file.
model_config
and model_checkpoint
in the detector node accordingly, and the model will be automatically downloaded and loaded. # 'DetectorNode':
# This node performs object detection from the frame image using an
# MMDetection model.
dict(
type='DetectorNode',
name='detector',
model_config='demo/mmdetection_cfg/'
'ssdlite_mobilenetv2-scratch_8xb24-600e_coco.py',
model_checkpoint='https://download.openmmlab.com'
'/mmdetection/v2.0/ssd/'
'ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_'
'scratch_600e_coco_20210629_110627-974d9307.pth',
input_buffer='_input_',
output_buffer='det_result'),
cls_names
set accordingly. # 'TopdownPoseEstimatorNode':
# This node performs keypoint detection from the frame image using an
# MMPose top-down model. Detection results is needed.
dict(
type='TopdownPoseEstimatorNode',
name='human pose estimator',
model_config='configs/wholebody_2d_keypoint/'
'topdown_heatmap/coco-wholebody/'
'td-hm_vipnas-mbv3_dark-8xb64-210e_coco-wholebody-256x192.py',
model_checkpoint='https://download.openmmlab.com/mmpose/'
'top_down/vipnas/vipnas_mbv3_coco_wholebody_256x192_dark'
'-e2158108_20211205.pth',
labels=['person'],
input_buffer='det_result',
output_buffer='human_pose'),
dict(
type='TopdownPoseEstimatorNode',
name='animal pose estimator',
model_config='configs/animal_2d_keypoint/topdown_heatmap/'
'animalpose/td-hm_hrnet-w32_8xb64-210e_animalpose-256x256.py',
model_checkpoint='https://download.openmmlab.com/mmpose/animal/'
'hrnet/hrnet_w32_animalpose_256x256-1aa7f075_20210426.pth',
labels=['cat', 'dog', 'horse', 'sheep', 'cow'],
input_buffer='human_pose',
output_buffer='animal_pose'),
Run the demo on a local video file
You can use local video files as the demo input by set camera_id
to the file path.
The computer doesn't have a camera? A smart phone can serve as a webcam via apps like Camo or DroidCam.
Test the camera and display Run follow command for a quick test of video capturing and displaying.
python demo/webcam_api_demo.py --config demo/webcam_cfg/test_camera.py