forked from CMU-Perceptual-Computing-Lab/openpose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python fix (CMU-Perceptual-Computing-Lab#674)
* Bug fixes for Python Windows and Cmake * Update to python doc * Added BUILD_DLL
- Loading branch information
1 parent
62eebd6
commit c8e3879
Showing
10 changed files
with
712 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
# From Python | ||
# It requires OpenCV installed for Python | ||
import sys | ||
import cv2 | ||
import os | ||
from sys import platform | ||
|
||
# Remember to add your installation path here | ||
# Option a | ||
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
sys.path.append('../../python') | ||
from openpose import * | ||
if platform == "win32": sys.path.append(dir_path + '/../../python/openpose/'); | ||
else: sys.path.append('../../python'); | ||
# Option b | ||
# 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') | ||
|
||
# Parameters for OpenPose. Take a look at C++ OpenPose example for meaning of components. Ensure all below are filled | ||
from openpose import * | ||
params = dict() | ||
params["logging_level"] = 3 | ||
params["output_resolution"] = "-1x-1" | ||
params["net_resolution"] = "-1x368" | ||
params["model_pose"] = "COCO" | ||
params["model_pose"] = "BODY_25" | ||
params["alpha_pose"] = 0.6 | ||
params["scale_gap"] = 0.3 | ||
params["scale_number"] = 1 | ||
params["render_threshold"] = 0.05 | ||
# If GPU version is built, and multiple GPUs are available, set the ID here | ||
params["num_gpu_start"] = 0 | ||
params["disable_blending"] = False | ||
# Ensure you point to the correct path where models are located | ||
params["default_model_folder"] = dir_path + "/../../../models/" | ||
# Construct OpenPose object allocates GPU memory | ||
openpose = OpenPose(params) | ||
img = cv2.imread(dir_path + "/../../../examples/media/COCO_val2014_000000000192.jpg") | ||
arr, output_image = openpose.forward(img, True) | ||
print arr | ||
|
||
while 1: | ||
# Read new image | ||
img = cv2.imread("image.png") | ||
# Output keypoints and the image with the human skeleton blended on it | ||
keypoints, output_image = openpose.forward(img, True) | ||
# Print the human pose keypoints, i.e., a [#people x #keypoints x 3]-dimensional numpy object with the keypoints of all the people on that image | ||
print(keypoints) | ||
# Display the image | ||
cv2.imshow("output", output_image) | ||
cv2.waitKey(15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
add_subdirectory(openpose) | ||
|
||
add_subdirectory(openpose) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
set(PYTHON_FILES | ||
openpose.py | ||
__init__.py | ||
_openpose.cpp) | ||
|
||
add_library(_openpose SHARED ${PYTHON_FILES}) | ||
target_link_libraries(_openpose openpose ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} ${MKL_LIBS} ${GLUT_LIBRARY} ${SPINNAKER_LIB} ${OpenCL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) | ||
SET_TARGET_PROPERTIES(_openpose PROPERTIES PREFIX "") | ||
configure_file(openpose.py openpose.py) | ||
configure_file(__init__.py __init__.py) | ||
|
||
#install(TARGETS _openpose DESTINATION python) | ||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION python/openpose FILES_MATCHING PATTERN "*.so") | ||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION python/openpose FILES_MATCHING PATTERN "*.py") | ||
set(PYTHON_FILES | ||
openpose.py | ||
__init__.py | ||
_openpose.cpp) | ||
|
||
add_library(_openpose SHARED ${PYTHON_FILES}) | ||
target_link_libraries(_openpose openpose ${OpenPose_3rdparty_libraries}) | ||
SET_TARGET_PROPERTIES(_openpose PROPERTIES PREFIX "") | ||
configure_file(openpose.py openpose.py) | ||
configure_file(__init__.py __init__.py) | ||
|
||
#install(TARGETS _openpose DESTINATION python) | ||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION python/openpose FILES_MATCHING PATTERN "*.so") | ||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION python/openpose FILES_MATCHING PATTERN "*.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from openpose import * | ||
from openpose import * |
Oops, something went wrong.