|
1 | 1 | ## Webcam Demo
|
2 | 2 |
|
3 |
| -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. |
| 3 | +The original Webcam API has been deprecated starting from version v1.1.0. Users now have the option to utilize either the Inferencer or the demo script for conducting pose estimation using webcam input. |
4 | 4 |
|
5 |
| -<div align="center"> |
6 |
| - <img src="https://user-images.githubusercontent.com/15977946/124059525-ce20c580-da5d-11eb-8e4a-2d96cd31fe9f.gif" width="600px" alt><br> |
7 |
| -</div> |
| 5 | +### Webcam Demo with Inferencer |
8 | 6 |
|
9 |
| -### Get started |
10 |
| - |
11 |
| -Launch the demo from the mmpose root directory: |
12 |
| - |
13 |
| -```shell |
14 |
| -# Run webcam demo with GPU |
15 |
| -python demo/webcam_api_demo.py |
16 |
| - |
17 |
| -# Run webcam demo with CPU |
18 |
| -python demo/webcam_api_demo.py --cpu |
19 |
| -``` |
20 |
| - |
21 |
| -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: |
| 7 | +Users can utilize the MMPose Inferencer to estimate human poses in webcam inputs by executing the following command: |
22 | 8 |
|
23 | 9 | ```shell
|
24 |
| -python demo/webcam_api_demo.py --config demo/webcam_cfg/human_pose.py |
| 10 | +python demo/inferencer_demo.py webcam --pose2d 'human' |
25 | 11 | ```
|
26 | 12 |
|
27 |
| -### Hotkeys |
28 |
| - |
29 |
| -| Hotkey | Function | |
30 |
| -| ------ | ------------------------------------- | |
31 |
| -| v | Toggle the pose visualization on/off. | |
32 |
| -| h | Show help information. | |
33 |
| -| m | Show the monitoring information. | |
34 |
| -| q | Exit. | |
35 |
| - |
36 |
| -Note that the demo will automatically save the output video into a file `webcam_api_demo.mp4`. |
| 13 | +For additional information about the arguments of Inferencer, please refer to the [Inferencer Documentation](/docs/en/user_guides/inference.md). |
37 | 14 |
|
38 |
| -### Usage and configuarations |
| 15 | +### Webcam Demo with Demo Script |
39 | 16 |
|
40 |
| -Detailed configurations can be found in the config file. |
| 17 | +All of the demo scripts, except for `demo/image_demo.py`, support webcam input. |
41 | 18 |
|
42 |
| -- **Configure detection models** |
43 |
| - Users can choose detection models from the [MMDetection Model Zoo](https://mmdetection.readthedocs.io/en/3.x/model_zoo.html). Just set the `model_config` and `model_checkpoint` in the detector node accordingly, and the model will be automatically downloaded and loaded. |
| 19 | +Take `demo/topdown_demo_with_mmdet.py` as example, users can utilize this script with webcam input by specifying **`--input webcam`** in the command: |
44 | 20 |
|
45 |
| - ```python |
46 |
| - # 'DetectorNode': |
47 |
| - # This node performs object detection from the frame image using an |
48 |
| - # MMDetection model. |
49 |
| - dict( |
50 |
| - type='DetectorNode', |
51 |
| - name='detector', |
52 |
| - model_config='demo/mmdetection_cfg/' |
53 |
| - 'ssdlite_mobilenetv2-scratch_8xb24-600e_coco.py', |
54 |
| - model_checkpoint='https://download.openmmlab.com' |
55 |
| - '/mmdetection/v2.0/ssd/' |
56 |
| - 'ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_' |
57 |
| - 'scratch_600e_coco_20210629_110627-974d9307.pth', |
58 |
| - input_buffer='_input_', |
59 |
| - output_buffer='det_result'), |
60 |
| - ``` |
61 |
| - |
62 |
| -- **Configure pose estimation models** |
63 |
| - In this demo we use two [top-down](https://github.com/open-mmlab/mmpose/tree/latest/configs/body_2d_keypoint/topdown_heatmap) pose estimation models for humans and animals respectively. Users can choose models from the [MMPose Model Zoo](https://mmpose.readthedocs.io/en/latest/modelzoo.html). To apply different pose models on different instance types, you can add multiple pose estimator nodes with `cls_names` set accordingly. |
64 |
| - |
65 |
| - ```python |
66 |
| - # 'TopdownPoseEstimatorNode': |
67 |
| - # This node performs keypoint detection from the frame image using an |
68 |
| - # MMPose top-down model. Detection results is needed. |
69 |
| - dict( |
70 |
| - type='TopdownPoseEstimatorNode', |
71 |
| - name='human pose estimator', |
72 |
| - model_config='configs/wholebody_2d_keypoint/' |
73 |
| - 'topdown_heatmap/coco-wholebody/' |
74 |
| - 'td-hm_vipnas-mbv3_dark-8xb64-210e_coco-wholebody-256x192.py', |
75 |
| - model_checkpoint='https://download.openmmlab.com/mmpose/' |
76 |
| - 'top_down/vipnas/vipnas_mbv3_coco_wholebody_256x192_dark' |
77 |
| - '-e2158108_20211205.pth', |
78 |
| - labels=['person'], |
79 |
| - input_buffer='det_result', |
80 |
| - output_buffer='human_pose'), |
81 |
| - dict( |
82 |
| - type='TopdownPoseEstimatorNode', |
83 |
| - name='animal pose estimator', |
84 |
| - model_config='configs/animal_2d_keypoint/topdown_heatmap/' |
85 |
| - 'animalpose/td-hm_hrnet-w32_8xb64-210e_animalpose-256x256.py', |
86 |
| - model_checkpoint='https://download.openmmlab.com/mmpose/animal/' |
87 |
| - 'hrnet/hrnet_w32_animalpose_256x256-1aa7f075_20210426.pth', |
88 |
| - labels=['cat', 'dog', 'horse', 'sheep', 'cow'], |
89 |
| - input_buffer='human_pose', |
90 |
| - output_buffer='animal_pose'), |
91 |
| - ``` |
92 |
| - |
93 |
| -- **Run the demo on a local video file** |
94 |
| - You can use local video files as the demo input by set `camera_id` to the file path. |
95 |
| - |
96 |
| -- **The computer doesn't have a camera?** |
97 |
| - A smart phone can serve as a webcam via apps like [Camo](https://reincubate.com/camo/) or [DroidCam](https://www.dev47apps.com/). |
98 |
| - |
99 |
| -- **Test the camera and display** |
100 |
| - Run follow command for a quick test of video capturing and displaying. |
101 |
| - |
102 |
| - ```shell |
103 |
| - python demo/webcam_api_demo.py --config demo/webcam_cfg/test_camera.py |
104 |
| - ``` |
| 21 | +```shell |
| 22 | +# inference with webcam |
| 23 | +python demo/topdown_demo_with_mmdet.py \ |
| 24 | + projects/rtmpose/rtmdet/person/rtmdet_nano_320-8xb32_coco-person.py \ |
| 25 | + https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth \ |
| 26 | + projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-m_8xb256-420e_coco-256x192.py \ |
| 27 | + https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-aic-coco_pt-aic-coco_420e-256x192-63eb25f7_20230126.pth \ |
| 28 | + --input webcam \ |
| 29 | + --show |
| 30 | +``` |
0 commit comments