Human pose estimation using OpenPose

Converting OpenPose output to .bvh format

So far, we used tf-pose-estimation variant of OpenPose and extracted human pose from static images, videos, and also from the real time webcam feed. Note that the human pose extracted using OpenPose is in 2D. In the following section, we will convert this 2D pose to .bvh format, which allows us to animate human characters.

NOTE: This section does not rely on the content presented on the previous page where installation and testing of tf-pose-estimation was explained. It is, in fact, a standalone section and we will be using a different github repository to achieve the task of converting human pose from images or videos to a .bvh format.

Background

In this section, we use this github repository to achieve the task of extracting human pose using OpenPose and then converting the output to a .bvh format. In order to accomplish the task, we must install the dependencies first that are mentioned in the readme file.

Installation

Step 1. Clone the github repository

  1. On a Windows PC, open the Command Prompt or the Anaconda Prompt. (I used the Anaconda Prompt)
  2. Navigate to a directory where you would like to download the project from a github repository. (example, $cd Desktop will make the desktop as our current working directory)
  3. Clone the github repo. (Note, make sure you have the git installed beforehand)
$ cd Desktop
$ git clone https://github.com/KevinLTT/video2bvh

Step 2: Create a new conda environment

After cloning, notice that there is a new folder created called video2bvh inside the directory in which you cloned the github repo.

Next, we will create a new conda environment inside this new folder. It is best to work in a new conda environment since we will be downloading various different tools and versions and we don’t want it to mess with our existing projects.

  1. Navigate to the video2bvh folder, that got created after cloning the github repo in Step 1
  2. Create a new conda environment and give it a name and specify a python version to install for this environment (In my case, I called new conda environment as ‘tfpose’ and installed python 3.7 version in this environment)
  3. Activate the newly created conda environment
  4. Install the kernel to the environment

See below!

$ cd tf-pose-estimation
$ conda create - n tfpose python=3.7
$ activate tfpose
$ pip install ipykernel
$ python -m ipykernel --user --name tfpose --display-name "tfpose"

Testing

Work in progress!

References

2 thoughts on “Human pose estimation using OpenPose”

  1. i got a error when i run the run_webcam.py command. i have installed all the packages and requirements. but i got this error. Can you help me with this error??
    File “run_webcam.py”, line 8, in
    from tf_pose.estimator import TfPoseEstimator
    File “C:\Users\User\tf-pose-estimation\tf_pose\__init__.py”, line 5, in
    from tf_pose.runner import infer, Estimator, get_estimator
    File “C:\Users\User\tf-pose-estimation\tf_pose\runner.py”, line 7, in
    from tf_pose import common
    File “C:\Users\User\tf-pose-estimation\tf_pose\common.py”, line 3, in
    import tensorflow as tf
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\__init__.py”, line 101, in
    from tensorflow_core import *
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\__init__.py”, line 46, in
    from . _api.v2 import compat
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py”, line 39, in
    from . import v1
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py”, line 32, in
    from . import compat
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\__init__.py”, line 39, in
    from . import v1
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\v1\__init__.py”, line 29, in
    from tensorflow._api.v2.compat.v1 import app
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py”, line 39, in
    from . import v1
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py”, line 32, in
    from . import compat
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\__init__.py”, line 39, in
    from . import v1
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\v1\__init__.py”, line 667, in
    from tensorflow_estimator.python.estimator.api._v1 import estimator
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_estimator\__init__.py”, line 10, in
    from tensorflow_estimator._api.v1 import estimator
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_estimator\_api\v1\estimator\__init__.py”, line 10, in
    from tensorflow_estimator._api.v1.estimator import experimental
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_estimator\_api\v1\estimator\experimental\__init__.py”, line 10, in
    from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py”, line 33, in
    from tensorflow_estimator.python.estimator import estimator
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py”, line 53, in
    from tensorflow_estimator.python.estimator import util as estimator_util
    File “C:\Users\User\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow_estimator\python\estimator\util.py”, line 75, in
    class _DatasetInitializerHook(tf.compat.v1.train.SessionRunHook):
    AttributeError: module ‘tensorflow’ has no attribute ‘compat’

    1. kaurprabhjot.kaur

      Hi,
      From a quick search online, most forums mentioning this error point to tensorflow 2.0. Please check the version of tensorflow being used. If you are running in a virtual environment, execute $ conda list as indicated in Step 6 under Installation.

Comments are closed.