This model estimates 21 hand keypoints per detected hand from [palm detector](../palm_detection_mediapipe). (The image below is referenced from [MediaPipe Hands Keypoints](https://github.com/tensorflow/tfjs-models/tree/master/hand-pose-detection#mediapipe-hands-keypoints-used-in-mediapipe-hands))
This model is converted from Tensorflow-JS to ONNX using following tools:
- tfjs to tf_saved_model: https://github.com/patlevin/tfjs-to-tf/
- tf_saved_model to ONNX: https://github.com/onnx/tensorflow-onnx
- simplified by [onnx-simplifier](https://github.com/daquexian/onnx-simplifier)
Also note that the model is quantized in per-channel mode with [Intel's neural compressor](https://github.com/intel/neural-compressor), which gives better accuracy but may lose some speed.
## Demo
Run the following commands to try the demo:
```bash
# detect on camera input
python demo.py
# detect on an image
python demo.py -i /path/to/image
```
### Example outputs
![webcam demo](./examples/mphandpose_demo.gif)
## License
All files in this directory are licensed under [Apache 2.0 License](./LICENSE).
help_msg_backends="Choose one of the computation backends: {:d}: OpenCV implementation (default); {:d}: CUDA"
help_msg_targets="Chose one of the target computation devices: {:d}: CPU (default); {:d}: CUDA; {:d}: CUDA fp16"
try:
backends+=[cv.dnn.DNN_BACKEND_TIMVX]
targets+=[cv.dnn.DNN_TARGET_NPU]
help_msg_backends+="; {:d}: TIMVX"
help_msg_targets+="; {:d}: NPU"
except:
print('This version of OpenCV does not support TIM-VX and NPU. Visit https://gist.github.com/fengyuentau/5a7a5ba36328f2b763aea026c43fa45f for more information.')
parser=argparse.ArgumentParser(description='Hand Pose Estimation from MediaPipe')
parser.add_argument('--input','-i',type=str,help='Path to the input image. Omit for using default camera.')
parser.add_argument('--model','-m',type=str,default='./handpose_estimation_mediapipe_2022may.onnx',help='Path to the model.')
parser.add_argument('--conf_threshold',type=float,default=0.8,help='Filter out hands of confidence < conf_threshold.')
parser.add_argument('--save','-s',type=str,default=False,help='Set true to save results. This flag is invalid when using camera.')
parser.add_argument('--vis','-v',type=str2bool,default=True,help='Set true to open a window for result visualization. This flag is invalid when using camera.')