Skip to content

OpenPose: A Real-Time Multi-Person Keypoint Detection And Multi-Threading C++ Library

License

Notifications You must be signed in to change notification settings

kensun0/openpose

 
 

Repository files navigation

OpenPose

Introduction

OpenPose is a library for real-time multi-person keypoint detection and multi-threading written in C++ using OpenCV and Caffe*, authored by Gines Hidalgo, Zhe Cao, Tomas Simon, Shih-En Wei, Hanbyul Joo and Yaser Sheikh.

  • It uses Caffe, but the code is ready to be ported to other frameworks (e.g., Tensorflow or Torch). If you implement any of those, please, make a pull request and we will add it!

OpenPose represents the first real-time system to jointly detect human body, hand and facial keypoints (in total 130 keypoints) on single images. In addition, the system computational performance on body keypoint estimation is invariant to the number of detected people in the image.

OpenPose is freely available for free non-commercial use, and may be redistributed under these conditions. Please, see the license for further details. Contact us for commercial purposes.

Library main functionality:

  • Multi-person 15 or 18-keypoint body pose estimation and rendering.

  • Multi-person 2x21-keypoint hand estimation and rendering (coming soon in around 1-2 months!).

  • Multi-person 70-keypoint face estimation and rendering (coming soon in around 2-3 months!).

  • Flexible and easy-to-configure multi-threading module.

  • Image, video, and webcam reader.

  • Able to save and load the results in various formats (JSON, XML, PNG, JPG, ...).

  • Small display and GUI for simple result visualization.

  • All the functionality is wrapped into a simple-to-use OpenPose Wrapper class.

The pose estimation work is based on the C++ code from the ECCV 2016 demo, "Realtime Multiperson Pose Estimation", Zhe Cao, Tomas Simon, Shih-En Wei, Yaser Sheikh. The full project repo includes Matlab and Python version, as well as training code.

Results

Body Estimation

Coming Soon (But Already Working!)

Body + Hands + Face Estimation

Body + Face Estimation

Body + Hands

Contents

  1. Installation, Reinstallation and Uninstallation
  2. Quick Start
    1. Demo
    2. OpenPose Wrapper
    3. OpenPose Library
  3. Output
    1. Output Format
    2. Reading Saved Results
  4. Send Us Your Feedback!
  5. Citation

Installation, Reinstallation and Uninstallation

You can find the installation, reinstallation and uninstallation steps on: doc/installation.md.

Quick Start

Most users cases should not need to dive deep into the library, they might just be able to use the Demo or the simple OpenPose Wrapper. So you can most probably skip the library details in OpenPose Library.

Demo

Your case if you just want to process a folder of images or video or webcam and display or save the pose results.

Forget about the OpenPose library details and just read the doc/demo_overview.md 1-page section.

OpenPose Wrapper

Your case if you want to read a specific format of image source and/or add a specific post-processing function and/or implement your own display/saving.

(Almost) forget about the library, just take a look to the Wrapper tutorial on examples/tutorial_wrapper/.

Note: you should not need to modify OpenPose source code or examples, so that you can directly upgrade the OpenPose library anytime in the future without changing your code. You might create your custom code on examples/user_code/ and compile it by using make all in the OpenPose folder.

OpenPose Library

Your case if you want to change internal functions and/or extend its functionality. First, take a look at the Demo and OpenPose Wrapper. Second, read the 2 following subsections: OpenPose Overview and Extending Functionality.

  1. OpenPose Overview: Learn the basics about the library source code in doc/library_overview.md.

  2. Extending Functionality: Learn how to extend the library in doc/library_extend_functionality.md.

  3. Adding An Extra Module: Learn how to add an extra module in doc/library_add_new_module.md.

Doxygen Documentation Autogeneration

You can generate the documentation by running the following command. The documentation will be generated in doc/doxygen/html/index.html. You can simply open it with double click (your default browser should automatically display it).

cd doc/
doxygen doc_autogeneration.doxygen

Output

Output Format

There are 2 alternatives to save the (x,y,score) body part locations. The write_pose flag uses the OpenCV cv::FileStorage default formats (JSON, XML and YML). However, the JSON format is only available after OpenCV 3.0. Hence, write_pose_json saves the people pose data using a custom JSON writer. For the latter, each JSON file has a people array of objects, where each object has an array body_parts containing the body part locations and detection confidence formatted as x1,y1,c1,x2,y2,c2,.... The coordinates x and y can be normalized to the range [0,1], [-1,1], [0, source size], [0, output size], etc., depending on the flag scale_mode. In addition, c is the confidence in the range [0,1].

{
    "version":0.1,
    "people":[
        {"body_parts":[1114.15,160.396,0.846207,...]},
        {"body_parts":[...]},
    ]
}

The body part order of the COCO (18 body parts) and MPI (15 body parts) keypoints is described in POSE_BODY_PART_MAPPING in include/openpose/pose/poseParameters.hpp. E.g., for COCO:

    POSE_COCO_BODY_PARTS {
        {0,  "Nose"},
        {1,  "Neck"},
        {2,  "RShoulder"},
        {3,  "RElbow"},
        {4,  "RWrist"},
        {5,  "LShoulder"},
        {6,  "LElbow"},
        {7,  "LWrist"},
        {8,  "RHip"},
        {9,  "RKnee"},
        {10, "RAnkle"},
        {11, "LHip"},
        {12, "LKnee"},
        {13, "LAnkle"},
        {14, "REye"},
        {15, "LEye"},
        {16, "REar"},
        {17, "LEar"},
        {18, "Bkg"},
    }

For the heat maps storing format, instead of individually saving each of the 67 heatmaps (18 body parts + background + 2 x 19 PAFs) individually, the library concatenates them into a huge (width x #heat maps) x (height) matrix, i.e. it concats the heat maps by columns. E.g., columns [0, individual heat map width] contains the first heat map, columns [individual heat map width + 1, 2 * individual heat map width] contains the second heat map, etc. Note that some image viewers are not able to display the resulting images due to the size. However, Chrome and Firefox are able to properly open them.

The saving order is body parts + background + PAFs. Any of them can be disabled with program flags. If background is disabled, then the final image will be body parts + PAFs. The body parts and background follow the order of POSE_COCO_BODY_PARTS or POSE_MPI_BODY_PARTS, while the PAFs follow the order specified on POSE_BODY_PART_PAIRS in poseParameters.hpp. E.g., for COCO:

    POSE_COCO_PAIRS    {1,2,   1,5,   2,3,   3,4,   5,6,   6,7,   1,8,   8,9,   9,10, 1,11,  11,12, 12,13,  1,0,   0,14, 14,16,  0,15, 15,17,   2,16,  5,17};

Where each index is the key value corresponding to each body part in POSE_COCO_BODY_PARTS, e.g., 0 for "Neck", 1 for "RShoulder", etc.

Reading Saved Results

We use standard formats (JSON, XML, PNG, JPG, ...) to save our results, so there will be lots of frameworks to read them later, but you might also directly use our functions in include/openpose/filestream.hpp. In particular, loadData (for JSON, XML and YML files) and loadImage (for image formats such as PNG or JPG) to load the data into cv::Mat format.

Custom Caffe

We only modified some Caffe compilation flags and minor details. You can use use your own Caffe distribution, these are the files we added and modified:

  1. Added files: install_caffe.sh; as well as Makefile.config.Ubuntu14.example, Makefile.config.Ubuntu16.example, Makefile.config.Ubuntu14_cuda_7.example and Makefile.config.Ubuntu16_cuda_7.example (extracted from Makefile.config.example). Basically, you must enable cuDNN.
  2. Edited file: Makefile. Search for "# OpenPose: " to find the edited code. We basically added the C++11 flag to avoid issues in some old computers.
  3. Optional - deleted Caffe file: Makefile.config.example.
  4. Finally, run make all && make distribute in your Caffe version and modify the Caffe directory variable in our Makefile config file: ./Makefile.config.UbuntuX.example (where X is 14 or 16 depending on your Ubuntu version), set the CAFFE_DIR parameter to the path where both the include and lib Caffe folders are located.

OpenPose Benchmark

Initial library running time benchmark on OpenPose Benchmark. You can comment in that document with your graphics card model and running time for that model, and we will add your results to the benchmark!

Send Us Your Feedback!

Our library is open source for research purposes, and we want to continuously improve it! So please, let us know if...

  1. ... you find any bug (in functionality or speed).

  2. ... you added some functionality to some class or some new Worker subclass which we might potentially incorporate.

  3. ... you know how to speed up or improve any part of the library.

  4. ... you have a request about possible functionality.

  5. ... etc.

Just comment on GibHub or make a pull request and we will answer as soon as possible! Send us an email if you use the library to make a cool demo or YouTube video!

Citation

Please cite the papers in your publications if it helps your research:

Pose Estimation

@inproceedings{cao2017realtime,
  author = {Zhe Cao and Tomas Simon and Shih-En Wei and Yaser Sheikh},
  booktitle = {CVPR},
  title = {Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields},
  year = {2017}
  }

@inproceedings{simon2017hand,
  author = {Tomas Simon and Hanbyul Joo and Iain Matthews and Yaser Sheikh},
  booktitle = {CVPR},
  title = {Hand Keypoint Detection in Single Images using Multiview Bootstrapping},
  year = {2017}
  }

@inproceedings{wei2016cpm,
  author = {Shih-En Wei and Varun Ramakrishna and Takeo Kanade and Yaser Sheikh},
  booktitle = {CVPR},
  title = {Convolutional pose machines},
  year = {2016}
  }

About

OpenPose: A Real-Time Multi-Person Keypoint Detection And Multi-Threading C++ Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 88.7%
  • Cuda 8.0%
  • Makefile 2.6%
  • Shell 0.7%