Unable to integrate ROS and OpenCV
Hi,
Please could someone help me? I am new to ROS, have done all the basic ROS tutorials, but still I am stuck at this.
To be able to convert ROS image topics into OpenCV images and vice versa, I am working on the tutorial: http://wiki.ros.org/cv_bridge/Tutoria... Specifically, I am trying to implement "An example ROS node" section from the tutorial.
However, while trying to catkin_make after adding the .cpp file (see my step 5 below), the following error is coming:
CMakeFiles/image_converter.dir/src/image_converter.cpp.o: In function `ImageConverter::imageCb(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)':
image_converter.cpp:(.text._ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE[_ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE]+0xbd): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
image_converter.cpp:(.text._ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE[_ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE]+0xc5): undefined reference to `cv::String::deallocate()'
image_converter.cpp:(.text._ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE[_ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE]+0x1ed): undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
image_converter.cpp:(.text._ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE[_ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE]+0x207): undefined reference to `cv::String::allocate(unsigned long)'
image_converter.cpp:(.text._ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE[_ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE]+0x369): undefined reference to `cv::String::deallocate()'
CMakeFiles/image_converter.dir/src/image_converter.cpp.o: In function `ImageConverter::~ImageConverter()':
image_converter.cpp:(.text._ZN14ImageConverterD2Ev[_ZN14ImageConverterD5Ev]+0x31): undefined reference to `cv::destroyWindow(cv::String const&)'
image_converter.cpp:(.text._ZN14ImageConverterD2Ev[_ZN14ImageConverterD5Ev]+0x39): undefined reference to `cv::String::deallocate()'
image_converter.cpp:(.text._ZN14ImageConverterD2Ev[_ZN14ImageConverterD5Ev]+0x9f): undefined reference to `cv::String::allocate(unsigned long)'
image_converter.cpp:(.text._ZN14ImageConverterD2Ev[_ZN14ImageConverterD5Ev]+0x164): undefined reference to `cv::String::deallocate()'
CMakeFiles/image_converter.dir/src/image_converter.cpp.o: In function `ImageConverter::ImageConverter()':
image_converter.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x705): undefined reference to `cv::namedWindow(cv::String const&, int)'
image_converter.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x70d): undefined reference to `cv::String::deallocate()'
image_converter.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x797): undefined reference to `cv::String::allocate(unsigned long)'
image_converter.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0xccf): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
These are the steps followed by me:
1) catkin_create_pkg bridge_cv sensor_msgs cv_bridge roscpp std_msgs image_transport
2) source /opt/ros/indigo/setup.bash
3) catkin_make
4) source ~/catkin_ws/devel/setup.bash
5) Create an im_converter.cpp file in /src folder of my package and add to it the the code given in the tutorial inside the "An example ROS node" section. (Please see the code in the tutorial. I exact copied from it. I am not writing the code here to keep my post shorter.)(http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages).
6) Add the following lines at the end of CMakeLists.txt:
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(image_converter src/image_converter.cpp)
target_link_libraries(image_converter ${catkin_LIBRARIES})
add_dependencies(image_converter image_converter_generate_messages_cpp)
7) catkin_make
8) rosrun bridge_cv image_converter
Hi! I'm having this exact same error. If you've solved it, could you post your solution? Thanks!
Hi I'm having a very similar problem, did you got any solution for it? Thanks