Robotics StackExchange | Archived questions

Cannot Converting between ROS images and OpenCV images - Python

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/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython

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

findpackage(catkin REQUIRED COMPONENTS cvbridge rospy sensormsgs stdmsgs )

find_package( OpenCV REQUIRED )

includedirectories( ${catkinINCLUDEDIRS} ${OpenCVINCLUDE_DIRS} )

addexecutable(${PROJECTNAME}node src/ros1_node.py)

targetlinklibraries(${PROJECTNAME}node ${catkinLIBRARIES} ${OpenCVLIBRARIES} )

But when i build it error:

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

make[2]: *** [/home/junifer/catkinws/devel/lib/ros1/ros1node] Error 1

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

Any recommend for my case, thank you so much !

Asked by ToanJunifer on 2018-10-06 22:16:37 UTC

Comments

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

Asked by ahendrix on 2018-10-07 01:46:33 UTC

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

Asked by ToanJunifer on 2018-10-07 03:13:41 UTC

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} )

Asked by ToanJunifer on 2018-10-07 03:46:44 UTC

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 roslib.load_manifest('/catkin_ws/src/cv_bridge_python/src/package.xml')

i dont know manifest file?

Asked by ToanJunifer on 2018-10-07 03:49:29 UTC

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

Asked by ToanJunifer on 2018-10-07 03:51:04 UTC

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 !

Asked by ToanJunifer on 2018-10-07 03:54:02 UTC

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

Asked by pedro_bb72 on 2019-04-11 02:00:11 UTC

Answers