#include <ros/ros.h>
#include <iostream>
#include <image_transport/image_transport.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
namespace enc = sensor_msgs::image_encodings;
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{ cv_bridge::CvImagePtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
cv::imshow("OpenCV viewer uEye", cv_ptr->image);
cv::waitKey(3);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "listenerKinectuEye");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub = it.subscribe("/camera/image_color", 1, imageCallback);
ROS_INFO("subscribed to Kinect & uEye topics");
ros::spin();
}
My question is how can I add a parameter to imageCallback function ? and how to use it in the subscribe (the Syntax) in the main function ?
Originally posted by ROSkinect on ROS Answers with karma: 751 on 2014-05-14
Post score: 0