9 async_web_server_cpp::HttpConnectionPtr connection,
ros::NodeHandle& nh) :
10 request_(request), connection_(connection), nh_(nh), inactive_(false)
12 topic_ = request.get_query_param_value_or_default(
"topic",
"");
20 async_web_server_cpp::HttpConnectionPtr connection,
ros::NodeHandle& nh) :
21 ImageStreamer(request, connection, nh), it_(nh), initialized_(false)
23 output_width_ = request.get_query_param_value_or_default<
int>(
"width", -1);
24 output_height_ = request.get_query_param_value_or_default<
int>(
"height", -1);
25 invert_ = request.has_query_param(
"invert");
26 default_transport_ = request.get_query_param_value_or_default(
"default_transport",
"raw");
39 for (
size_t it = 0; it<available_topics.size(); it++){
40 std::string available_topic_name = available_topics[it].name;
41 if(available_topic_name ==
topic_ || (available_topic_name.find(
"/") == 0 &&
42 available_topic_name.substr(1) ==
topic_)) {
63 catch (boost::system::system_error &e)
66 ROS_DEBUG(
"system_error exception: %s", e.what());
70 catch (std::exception &e)
92 if (msg->encoding.find(
"F") != std::string::npos)
96 cv::Mat_<float> float_image = float_image_bridge;
98 cv::minMaxIdx(float_image, 0, &max_val);
102 float_image *= (255 / max_val);
112 int input_width = img.cols;
113 int input_height = img.rows;
123 cv::flip(img, img,
false);
124 cv::flip(img, img,
true);
132 cv::resize(img, img_resized, new_size);
156 catch (cv::Exception &e)
162 catch (boost::system::system_error &e)
165 ROS_DEBUG(
"system_error exception: %s", e.what());
169 catch (std::exception &e)
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())
virtual void initialize(const cv::Mat &)
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
std::vector< TopicInfo > V_TopicInfo
ImageTransportImageStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle &nh)
cv::Mat output_size_image
#define ROS_ERROR_THROTTLE(rate,...)
image_transport::ImageTransport it_
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
std::string default_transport_
ImageStreamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle &nh)
virtual ~ImageTransportImageStreamer()
virtual void restreamFrame(double max_age)
virtual void sendImage(const cv::Mat &, const ros::Time &time)=0
image_transport::Subscriber image_sub_