This experimental module exposes a Python API for OpenPose. This allows you to construct an OpenPose object, pass in a numpy array for an image, and get a numpy array of the pose positions. This API also exposes an API that allows you to directly pass in heatmaps from a network and extract poses out of it.
This experimental module exposes a Python API for OpenPose. This allows you to construct an OpenPose object, pass in a numpy array for an image, and get a numpy array of the pose positions. This API also exposes an API that allows you to directly pass in heatmaps from a network and extract poses out of it (Requires Python Caffe to be installed seperately)
At present the Python API only supports body pose. Hands and Face will be added in the future.
## Installation
Check [doc/installation.md#python-module](./installation.md#python-module) for installation steps.
To simply test the OpenPose API in your project without installation, ensure that the line `sys.path.append('{OpenPose_path}/python')` is set in your *.py files, where `{OpenPose_path}` points to your build folder of OpenPose. Take a look at `build/examples/tutorial_pose/1_extract_pose.py` for an example.
On an Ubuntu or OSX based system, you may use it globally. Running `sudo make install` will install OpenPose by default into `/usr/local/python`. You can set this into your python path and start using it at any location.
The Python API requires Numpy for array management, and OpenCV for image loading. They can be installed via:
```
pip install numpy
pip install opencv-python
```
## Compatibility
The OpenPose Python module is compatible with both Python 2 and Python 3. In addition, it will also run in all OpenPose compatible operating systems.
...
...
@@ -26,56 +35,16 @@ The OpenPose Python module is compatible with both Python 2 and Python 3. In add
## Testing
Two examples can be found in `build/examples/tutorial_python` in your build folder. Navigate directly to this path to run examples.
- `1_extract_pose` demonstrates a simple use of the API.
- `2_pose_from_heatmaps` demonstrates constructing pose from heatmaps from the caffe network.
-`1_extract_pose` demonstrates a simple use of the API.
-`2_pose_from_heatmaps` demonstrates constructing pose from heatmaps from the caffe network. (Requires Python Caffe to be installed seperately)
```
# From command line
cd build/examples/tutorial_python
python
python 1_extract_pose.py
```
```python
# From Python
# It requires OpenCV installed for Python
importcv2
importos
importsys
# Remember to add your installation path here
# Option a
sys.path.append('{OpenPose_path}/python')
# Option b
# If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it.
# sys.path.append('/usr/local/python')
fromopenposeimport*
# Parameters for OpenPose. Take a look at C++ OpenPose example for meaning of components. Ensure all below are filled
params=dict()
params["logging_level"]=3
params["output_resolution"]="-1x-1"
params["net_resolution"]="-1x368"
params["model_pose"]="BODY_25"
params["alpha_pose"]=0.6
params["scale_gap"]=0.3
params["scale_number"]=1
params["render_threshold"]=0.05
params["num_gpu_start"]=0
# If GPU version is built, and multiple GPUs are available, set the ID here
# If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it.
# sys.path.append('/usr/local/python')
# Parameters for OpenPose. Take a look at C++ OpenPose example for meaning of components. Ensure all below are filled
fromopenposeimport*
params=dict()
params["logging_level"]=3
params["output_resolution"]="-1x-1"
params["net_resolution"]="-1x368"
params["model_pose"]="COCO"
params["model_pose"]="BODY_25"
params["alpha_pose"]=0.6
params["scale_gap"]=0.3
params["scale_number"]=1
params["render_threshold"]=0.05
# If GPU version is built, and multiple GPUs are available, set the ID here
params["num_gpu_start"]=0
params["disable_blending"]=False
# Ensure you point to the correct path where models are located