Ask Your Question
0

Image subscriber - window popup does not appear

asked 2015-03-10 06:28:32 -0500

Kapil Yadav gravatar image

I am following image subscribe tutorial on official ROS page. when I run my_subscriber no window popup appears. I type -

rosrun image_transport_tutorial my_subscriber

output is -

init done
opengl support available

I am following this tutorial - [ROS tutorial] ( http://wiki.ros.org/image_transport/T... )

I have roscore and rosrun image_transport_tutorial my_publisher pathtofile already running in dofferent terminals.

my_subscriber file has the following contents -

#include <ros/ros.h>
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <stdio.h>
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
  try
  {
    cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image);
  }
  catch (cv_bridge::Exception& e)
  {
    ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
  }
}

int main(int argc, char **argv)
{
  std::cout<<"kapil";
  ros::init(argc, argv, "image_listener");
  ros::NodeHandle nh;
  cv::namedWindow("view");
  cv::startWindowThread();
  image_transport::ImageTransport it(nh);
  image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback);
  ros::spin();
  cv::destroyWindow("view");
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-11 17:14:16 -0500

sudhanshu_mittal gravatar image

The code given in the tutorial seems to be working perfectly fine.

This is some configuration problem. I hope you tried this. http://stackoverflow.com/questions/12...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-10 06:28:32 -0500

Seen: 399 times

Last updated: Mar 11 '15