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

Revision history [back]

@Jan Tromp, I haven't used pickit3d, but let me suggest one way. Are you able to run pickit3d ros package? If you did, please type rostopic list and provide the output.

You should be able to see topics which publishes message in sensor_msgs/Image type. When you subscribe these topics you will be able to get raw image datas (rgb and depth). You can subscribe these topics from the terminal to check:

rostopic echo /topic_name

If you can get raw datas, then what you can do is to create a ros node which subscribes these topics. After subscribing these topics, you can process these images with opencv as you wish.

Here is a code sample to subscribe an image:

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>

void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
  try
  {
    cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image);
    cv::waitKey(30);
  }
  catch (cv_bridge::Exception& e)
  {
    ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
  }
}

int main(int argc, char **argv)
{
  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");
}

Realize that opencv library is already added in the topic. After this point, there is nothing related to ROS. You can process the images with opencv by editing this code template as if you are using opencv in normal c++ mode.

Realize that you need to edit "camera/image" topic name in this line with your topic name.

  image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback);

Don't forget to mark this comment as answer. Good luck!