From 853ccb1e120547355f5fed3609dfaeecd62bc7cc Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Thu, 24 Jan 2019 00:43:13 -0500 Subject: [PATCH] Improved Python doc --- README.md | 32 +++--- doc/installation.md | 7 -- doc/modules/python_module.md | 61 ++++++----- .../3_keypoints_from_images.py | 79 ++++++++++++++ .../4_keypoints_from_images_multi_gpu.py | 103 ++++++++++++++++++ .../5_heatmaps_from_image.py | 88 +++++++++++++++ examples/tutorial_api_python/CMakeLists.txt | 6 +- 7 files changed, 326 insertions(+), 50 deletions(-) create mode 100644 examples/tutorial_api_python/3_keypoints_from_images.py create mode 100644 examples/tutorial_api_python/4_keypoints_from_images_multi_gpu.py create mode 100644 examples/tutorial_api_python/5_heatmaps_from_image.py diff --git a/README.md b/README.md index fc0ff93a..e9ed60e9 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,17 @@ Note: Currently using [travis-matrix-badges](https://github.com/bjfish/travis-matrix-badges) vs. traditional [![Build Status](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose.svg?branch=master)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) --> -[OpenPose](https://github.com/CMU-Perceptual-Computing-Lab/openpose) represents the **first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints (in total 135 keypoints) on single images**. +[**OpenPose**](https://github.com/CMU-Perceptual-Computing-Lab/openpose) represents the **first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints (in total 135 keypoints) on single images**. + +It is **authored by [Gines Hidalgo](https://www.gineshidalgo.com), [Zhe Cao](https://people.eecs.berkeley.edu/~zhecao), [Tomas Simon](http://www.cs.cmu.edu/~tsimon), [Shih-En Wei](https://scholar.google.com/citations?user=sFQD3k4AAAAJ&hl=en), [Hanbyul Joo](https://jhugestar.github.io), and [Yaser Sheikh](http://www.cs.cmu.edu/~yaser)**. Currently, it is being **maintained by [Gines Hidalgo](https://www.gineshidalgo.com) and [Yaadhav Raaj](https://www.linkedin.com/in/yaadhavraaj)**. In addition, OpenPose would not be possible without the [**CMU Panoptic Studio dataset**](http://domedb.perception.cs.cmu.edu). We would also like to thank all the people who helped OpenPose in any way. The main contributors are listed in [doc/contributors.md](doc/contributors.md). + + +

+
+ Authors Gines Hidalgo (left) and Hanbyul Joo (right) in front of the CMU Panoptic Studio

## Features @@ -40,6 +47,7 @@ Note: Currently using [travis-matrix-badges](https://github.com/bjfish/travis-ma - [**Python API**](doc/modules/python_module.md). - [**Unity Plugin**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_unity_plugin). - CUDA (Nvidia GPU), OpenCL (AMD GPU), and CPU versions. + - Training code included in the [**original CVPR 2017 GitHub repository**](https://github.com/ZheC/Multi-Person-Pose-Estimation). @@ -60,17 +68,23 @@ For further details, check [all released features](doc/released_features.md) and ### Body and Foot Estimation

+
+ Testing the Crazy Uptown Funk flashmob in Sydney video sequence with OpenPose

### 3-D Reconstruction Module (Body, Foot, Face, and Hands)

+
+ Testing the 3D Reconstruction Module of OpenPose

### Body, Foot, Face, and Hands Estimation

+
+ Authors Gines Hidalgo (left image) and Tomas Simon (right image) testing OpenPose

### Unity Plugin @@ -78,6 +92,8 @@ For further details, check [all released features](doc/released_features.md) and +
+ Tianyi Zhao and Gines Hidalgo testing their OpenPose Unity Plugin

### Runtime Analysis @@ -99,9 +115,8 @@ This analysis was performed using the same images for each algorithm and a batch 7. [Speeding Up OpenPose and Benchmark](#speeding-up-openpose-and-benchmark) 8. [Foot Dataset](#foot-dataset) 9. [Send Us Failure Cases and Feedback!](#send-us-failure-cases-and-feedback) -10. [Authors and Contributors](#authors-and-contributors) -11. [Citation](#citation) -12. [License](#license) +10. [Citation](#citation) +11. [License](#license) @@ -166,15 +181,6 @@ Just comment on GitHub or make a pull request and we will answer as soon as poss -## Authors and Contributors -OpenPose is authored by [Gines Hidalgo](https://www.gineshidalgo.com/), [Zhe Cao](http://www.andrew.cmu.edu/user/zhecao), [Tomas Simon](http://www.cs.cmu.edu/~tsimon), [Shih-En Wei](https://scholar.google.com/citations?user=sFQD3k4AAAAJ&hl=en), [Hanbyul Joo](http://www.cs.cmu.edu/~hanbyulj), and [Yaser Sheikh](http://www.cs.cmu.edu/~yaser). Currently, it is being maintained by [Gines Hidalgo](https://www.gineshidalgo.com/) and [Yaadhav Raaj](https://www.linkedin.com/in/yaadhavraaj). The [original CVPR 2017 repo](https://github.com/ZheC/Multi-Person-Pose-Estimation) includes Matlab and Python versions, as well as the training code. The body pose estimation work is based on [the original ECCV 2016 demo](https://github.com/CMU-Perceptual-Computing-Lab/caffe_rtpose). - -In addition, OpenPose would not be possible without the [CMU Panoptic Studio dataset](http://domedb.perception.cs.cmu.edu/). - -We would also like to thank all the people who helped OpenPose in any way. The main contributors are listed in [doc/contributors.md](doc/contributors.md). - - - ## Citation Please cite these papers in your publications if it helps your research (the face keypoint detector was trained using the procedure described in [Simon et al. 2017] for hands): diff --git a/doc/installation.md b/doc/installation.md index ea0a9bed..ef7734e7 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -290,13 +290,6 @@ Note: Check the differences between these models in [doc/faq.md#difference-betwe #### Python API To install the Python API, ensure that the `BUILD_PYTHON` flag is turned on while running CMake GUI and follow the standard installation steps. After the installation, check [doc/modules/python_module.md](./modules/python_module.md) for further details. -Note: If you are in Windows, and you fail to install the required third party Python libraries, it might print an error similar to: `Exception: Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?`. From GitHub issue #941: -``` -I had a similar issue with Visual Studio (VS). I am pretty sure that the issue is that while you are compiling OpenPose in VS, it tries to import cv2 (python-opencv) and it fails. So make sure that if you open cmd.exe and run python, you can actually import cv2 without errors. I could not, but I had cv2 installed in a IPython environment (Anaconda), so I activated that environment, and then ran (change this to adapt it to your VS version and location of OpenPose.sln): - -C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe C:\path\to\OpenPose.sln -``` - #### CPU Version diff --git a/doc/modules/python_module.md b/doc/modules/python_module.md index e0dc8a20..7aa3df6b 100644 --- a/doc/modules/python_module.md +++ b/doc/modules/python_module.md @@ -6,6 +6,7 @@ 3. [Installation](#installation) 4. [Testing](#testing) 5. [Exporting Python OpenPose](#exporting-python-openpose) +6. [Common Issues](#common-issues) @@ -15,31 +16,30 @@ This module exposes a Python API for OpenPose. It is effectively a wrapper that ## Compatibility -The OpenPose Python module is compatible with both Python 2 and Python 3. In addition, it will also run in all OpenPose compatible operating systems. It uses [Pybind11](https://github.com/pybind/pybind11) for mapping between C++ and Python datatypes. +The OpenPose Python module is compatible with both Python 2 and Python 3 (default and recommended). In addition, it will also run in all OpenPose compatible operating systems. It uses [Pybind11](https://github.com/pybind/pybind11) for mapping between C++ and Python datatypes. -To compile, enable `BUILD_PYTHON` in cmake. Pybind selects the latest version of Python by default (Python 3). To use Python 2, change `PYTHON_EXECUTABLE` and `PYTHON_LIBRARY` flags in cmake-gui to your desired python version. +To compile, enable `BUILD_PYTHON` in CMake-gui. In Windows, make sure you compile the whole solution (clicking the green play button does not compile the whole solution!). You can do that by right-click on the OpenPose project solution, and clicking in `Build solution`. -Ubuntu Eg: +Pybind selects the latest version of Python by default (Python 3). To use Python 2, change `PYTHON_EXECUTABLE` and `PYTHON_LIBRARY` flags in CMake-gui to your desired Python version. ``` -PYTHON_EXECUTABLE=/usr/bin/python2.7 +# Ubuntu +PYTHON_EXECUTABLE=/usr/bin/python2.7 PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7m.so ``` -Mac OSX Eg: - ``` -PYTHON_EXECUTABLE=/usr/local/bin/python2.7 -PYTHON_LIBRARY=/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7m.dylib +# Mac OSX +PYTHON_EXECUTABLE=/usr/local/bin/python2.7 +PYTHON_LIBRARY=/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7m.dylib ``` -Windows Eg: - ``` +:: Windows PYTHON_EXECUTABLE=C:/Users/user/AppData/Local/Programs/Python/Python27/python.exe ``` -If run via the command line, you may need to run cmake twice in order for this change to take effect. +If run via the command line, you may need to run cmake twice in order for this change to take effect. @@ -49,12 +49,13 @@ Check [doc/installation.md#python-module](../installation.md#python-api) for ins The Python API requires python-dev, Numpy (for array management), and OpenCV (for image loading). They can be installed via: ``` +# Python 3 (default and recommended) +sudo apt-get install python3-dev +sudo pip3 install numpy opencv-python + # Python 2 sudo apt-get install python-dev sudo pip install numpy opencv-python -# Python 3 (recommended) -sudo apt-get install python3-dev -sudo pip3 install numpy opencv-python ``` @@ -66,15 +67,15 @@ All the Python examples from the Tutorial API Python module can be found in `bui # From command line cd build/examples/tutorial_api_python +# Python 3 (default version) +python3 1_body_from_image.py +python3 2_whole_body_from_image.py +# python3 [any_other_example.py] + # Python 2 python2 1_body_from_image.py python2 2_whole_body_from_image.py # python2 [any_other_example.py] - -# Python 3 (recommended) -python3 1_body_from_image.py -python3 2_whole_body_from_image.py -# python3 [any_other_example.py] ``` @@ -96,10 +97,10 @@ Windows: os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../{x86/x64}/Release;' + dir_path + '/../../bin;' ``` - -#### Common Issues -The error in general is that openpose cannot be found. Ensure first that `BUILD_PYTHON` flag is set to ON. If the error persists, check the following: + +## Common Issues +The error in general is that PyOpenPose cannot be found (an error similar to: `ImportError: cannot import name pyopenpose`). Ensure first that `BUILD_PYTHON` flag is set to ON. If the error persists, check the following: In the script you are running, check for the following line, and run the following command in the same location as where the file is @@ -118,11 +119,18 @@ pyopenpose.cpython-35m-x86_64-linux-gnu.so pyopenpose.so ``` -If you do not have any one of those, you may not have compiled openpose successfully, or you may be running the examples, not from the build folder but the source folder. If you have the first one, you have compiled pyopenpose for python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands. +If you do not have any one of those, you may not have compiled openpose successfully, or you may be running the examples, not from the build folder but the source folder. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with `python3`, and vice versa for the 2nd one. Follow the testing examples above for exact commands. **Windows:** -Python for Openpose needs to be compiled in Release mode for now. This can be done in [Visual Studio](https://cdn.stereolabs.com/docs/getting-started/images/release_mode.png). Once that is done check this line: +Problem 1: If you are in Windows, and you fail to install the required third party Python libraries, it might print an error similar to: `Exception: Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?`. From GitHub issue #941: +``` +I had a similar issue with Visual Studio (VS). I am pretty sure that the issue is that while you are compiling OpenPose in VS, it tries to import cv2 (python-opencv) and it fails. So make sure that if you open cmd.exe and run Python, you can actually import cv2 without errors. I could not, but I had cv2 installed in a IPython environment (Anaconda), so I activated that environment, and then ran (change this to adapt it to your VS version and location of OpenPose.sln): + +C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe C:\path\to\OpenPose.sln +``` + +Problem 2: Python for Openpose needs to be compiled in Release mode for now. This can be done in [Visual Studio](https://cdn.stereolabs.com/docs/getting-started/images/release_mode.png). Once that is done check this line: `sys.path.append(dir_path + '/../../python/openpose/Release');` @@ -137,7 +145,7 @@ pyopenpose.cp36-win_amd64.pyd pyopenpose.pyd ``` -If such a folder does not exist, you need to compile in Release mode as seen above. If you have the first one, you have compiled pyopenpose for python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands. If that still does not work, check this line: +If such a folder does not exist, you need to compile in Release mode as seen above. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with `python3`, and vice versa for the 2nd one. Follow the testing examples above for exact commands. If that still does not work, check this line: `os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;'` @@ -146,5 +154,4 @@ dir ../../x64/Release dir ../../bin ``` -Ensure that both of these paths exist, as pyopenpose needs to reference those libraries. If they don't exist, change the path so that they point to the correct location in your build folder - +Ensure that both of these paths exist, as PyOpenPose needs to reference those libraries. If they don't exist, change the path so that they point to the correct location in your build folder. diff --git a/examples/tutorial_api_python/3_keypoints_from_images.py b/examples/tutorial_api_python/3_keypoints_from_images.py new file mode 100644 index 00000000..b2c4573b --- /dev/null +++ b/examples/tutorial_api_python/3_keypoints_from_images.py @@ -0,0 +1,79 @@ +# From Python +# It requires OpenCV installed for Python +import sys +import cv2 +import os +from sys import platform +import argparse +import time + +# Import Openpose (Windows/Ubuntu/OSX) +dir_path = os.path.dirname(os.path.realpath(__file__)) +try: + # Windows Import + if platform == "win32": + # Change these variables to point to the correct folder (Release/x64 etc.) + sys.path.append(dir_path + '/../../python/openpose/Release'); + os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;' + import pyopenpose as op + else: + # Change these variables to point to the correct folder (Release/x64 etc.) + sys.path.append('../../python'); + # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. + # sys.path.append('/usr/local/python') + from openpose import pyopenpose as op +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e + +# Flags +parser = argparse.ArgumentParser() +parser.add_argument("--image_dir", default="../../../examples/media/", help="Process a directory of images. Read all standard formats (jpg, png, bmp, etc.).") +parser.add_argument("--no_display", default=False, help="Enable to disable the visual display.") +args = parser.parse_known_args() + +# Custom Params (refer to include/openpose/flags.hpp for more parameters) +params = dict() +params["model_folder"] = "../../../models/" + +# Add others in path? +for i in range(0, len(args[1])): + curr_item = args[1][i] + if i != len(args[1])-1: next_item = args[1][i+1] + else: next_item = "1" + if "--" in curr_item and "--" in next_item: + key = curr_item.replace('-','') + if key not in params: params[key] = "1" + elif "--" in curr_item and "--" not in next_item: + key = curr_item.replace('-','') + if key not in params: params[key] = next_item + +# Construct it from system arguments +# op.init_argv(args[1]) +# oppython = op.OpenposePython() + +# Starting OpenPose +opWrapper = op.WrapperPython() +opWrapper.configure(params) +opWrapper.start() + +# Read frames on directory +imagePaths = op.get_images_on_directory(args[0].image_dir); +start = time.time() + +# Process and display images +for imagePath in imagePaths: + datum = op.Datum() + imageToProcess = cv2.imread(imagePath) + datum.cvInputData = imageToProcess + opWrapper.emplaceAndPop([datum]) + + print("Body keypoints: \n" + str(datum.poseKeypoints)) + + if not args[0].no_display: + cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData) + key = cv2.waitKey(15) + if key == 27: break + +end = time.time() +print("OpenPose demo successfully finished. Total time: " + str(end - start) + " seconds") diff --git a/examples/tutorial_api_python/4_keypoints_from_images_multi_gpu.py b/examples/tutorial_api_python/4_keypoints_from_images_multi_gpu.py new file mode 100644 index 00000000..43defed0 --- /dev/null +++ b/examples/tutorial_api_python/4_keypoints_from_images_multi_gpu.py @@ -0,0 +1,103 @@ +# From Python +# It requires OpenCV installed for Python +import sys +import cv2 +import os +from sys import platform +import argparse +import time + +# Import Openpose (Windows/Ubuntu/OSX) +dir_path = os.path.dirname(os.path.realpath(__file__)) +try: + # Windows Import + if platform == "win32": + # Change these variables to point to the correct folder (Release/x64 etc.) + sys.path.append(dir_path + '/../../python/openpose/Release'); + os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;' + import pyopenpose as op + else: + # Change these variables to point to the correct folder (Release/x64 etc.) + sys.path.append('../../python'); + # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. + # sys.path.append('/usr/local/python') + from openpose import pyopenpose as op +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e + +# Flags +parser = argparse.ArgumentParser() +parser.add_argument("--image_dir", default="../../../examples/media/", help="Process a directory of images. Read all standard formats (jpg, png, bmp, etc.).") +parser.add_argument("--no_display", default=False, help="Enable to disable the visual display.") +args = parser.parse_known_args() + +# Custom Params (refer to include/openpose/flags.hpp for more parameters) +params = dict() +params["model_folder"] = "../../../models/" + +# Add others in path? +for i in range(0, len(args[1])): + curr_item = args[1][i] + if i != len(args[1])-1: next_item = args[1][i+1] + else: next_item = "1" + if "--" in curr_item and "--" in next_item: + key = curr_item.replace('-','') + if key not in params: params[key] = "1" + elif "--" in curr_item and "--" not in next_item: + key = curr_item.replace('-','') + if key not in params: params[key] = next_item + +# Construct it from system arguments +# op.init_argv(args[1]) +# oppython = op.OpenposePython() + +# Starting OpenPose +opWrapper = op.WrapperPython() +opWrapper.configure(params) +opWrapper.start() + +# Read frames on directory +imagePaths = op.get_images_on_directory(args[0].image_dir); + +# Read number of GPUs in your system +numberGPUs = op.get_gpu_number() +start = time.time() + +# Process and display images +for imageBaseId in range(0, len(imagePaths), numberGPUs): + + # Create datums + datums = [] + + # Read and push images into OpenPose wrapper + for gpuId in range(0, numberGPUs): + + imageId = imageBaseId+gpuId + if imageId < len(imagePaths): + + imagePath = imagePaths[imageBaseId+gpuId] + datum = op.Datum() + imageToProcess = cv2.imread(imagePath) + datum.cvInputData = imageToProcess + datums.append(datum) + opWrapper.waitAndEmplace([datums[-1]]) + + # Retrieve processed results from OpenPose wrapper + for gpuId in range(0, numberGPUs): + + imageId = imageBaseId+gpuId + if imageId < len(imagePaths): + + datum = datums[gpuId] + opWrapper.waitAndPop([datum]) + + print("Body keypoints: \n" + str(datum.poseKeypoints)) + + if not args[0].no_display: + cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData) + key = cv2.waitKey(15) + if key == 27: break + +end = time.time() +print("OpenPose demo successfully finished. Total time: " + str(end - start) + " seconds") diff --git a/examples/tutorial_api_python/5_heatmaps_from_image.py b/examples/tutorial_api_python/5_heatmaps_from_image.py new file mode 100644 index 00000000..7a47331e --- /dev/null +++ b/examples/tutorial_api_python/5_heatmaps_from_image.py @@ -0,0 +1,88 @@ +# From Python +# It requires OpenCV installed for Python +import sys +import cv2 +import os +from sys import platform +import argparse +import numpy as np + +# Import Openpose (Windows/Ubuntu/OSX) +dir_path = os.path.dirname(os.path.realpath(__file__)) +try: + # Windows Import + if platform == "win32": + # Change these variables to point to the correct folder (Release/x64 etc.) + sys.path.append(dir_path + '/../../python/openpose/Release'); + os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;' + import pyopenpose as op + else: + # Change these variables to point to the correct folder (Release/x64 etc.) + sys.path.append('../../python'); + # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. + # sys.path.append('/usr/local/python') + from openpose import pyopenpose as op +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e + +# Flags +parser = argparse.ArgumentParser() +parser.add_argument("--image_path", default="../../../examples/media/COCO_val2014_000000000192.jpg", help="Process an image. Read all standard formats (jpg, png, bmp, etc.).") +args = parser.parse_known_args() + +# Custom Params (refer to include/openpose/flags.hpp for more parameters) +params = dict() +params["model_folder"] = "../../../models/" +params["heatmaps_add_parts"] = True +params["heatmaps_add_bkg"] = True +params["heatmaps_add_PAFs"] = True +params["heatmaps_scale"] = 2 + +# Add others in path? +for i in range(0, len(args[1])): + curr_item = args[1][i] + if i != len(args[1])-1: next_item = args[1][i+1] + else: next_item = "1" + if "--" in curr_item and "--" in next_item: + key = curr_item.replace('-','') + if key not in params: params[key] = "1" + elif "--" in curr_item and "--" not in next_item: + key = curr_item.replace('-','') + if key not in params: params[key] = next_item + +# Construct it from system arguments +# op.init_argv(args[1]) +# oppython = op.OpenposePython() + +# Starting OpenPose +opWrapper = op.WrapperPython() +opWrapper.configure(params) +opWrapper.start() + +# Process Image +datum = op.Datum() +imageToProcess = cv2.imread(args[0].image_path) +datum.cvInputData = imageToProcess +opWrapper.emplaceAndPop([datum]) + +# Process outputs +outputImageF = (datum.inputNetData[0].copy())[0,:,:,:] + 0.5 +outputImageF = cv2.merge([outputImageF[0,:,:], outputImageF[1,:,:], outputImageF[2,:,:]]) +outputImageF = (outputImageF*255.).astype(dtype='uint8') +heatmaps = datum.poseHeatMaps.copy() +heatmaps = (heatmaps).astype(dtype='uint8') + +# Display Image +counter = 0 +while 1: + num_maps = heatmaps.shape[0] + heatmap = heatmaps[counter, :, :].copy() + heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET) + combined = cv2.addWeighted(outputImageF, 0.5, heatmap, 0.5, 0) + cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", combined) + key = cv2.waitKey(-1) + if key == 27: + break + counter += 1 + counter = counter % num_maps diff --git a/examples/tutorial_api_python/CMakeLists.txt b/examples/tutorial_api_python/CMakeLists.txt index 3a60581b..8b0f6cdb 100644 --- a/examples/tutorial_api_python/CMakeLists.txt +++ b/examples/tutorial_api_python/CMakeLists.txt @@ -2,8 +2,8 @@ configure_file(openpose_python.py openpose_python.py) configure_file(1_body_from_image.py 1_body_from_image.py) configure_file(2_whole_body_from_image.py 2_whole_body_from_image.py) -configure_file(3_heatmaps_from_image.py 3_heatmaps_from_image.py) -configure_file(4_keypoints_from_images.py 4_keypoints_from_images.py) -configure_file(5_keypoints_from_images_multi_gpu.py 5_keypoints_from_images_multi_gpu.py) +configure_file(3_keypoints_from_images.py 3_keypoints_from_images.py) +configure_file(4_keypoints_from_images_multi_gpu.py 4_keypoints_from_images_multi_gpu.py) +configure_file(5_heatmaps_from_image.py 5_heatmaps_from_image.py) configure_file(6_face_from_image.py 6_face_from_image.py) configure_file(7_hand_from_image.py 7_hand_from_image.py) -- GitLab