Robotics StackExchange | Archived questions

Image subscriber - window popup does not appear

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

I have roscore and rosrun imagetransporttutorial 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");
}

Asked by Kapil Yadav on 2015-03-10 06:28:32 UTC

Comments

Answers

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/12415164/init-done-opengl-support-available

Asked by sudhanshu_mittal on 2015-03-11 17:14:16 UTC

Comments