stevenjj / openpose_ros

A ros wrapper for the CMU openpose library
60 stars 25 forks source link

OpenPose ROS

ROS wrapper for OpenPose ( https://github.com/CMU-Perceptual-Computing-Lab/openpose ) allows the estimation of 2d multi-person pose from a single RGB camera (see commit number a1e0a5f4136e702b5731a268c2993fb75ca4753c ). Based on https://github.com/stevenjj/openpose_ros .

When a depth image is synchronized with the RGB image (RGB-D image), a 3d extractor node has been implemented to obtain 3d pose estimation from the 2d pose estimation given by OpenPose through the projection of the 2d pose estimation onto the point-cloud of the depth image. Also, a visualization node for the 3d results has been implemented.

alt text

Installing Openpose ROS Wrapper

  1. Install openpose and its dependencies ( https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md)

NOTE: OpenCV 3.2 recommended, as OpenCv 2.4 might cause some errors.

  1. Install PCL (http://pointclouds.org/downloads/)

  2. Enable the package running in openpose_ros directory:

    ./install_openpose_and_enable_package.sh
  3. If it succeds, compile:

    cd ~/catkin_ws/src
    catkin build
    cd ..
    source devel/setup.bash

Running OpenPose ROS Wrapper and 3d Pose Extractor

The package can be divided into two modules that work independently. One for 2d pose detections, with a visualization tool like the one in OpenPose but implemented in ROS. And another for 3d pose detections, with a visualization node to view the results with RViz. We use the same node to get OpenPose 2d detections for both modules, but we have duplicated it and the services it provides with different names to avoid trouble while calling it with the 2d visualization tool and the 3d extractor node simultaneously.

2d Detection Module

This module is composed of a service node for getting 2d detections and a node for the output visualization.

First of all, you might want to change some things in the code to adapt it to your necessities:

alt text

alt text

Once you have set those parameters repeat step 4 of installation.

Now you can run the code. First connect a RGB camera and run the corresponding ROS drivers to start to publish the images (they must be image_raw). For example you can connect a webcam and use https://github.com/ros-drivers/usb_cam. With this drivers run:

roslaunch usb_cam usb_cam-test.launch

You should get the something like:

alt text

Then, initialize the 2d detection service node:

rosrun openpose_ros_pkg openpose_ros_node

If everything works fine you should see the following output in your shell:

[ INFO] [1501140533.950685432]: Initialization Successful!

Finally, to get the 2d poses of the images from the camera and visualize the output, run:

rosrun openpose_ros_pkg openpose_ros_node_firephinx

You should obtain something similar to:

alt text

Topics

If everything is running correctly, the package should be publishing in the topics:

/openpose_ros/input_image
/openpose_ros/detected_poses_image
/openpose_ros/detected_poses_keypoints

alt text

alt text

If you write the data in a csv it should be like this:

alt text

3d Detection Module

This module is composed of the same 2d extractor node described in the previous section, a node for getting 3d pose detection and a node for visualization of the output in RViz. We can see the resulting 3d human skeleton and the resulting 3d detections for the joints or both at the same time with the visualization node. An RGB-D camera is needed to run this module.

First of all you might want to change some things in the code to adapt it to your necessities:

alt text

*Here you should change /usb_cam_3d/image_raw/ for the topic your camera will be publishing the sensor_msgs::Image messages (RGB images). You should also change /kinect2/qhd/points for the topic your camera will be publishing the sensor_msgs::Pointcloud2 messages (depth images).

alt text

alt text

To set the options of the skeleton, go to:

alt text

Once you have set the options repeat step 4 of the installation process. Now that you have configured it, you can run the code. First of all connect your RGB-D and run the corresponding ROS drivers.

For example you can use a KinectOne and https://github.com/code-iai/iai_kinect2 ROS drivers. To initialize the camera with this drivers run:

roslaunch kinect2_bridge kinect2_bridge.launch
rosrun kinect2_viewer kinect2_viewer

Then you will see the camera output:

alt text

Once your camera is publishing, launch the 2D extractor node and the 3D extractor node by running:

roslaunch roslaunch skeleton_extract_3d openpose_skeleton_extract.launch

If everything is working fine you should have something similar to:

alt text

Then you can run the visualization node:

rosrun skeleton_extract_3d skeleton_extract_3d_visualization_node

NOTE: To have the fixed frame for visualization you must run:

rosrun kinect2_bridge kinect2_bridge _publish_tf:=true

Now open rviz and select as fixed frame the one you have set for the markers. For example, I have chosen:

kinect2_ir_optical_frame

Select the topics:

/openpose_ros/skeleton_3d/visualization_markers
/openpose_ros/skeleton_3d/visualization_skeleton

and you should have something similar to:

alt text

You can also select the pointcloud at the same time:

alt text

Topics

/openpose_ros/skeleton_3d/detected_poses_image
/openpose_ros/skeleton_3d/detected_poses_keypoints
/openpose_ros/skeleton_3d/detected_poses_keypoints_3d
/openpose_ros/skeleton_3d/input_pointcloud
/openpose_ros/skeleton_3d/input_rgb
/openpose_ros/skeleton_3d/visualization_markers
/openpose_ros/skeleton_3d/visualization_skeleton

alt text

alt text

alt text

alt text

Author

Miguel Arduengo García

Undergraduate student at CFIS-UPC (Barcelona Tech, Spain).

CFIS-UPC: https://cfis.upc.edu/es

Barcelona Tech: http://www.upc.edu/?set_language=en

Citation

Please cite the tech report if it helps in your publications:

Arduengo, M., Jorgensen, S.J., Hambuchen, K., Sentis, L., Moreno-Noguer, F., Alenyà, G. "ROS wrapper for real-time multi-person pose estimation with a single camera". Technical Report IRI-TR-17-02, Institut de Robòtica i Informàtica Industrial, CSIC-UPC, 2017.

https://upcommons.upc.edu/handle/2117/110929