Closed ccl-private closed 3 years ago
Hi! To use fast pose extractor, please follow prerequisites, mainly successfully run setup.py build_ext
and add result to PYTHONPATH
.
thanks~I forget that~
Hi,
I want to use the fast pose extractor in ROS, I successfully built the setup.py and add the result to PYTHONPATH. when I run sys.path, it is able to show the path '/home/aegis/catkin_ws/src/pose_estimation/src/pose_estimation/pose_extractor/build'
I could "import pose_extractor" successfully, but it fails when "from pose_extractor import extract_poses".
Does that mean C++ library was not imported to python interface?
Thanks!!
Hi, do you have pose_extractor.so
inside pose_extractor/build
folder? If so, what is the output of (should be something like 00000000000030c0
t_ZL13extract_posesP7_objectS0_
):
nm pose_extractor/build/pose_extractor.so | grep extract_poses
I have just exported to PYTHONPATH and demo works (got +10 FPS):
~/lightweight-human-pose-estimation-3d-demo.pytorch$ export PYTHONPATH=./pose_extractor/build/:$PYTHONPATH
~/lightweight-human-pose-estimation-3d-demo.pytorch$ python demo.py -m ~/Downloads/human-pose-estimation-3d.pth --video 0
Hi, yes I have pose_extractor.so inside, the output shows: 00000000000032a8 t _ZL13extract_posesP7objectS0
Originally the demo also works on me. When I apply into ROS, I need to recompile demo.python with catkin make. I think I could not access this build folder in my catkin workspace even if it already in my python environment. What is the mechanism to link the .so file?
It looks like things work in a different way in ROS, you can check this tutorial, it has steps to wrap C++ function under ROS to call in Python. Or may be some other recipes will work (I do not have a ROS to check).
Hi Daniil, it works now. Thanks!
Great! Can you please tell what was helped or may be attach a diff with changes for the future readers (and me :), it is really interesting how code should be transformed for ROS)?
Sure, my pleasure!
I referred this tutorial. https://roboticsbackend.com/ros-import-python-module-from-another-package/ I first build the fast extraction C++ wrapper pose_extractor, then import the python modules into ROS.
My package is built as follows:
pose_estimation/ └── src └── pose_estimation ├── __init__.py ├── data ├── models ├── modules ├── setup.py (for pose_extractor) └── pose_extractor ├── CMakeLists.txt ├── package.xml ├── setup.py (for python import) └── demo.py
With such set up of my package, "pose_estimation" need to be added as a prefix when importing the packages. For example: from pose_estimation.modules.input_reader import VideoReader, ImageReader
Extra attention is needed when importing pose_extractor (the fast version)
Hope it helps.
Many thanks for the clarifications!
how to load fast pose extraction?