# ros_openpose
ROS wrapper for OpenPose | It supports *(currently but others are planned)*-
- [x] Intel RealSense Camera :heavy_check_mark:
- [x] Microsoft Kinect v2 Camera :heavy_check_mark:
- [x] Stereolabs ZED2 Camera :heavy_check_mark: (see [thanks](#thanks) section)
- [x] Azure Kinect Camera :heavy_check_mark:
- [x] Any color camera such as webcam etc :heavy_check_mark:
</br>
<p align="center">
<img src="files/ros_openpose.gif", width="800">
</br>
<sup>Sample video showing visualization on RViz</sup>
</p>
## Supported OpenPose Versions
* 1.7.0 *latest* (see point #1 in [troubleshooting](#troubleshooting) section)
* 1.6.0 (see [thanks](#thanks) section)
* 1.5.1
* 1.5.0
## Dependencies
* [OpenPose](https://github.com/CMU-Perceptual-Computing-Lab/openpose)
Note: Additionally, camera-specific ROS drivers such as following are required as per your camera model-
* [realsense-ros](https://github.com/IntelRealSense/realsense-ros): For Intel RealSense Camera
* [iai_kinect2](https://github.com/code-iai/iai_kinect2): For Microsoft Kinect v2 Camera
* [zed-ros-wrapper](https://github.com/stereolabs/zed-ros-wrapper): For Stereolabs ZED2 Camera
* [azure_kinect_ros_driver](https://github.com/microsoft/Azure_Kinect_ROS_Driver): For Azure Kinect Camera
## Installation
1. Make sure to download the complete repository. Use `git clone https://github.com/ravijo/ros_openpose.git` or download zip as per your convenience.
1. Invoke catkin tool inside ros workspace i.e., `catkin_make`
1. Make python scripts executable by using command below-
```bash
roscd ros_openpose/scripts
chmod +x *.py
```
## Troubleshooting
1. While compiling the package, if the following error is reported at the terminal-
```
error: no matching function for call to ‘op::WrapperStructPose::WrapperStructPose(<brace-enclosed initializer list>)’
```
In this case, please checkout OpenPose version 1.7.0 by running the following command at the root directory of OpenPose installation-
```bash
git checkout tags/v1.7.0
```
1. While compiling the package, if any of the following error is reported at the terminal-
```
error: ‘check’ is not a member of ‘op’
error: no match for ‘operator=’ (operand types are ‘op::Matrix’ and ‘const cv::Mat’)
error: invalid initialization of reference of type ‘const op::String&’ from expression of type ‘fLS::clstring {aka std::__cxx11::basic_string<char>}’
```
In this case, please checkout OpenPose version 1.6.0 by running the following command at the root directory of OpenPose installation-
```bash
git checkout tags/v1.6.0
```
Do not forget to run `sudo make install` to install the OpenPose system-wide.
1. If compliation fails by showing the following error-
```
/usr/bin/ld: cannot find -lThreads::Threads
```
In this case, please put the following by editing the [CMakeLists.txt](https://github.com/ravijo/ros_openpose/blob/master/CMakeLists.txt)
```
find_package(Threads REQUIRED)
```
For more information, please check [here](https://github.com/ravijo/ros_openpose/issues/12).
1. <s>While compiling the package, if the following error is reported at the terminal-
```
error: no match for ‘operator=’ (operand types are ‘op::Matrix’ and ‘const cv::Mat’)
```
In this case, please update the OpenPose. Most likely, an old version of OpenPose is installed. So please checkout Openpose from the master branch as [described here](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md#update-openpose). Alternatively, you can checkout OpenPose version 1.5.1 by running the following command at the root directory of OpenPose installation-
```bash
git checkout tags/v1.5.1
```
Do not forget to run `sudo make install` to install the OpenPose system-wide.</s> *Note that OpenPose version 1.5.1 is still supported.*
## Configuration
The main launch file is `run.launch`. It has the following important arguments-
1. `model_folder`: It represents the full path to the model directory of OpenPose. Kindly modify it as per OpenPose installation in your machine. Please edit `run.launch` file as shown below-
```xml
<arg name="openpose_args" value="--model_folder /home/ravi/openpose/models/"/>
```
1. `openpose_args`: It is provided to support the standard OpenPose command-line arguments. Please edit `run.launch` file as shown below-
```xml
<arg name="openpose_args" value="--face --hand"/>
```
1. `camera`: It can only be one of the following: `realsense`, `kinect`, `zed2`, `nodepth`. Default value of this argument is `realsense`. See below for more information.
## Implementation Versions Info.
* **Synchronous API** (see [thanks](#thanks) section)
* Uses `op_wrapper.emplaceAndPop()` method provided by OpenPose
* By default this version is disabled. Therefore, please set `synchronous:=true` and provide `py_openpose_path` while calling `run.launch`. For example:
```bash
roslaunch ros_openpose run.launch camera:=realsense synchronous:=true py_openpose_path:=absolute_path_to_py_openpose
```
* If the arg `py_openpose_path` is not specified, then the CPP node is used. Otherwise, the python node is used. Therefore, please compile OpenPose accordingly if you plan to use python bindings of the OpenPose.
* **Asynchronous API**
* Uses two workers, `op::WorkerProducer` and `op::WorkerConsumer` workers provided by OpenPose
* Uses OpenPose CPP APIs
* By default this version is enabled. Users are advised to try `synchronous:=true` if not satisfied with the performance.
## Steps to Run with Intel RealSense Camera
1. Make sure that ROS env is sourced properly by executing the following command-
```bash
source devel/setup.bash
```
1. Invoke the main launch file by executing the following command-
```bash
roslaunch ros_openpose run.launch
```
## Steps to Run with Microsoft Kinect v2 Camera
1. Make sure that ROS env is sourced properly by executing the following command-
```bash
source devel/setup.bash
```
1. Invoke the main launch file by executing the following command-
```bash
roslaunch ros_openpose run.launch camera:=kinect
```
## Steps to Run with Stereolabs ZED2 Camera
1. Change the parameter `openni_depth_mode` in [zed-ros-wrapper/zed_wrapper/params/common.yaml](https://github.com/stereolabs/zed-ros-wrapper/blob/master/zed_wrapper/params/common.yaml) to `true` (default is `0`).
1. Make sure that ROS env is sourced properly by executing the following command-
```bash
source devel/setup.bash
```
1. Invoke the main launch file by executing the following command-
```bash
roslaunch ros_openpose run.launch camera:=zed2
```
## Steps to Run with Azure Kinect Camera
1. Make sure that ROS env is sourced properly by executing the following command-
```bash
source devel/setup.bash
```
1. Invoke the main launch file by executing the following command-
```bash
roslaunch ros_openpose run.launch camera:=azurekinect
```
## Steps to Run with any Color Camera such as Webcam etc.
1. Make sure that ROS env is sourced properly by executing the following command-
```bash
source devel/setup.bash
```
1. Start the ROS package of your camera. Basically, this package is going to capture images from your camera, and then it is going to publish those images on a ROS topic. Make sure to set the correct ROS topic to `color_topic` inside [config_nodepth.launch](https://github.com/ravijo/ros_openpose/blob/d5d8e05978a1b085d8d6ffdc7604dc99a664d8d8/launch/config_nodepth.launch#L10) file.
1. Invoke the main launch file by executing the following command-
```bash
roslaunch ros_openpose run.launch camera:=nodepth
```
Note: To confirm that ROS package of your camera is working properly, please check if the ROS package is publishing images by exe