Hello! I was trying to execute tfpose_ros in Ubuntu 18.04 LTS, Python 3.6 and ROS Melodic. I have few issues with it:
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)
From what I read on the internet, it is because 'PyInit_cv_bridge_boost' which is present in ROS library will not run on Python 3.
To fix it, I created a new catkin workspace by following these steps:
```{r, attr.output='style="max-height: 100px;"'}
python-catkin-tools is needed for catkin toolpython3-dev and python3-catkin-pkg-modules is needed to build cv_bridgepython3-numpy and python3-yaml is cv_bridge dependenciesros-kinetic-cv-bridge is needed to install a lot of cv_bridge deps. Probaply you already have it installed.sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge
mkdir catkin_workspace
cd catkin_workspace
catkin init
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
catkin config --install
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv
apt-cache show ros-kinetic-cv-bridge | grep Version
Version: 1.12.8-0xenial-20180416-143935-0800
cd src/vision_opencv/
git checkout 1.12.8
cd ../../
catkin build cv_bridge
source install/setup.bash --extend
Even though this helped me fix the 'PyInit_cv_bridge_boost' error, I got few more errors. The first one was 'Package name and basename mismatch' error. I fixed it by following #547 . This gave me another error
```{r, attr.output='style="max-height: 100px;"'}
Errors << tfpose_ros:install /home/linuxuser/catkin_workspace/logs/tfpose_ros/build.install.000.log
--2020-05-26 02:02:33-- http://download686.mediafire.com/x4qhgkd2kcug/qlzzr20mpocnpa3/graph_opt.pb
Resolving download686.mediafire.com (download686.mediafire.com)... 205.196.120.134
Connecting to download686.mediafire.com (download686.mediafire.com)|205.196.120.134|:80... connected.
HTTP request sent, awaiting response... 416 Range Not Satisfiable
The file is already fully retrieved; nothing to do.
file pafprocess.py (for module pafprocess) not found
error: package directory 'tf_pose_data' does not exist
CMake Error at catkin_generated/safe_execute_install.cmake:4 (message):
execute_process(/home/linuxuser/catkin_workspace/build/tfpose_ros/catkin_generated/python_distutils_install.sh)
returned error code
Call Stack (most recent call first):
cmake_install.cmake:132 (include)
make: *** [install] Error 1
cd /home/linuxuser/catkin_workspace/build/tfpose_ros; catkin build --get-env tfpose_ros | catkin env -si /usr/bin/make install; cd -
Does anyone know how to fix it? Is this the right way to execute tfpose_ros?
I was finally able to make it work. Here is my configuration:
I have typed this out for the above configuration. It might or might not work for other combinations of these packages. I would recommend you to try it in a virtual enviroment (preferably conda) because it will help you to roll back in case you make any mistake.
4. Now create a new directory in home and configure it for ROS
```{r, attr.output='style="max-height: 100px;"'}
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
echo "source devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
Please use catkin_make and not catkin build
These packages should be more than enough. If the build fails (later on when you build the code) because certain package is missing, then install it.
6. Now run these commands (make sure you are inside the catkin_ws folder)
```{r, attr.output='style="max-height: 100px;"'}
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ros-kinetic-video-stream-opencv
sudo apt-get install ros-kinetic-image-view
git clone https://github.com/ildoonet/ros-video-recorder.git src/
git clone https://github.com/ildoonet/tf-pose-estimation.git src/
pip install -U setuptools
Now go inside tf-pose-estimation directory and change few things
a) In package.xml, replace <version>0.1.0</version> with <version>0.1.1</version>
b) In setup.py, change name='tf-pose' to name='tfpose_ros' and package_dir={'tf_pose_data': 'models'} to package_dir={'tfpose_ros': 'models'}
c) Don't forget to build the C++ library for post processing
As I mentioned in the issue I raised, there is conflict in python2 and python3 packages. This is how you fix it
a) Rename cv2.so in /opt/ros/kinetic/lib/python2.7/dist-packages to cv2_renamed.so or anything so that it doesn't get imported. (This is nothing but OpenCV's shared object file for Python 2.7)
This will make sure that Python3's OpenCV is imported.
b) Next library is cv_bridge. This is now you fix this
```{r, attr.output='style="max-height: 100px;"'}
catkin init
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
catkin config --install
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv
apt-cache show ros-kinetic-cv-bridge | grep Version
Version: 1.12.8-0xenial-20180416-143935-0800
cd src/vision_opencv/
git checkout 1.12.8
cd ../../
catkin_make cv_bridge
catkin_make
If you encounter this error:
```{r, attr.output='style="max-height: 100px;"'}
CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: /usr/include
Could not find the following Boost libraries:
boost_python3
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)
It is because CMake tries to find libboost_python3.so library, but in ubuntu it is libboost_python-py35.so(/usr/lib/x86_64-linux-gnu/libboost_python-py35.so), so you should change line
```{r, attr.output='style="max-height: 100px;"'}
find_package(Boost REQUIRED python3)
```{r, attr.output='style="max-height: 100px;"'}
find_package(Boost REQUIRED python-py35)
in file src/vision_opencv/cv_bridge/CMakeLists.txt and rebuild package (i.e run catkin_make again)
```{r, attr.output='style="max-height: 100px;"'}
humans = e.inference(image, resize_to_default=(w > 0 and h > 0), upsample_size=args.resize_out_ratio)
Make sure that this is done in catkin_ws folder(really important!)
You might not be able to see the poses the first time you run it, because it will take some time for the model to load onto the memory. Quit it (Ctrl+C) once the model loads and re-run the program to see the correct output.
I hope this works for you!
P.S In case you make some mistake or you want to re-install ROS, then run these commands to remove ROS packages completely
```{r, attr.output='style="max-height: 100px;"'}
sudo apt-get remove ros-*
sudo apt-get remove ros-melodic-*
sudo apt-get autoremove
sudo rm -rf /etc/ros/
sudo apt update
Most helpful comment
I was finally able to make it work. Here is my configuration:
I have typed this out for the above configuration. It might or might not work for other combinations of these packages. I would recommend you to try it in a virtual enviroment (preferably conda) because it will help you to roll back in case you make any mistake.
```{r, attr.output='style="max-height: 100px;"'}
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep
sudo rosdep init
rosdep update
Please use
catkin_makeand notcatkin build```{r, attr.output='style="max-height: 100px;"'}
sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge
pip install catkin_pkg
pip install rospkg
pip3 install catkin_pkg
pip3 install empy
pip install empy
Now go inside tf-pose-estimation directory and change few things
a) In package.xml, replace
<version>0.1.0</version>with<version>0.1.1</version>b) In setup.py, change
name='tf-pose'toname='tfpose_ros'andpackage_dir={'tf_pose_data': 'models'}topackage_dir={'tfpose_ros': 'models'}c) Don't forget to build the C++ library for post processing
As I mentioned in the issue I raised, there is conflict in python2 and python3 packages. This is how you fix it
a) Rename
cv2.soin/opt/ros/kinetic/lib/python2.7/dist-packagestocv2_renamed.soor anything so that it doesn't get imported. (This is nothing but OpenCV's shared object file for Python 2.7)This will make sure that Python3's OpenCV is imported.
b) Next library is
cv_bridge. This is now you fix this```{r, attr.output='style="max-height: 100px;"'}
Initializing catkin workspace
catkin init
Instruct catkin to set cmake variables
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
catkin config --install
Clone cv_bridge src
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv
Find version of cv_bridge in your repository
apt-cache show ros-kinetic-cv-bridge | grep Version
Version: 1.12.8-0xenial-20180416-143935-0800
Checkout right version in git repo. In my case it was 1.12.8
cd src/vision_opencv/
git checkout 1.12.8
cd ../../
Build
catkin_make cv_bridge
Building all packages
catkin_make
It is because CMake tries to find
libboost_python3.solibrary, but in ubuntu it islibboost_python-py35.so(/usr/lib/x86_64-linux-gnu/libboost_python-py35.so), so you should change line```{r, attr.output='style="max-height: 100px;"'}
find_package(Boost REQUIRED python3)
in file
src/vision_opencv/cv_bridge/CMakeLists.txtand rebuild package (i.e run catkin_make again)```{r, attr.output='style="max-height: 100px;"'}
humans = e.inference(image)
```{r, attr.output='style="max-height: 100px;"'}
roslaunch tfpose_ros demo_video.launch