Cannot Converting between ROS images and OpenCV images - Python

asked 2018-10-06 22:16:37 -0500

ToanJunifer gravatar image

updated 2018-10-06 22:19:46 -0500

Hi,

My name is Junifer. And I am a newbie. I am going to learn ROS and OpenCV. And I trying to convert ROS Image to OpenCV Image with Python language. But when i make follow the guide, it is not working. The guide link: http://wiki.ros.org/cv_bridge/Tutoria...

After make follow the guide. I add a file name ros_1_node.py in catkin_ws/package_name/src, and of course have code inside as the guide. Then i edit the CMakeList:

find_package(catkin REQUIRED COMPONENTS cv_bridge rospy sensor_msgs std_msgs )

find_package( OpenCV REQUIRED )

include_directories( ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )

add_executable(${PROJECT_NAME}_node src/ros_1_node.py)

target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} )

But when i build it error:

(.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status

make[2]: * [/home/junifer/catkin_ws/devel/lib/ros_1/ros_1_node] Error 1

make[1]: * [ros_1/CMakeFiles/ros_1_node.dir/all] Error 2 make: * [all] Error 2 Invoking "make -j8 -l8" failed

Any recommend for my case, thank you so much !

edit retag flag offensive close merge delete

Comments

2

It looks like you're trying to compile Python with a C++ compiler. You don't need to compile Python...

ahendrix gravatar image ahendrix  ( 2018-10-07 01:46:33 -0500 )edit

Hi Ahendrix, thank for your response. So what do i need to do now ? Can you show me, what step i make wrong ?

ToanJunifer gravatar image ToanJunifer  ( 2018-10-07 03:13:41 -0500 )edit

i was edit again the CMakeList:

find_package(catkin REQUIRED COMPONENTS cv_bridge rospy sensor_msgs std_msgs )

find_package( OpenCV REQUIRED )

include_directories( ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )
ToanJunifer gravatar image ToanJunifer  ( 2018-10-07 03:46:44 -0500 )edit

Then I build successfully. Then:

$ roscore

$ rosrun ros_1 ros_1.py

but i show another error.

File "/home/junifer/catkin_ws/src/cv_bridge_python/src/cv_bridge_python.py", line 5, in <module> roslib.load_manifest('/catkin_ws/src/cv_bridge_python/src/package.xml')

i dont know manifest file?

ToanJunifer gravatar image ToanJunifer  ( 2018-10-07 03:49:29 -0500 )edit

File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py",line 203,in get_path raise ResourceNotFound(name, ros_paths=self._ros_paths) rospkg.common.ResourceNotFound:/catkin_ws/src/cv_bridge_python/src/package.xml

ROS path [0]=/opt/ros/indigo/share/ros

ROS path [1]=/home/junifer/catkin_ws/src

ToanJunifer gravatar image ToanJunifer  ( 2018-10-07 03:51:04 -0500 )edit

And I am using python 3.4 to binding with OpenCV not Python 2.7.

My computer running on Unbutu 14.04 Indigo and install with full option in ROS, to make sure opencv-contrib and opencv-python was install.

So may you give me any advise ?

Thank you so much !

ToanJunifer gravatar image ToanJunifer  ( 2018-10-07 03:54:02 -0500 )edit

If you open a new terminal and run "import cv2" is it imported successfully?

pedro_bb72 gravatar image pedro_bb72  ( 2019-04-11 02:00:11 -0500 )edit