include <ros ros.h="">
include <image_transport image_transport.h="">
include <cv_bridge cv_bridge.h="">
include <sensor_msgs image_encodings.h="">
include <opencv2 imgproc="" imgproc.hpp="">
include <opencv2 highgui="" highgui.hpp="">
void callback(const sensor_msgs::ImageConstPtr& msg) {
cv_bridge::CvImagePtr cvImagePtr; try {
cvImagePtr = cv_bridge::toCvCopy(msg);
//cv::Mat &mat = cvImagePtr->image;
cv::imshow("windowName", cvImagePtr->image);
cv::destroyWindow("windowName");
}
catch (cv_bridge::Exception &e) {
ROS_ERROR("cv_bridge exception: %s", e.what());
}
} int main(int argc, char **argv) {
ros::init(argc, argv, "nodeName");
cv::namedWindow("windowName");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub = it.subscribe("/ardrone/image_raw", 1, callback);
ros::spin();
}