GithubHelp home page GithubHelp logo

felixchenfy / ros_openpose_rgbd Goto Github PK

View Code? Open in Web Editor NEW
38.0 6.0 8.0 35.51 MB

Visualize 3d humans' skeletons(body+hands) in ros rviz. The 2d joints are detected by openpose; The depth is from depth image.

License: MIT License

CMake 0.41% Python 99.59%
openpose human-pose rgbd 3d-pose ros rviz visualization realsense-camera

ros_openpose_rgbd's Introduction

ros_openpose_rgbd

Combine Openpose 2D detection results and depth image to obtain human 3D joint positions, and draw in ROS rviz.

Demo: (Body only; 12 fps; Kind of good.)

Demo: (Body+hand; 3 fps; Inaccurate hands' 3D positions.)

Contents:

1. Introduction

Algorithm: The workflow is:

  1. Detect 2D human joints from color image by Openpose.
  2. Compute joints' 3D positions by getting the depth from depth image.
  3. Visualize them in rviz by ROS markers.

Code: The main script is detect_and_draw_joints.py, which imports two library scripts lib_openpose_detector.py and lib_draw_3d_joints.py.

Data: See data/image_i1 and data/images_n40.

Joints' format: I'm using COCO model for body detection. See this page, and the picture of body and hand.

Example of usage: Check the arguments by rosrun ros_openpose_rgbd detect_and_draw_joints.py -h. Read Section 3. Usage for more details.

2. Installation

Environment:
Ubuntu 18.04, ROS melodic, python2.

Install some common python libraries:

pip2 install --user open3d

Openpose: First, install Openpose by following its very detailed and very long official tutorial.
Please also compile its code into Python2 libraries. Tutorial is here.

The major (not complete) steps are listed below:

cd ~/githubs
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose; cd openpose
mkdir -p build; cd build
cmake  -DBUILD_PYTHON=ON \
    -DPYTHON_EXECUTABLE=/usr/bin/python2.7 \
    -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7m.so ..
make -j11
sudo make install # Install c++/python libraries to `/usr/local/python`.

After installation, check the environment variable OPENPOSE_HOME. We will need to read model from ${OPENPOSE_HOME}/models/.

echo "'${OPENPOSE_HOME}' should be the folder of your openpose."

Make sure you can run its example

cd ${OPENPOSE_HOME}/build/examples/tutorial_api_python
python 04_keypoints_from_images.py

Set the environment variable OPENPOSE_PYTHONPATH as the installation directory of openpose python libraries. It's probably /usr/local/python.

export OPENPOSE_PYTHONPATH="/usr/local/python"

3. Usage

3.1. Unittest

3.1.1. lib_openpose_detector.py

python lib_openpose_detector.py

This test case reads a color image from data/image_i1/color/, detect the human joints, and then ouputs the results to output/.

3.1.2. lib_draw_3d_joints.py

python lib_draw_3d_joints.py
roslaunch ros_openpose_rgbd run_rviz.launch

This test case reads the 2D joints and image from data/image_i1/, computes the 3D joint positions, and then draw the joints in rviz.

3.2. Test Data from Disk

DATA="data/images_n40/"
rosrun ros_openpose_rgbd detect_and_draw_joints.py \
    --data_source disk \
    --base_folder $(rospack find ros_openpose_rgbd) \
    --folder_color $DATA/color \
    --folder_depth $DATA/depth \
    --camera_info_file $DATA/cam_params_realsense.json \
    --detect_hand true # true or false
roslaunch ros_openpose_rgbd run_rviz.launch

3.3. Test Data from ROS Topic

Please download the color/depth images pulisher:

ROOT=$(rospack find ros_openpose_rgbd)
cd ${ROOT}/.. # cd to ~/catkin_ws/src/ folder.
if [ ! -d "ros_pub_and_sub_rgbd_and_cloud" ]; then
    repo="https://github.com/felixchenfy/ros_pub_and_sub_rgbd_and_cloud"
    git clone ${repo}
    cd ros_pub_and_sub_rgbd_and_cloud
    chmod a+x pub_rgbd_and_cloud.py
fi

OK. Now publish data, and start detection and drawing:

roslaunch ros_openpose_rgbd publish_test_rgbd_data.launch
rosrun ros_openpose_rgbd detect_and_draw_joints.py \
    --data_source rostopic \
    --ros_topic_color camera/color/image_raw \
    --ros_topic_depth camera/aligned_depth_to_color/image_raw \
    --ros_topic_camera_info camera/color/camera_info \
    --detect_hand true # true or false

The publish rate is set as 1 image/second. Please read launch/publish_test_rgbd_data.launch, and change publish settings in config/publish_test_rgbd_data_config.yaml.

3.4. Test Data from Realsense

In 3.3, the data is read from disk and published to ROS topics. Here we read it from Realsense D435.

roslaunch ros_openpose_rgbd run_realsense.launch
rosrun ros_openpose_rgbd detect_and_draw_joints.py \
    --data_source rostopic \
    --is_using_realsense true \
    --detect_hand false # My laptop is not fast enough to detect hand.

4.Results

4.1. Speed

Running speed of the main program detect_and_draw_joints.py is:

  • Settings: RTX 2070; Image resize to 320x240.
  • Results:
    • body + hand: 3 fps.
    • Only body: 12 fps.

4.2. Accuracy

See the two gif at the top of this README.

  • The 3D body joints are not too bad, but still has some "trembling" even if I'm standing still.
  • The 3D hand joints are awful. (1) One thing is that due to self-occlusion and motion blur, sometimes 2D joints are not detected or are not accurate. (2) Another thing is that finger's depth is very inaccurate. We know that the depth near an object's edge is likely to be noisy, and this is especially severe for small and thing objects like fingers.

Besides the above problem, the Realsense also doesn't work well as expected. The measured depth value becomes inaccurate when the object is 1 meter away. I didn't do the experiment, but I feel it's about 1cm error at 1 meter, and up to 10cm when the object is several meters away (Let's say 4 meters). Also, the depth is fluctuating noticeably for distant objects, which can even be noticed from depth image.

5. Others

5.1. Helper Tools

5.2. Noisy Realsense

Below are two screenshots of the point cloud of data/image_i1 taken from different angles. You can see that it's very noisy. When I recorded this data, I forgot to turn on Realsense's spacial and temporal filtering of the point cloud. I tried it later, but the result was still bad.

5.3. Bugs

  • The ROS marker delete function sometimes doesn't work. I can't solve it right now, maybe you need to close rviz and open it again in order to clear the ROS markers. The corresponding delete function is defined in utils/lib_rviz_marker.py and def delete_marker.

ros_openpose_rgbd's People

Contributors

felixchenfy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ros_openpose_rgbd's Issues

cannot find the package after cakin_make

Hi dear developer

I met a problem I clone your package in the ~/catkin_ws/src
And after catkin_make, it stopped at

Running command: "make cmake_check_build_system" in "/home/vcipl/catkins/build"

Running command: "make -j8 -l8" in "/home/vcipl/catkins/build"

After that when I try to run the command:
$ roslaunch ros_openpose_rgbd run_rviz.launch
The error is
RLException: [run_rviz.launch] is neither a launch file in package [ros_openpose_rgbd] nor is [ros_openpose_rgbd] a launch file name.

Is the any steps in compiling I got mistakes? I am new to the melodic.
Hope to hear from you soon

Thank you
Le Zhou

AttributeError: 'RgbdImage' object has no attribute '_camera_pose'

Hi @felixchenfy
when i tried this command :

3.1.2. lib_draw_3d_joints.py
python lib_draw_3d_joints.py
roslaunch ros_openpose_rgbd run_rviz.launch

i got this following error :
python lib_draw_3d_joints.py
Unable to register with master node [http://localhost:11311]: master may not be running yet. Will keep trying.
[INFO] [1610807311.947765]: RvizMarker.init(): frame_id=base, topic_name=visualization_marker
Traceback (most recent call last):
File "lib_draw_3d_joints.py", line 425, in
test_visualize_3d_joints()
File "lib_draw_3d_joints.py", line 403, in test_visualize_3d_joints
hand_joints[:, i, :, :])
File "lib_draw_3d_joints.py", line 239, in init
self.set_joints(rgbd, body_joints, hand_joints)
File "lib_draw_3d_joints.py", line 248, in set_joints
self._body = Body(id_body, rgbd, body_joints)
File "lib_draw_3d_joints.py", line 181, in init
super(Body, self).init(*args)
File "lib_draw_3d_joints.py", line 61, in init
self._create_3d_joints(joints)
File "lib_draw_3d_joints.py", line 132, in _create_3d_joints
joints_xyz_in_world = change_joints_coordinate_to_world()
File "lib_draw_3d_joints.py", line 127, in change_joints_coordinate_to_world
T_camera = self._rgbd.camera_pose() # 4x4
File "/home/kubotalab/open3dtest_ws/src/ros_openpose_rgbd/utils/lib_rgbd.py", line 62, in camera_pose
return self._camera_pose
AttributeError: 'RgbdImage' object has no attribute '_camera_pose'

can you help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.