test_h264_sub.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
3 #include <opencv2/highgui/highgui.hpp>
4 #include <cv_bridge/cv_bridge.h>
5 
6 void imageCallback(const sensor_msgs::ImageConstPtr& msg)
7 {
8  try
9  {
10  cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image);
11  cv::waitKey(1);
12  }
13  catch (cv_bridge::Exception& e)
14  {
15  ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
16  }
17 }
18 
19 int main(int argc, char **argv) {
20  ros::init(argc, argv, "image_listener");
21  ros::NodeHandle nh;
22  cv::namedWindow("view");
23  cv::startWindowThread();
25  image_transport::Subscriber sub = it.subscribe("/tello/image_raw", 1, imageCallback);
26  ros::spin();
27  cv::destroyWindow("view");
28 }
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
Subscriber subscribe(const std::string &base_topic, uint32_t queue_size, const boost::function< void(const sensor_msgs::ImageConstPtr &)> &callback, const ros::VoidPtr &tracked_object=ros::VoidPtr(), const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
#define ROS_ERROR(...)
int main(int argc, char **argv)


tello_driver
Author(s): Jordy van Appeven
autogenerated on Wed May 13 2020 03:34:54