ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

You forgot to tell ros to "spin" in pub.cpp:

while (nh.ok()) 
 {
   pub.publish(ros_image);
   ros::spinOnce(); //Here is where the magic happens
   loop_rate.sleep();
 }

And I am not all that sure about your call to imread

cv::imread("/home/abi/Pictures/attachments/",CV_LOAD_IMAGE_COLOR);

You are passing a folder name instead of a path to an image. Should be something like

cv::imread("/home/abi/Pictures/attachments/someimage.jpg",CV_LOAD_IMAGE_COLOR);

You forgot to tell ros to "spin" in pub.cpp:

while (nh.ok()) 
 {
   pub.publish(ros_image);
   ros::spinOnce(); //Here is where the magic happens
   loop_rate.sleep();
 }

And I am not all that sure about your call to imread

cv::imread("/home/abi/Pictures/attachments/",CV_LOAD_IMAGE_COLOR);

You are passing a folder name instead of a path to an image. Should be something like

cv::imread("/home/abi/Pictures/attachments/someimage.jpg",CV_LOAD_IMAGE_COLOR);

[UPDATE]

Also, you are publishing the topic /static_image/compressed but subscribing on the topic /static_image/. Make sure that you are publishing what you think you are publishing. You can run the publisher node and then check the published topics with: rostopic list