3 #include <boost/iostreams/filtering_streambuf.hpp> 
    4 #include <boost/iostreams/copy.hpp> 
    5 #include <boost/iostreams/filter/zstd.hpp> 
    7 #include <opencv2/core/mat.hpp> 
    8 #include <opencv2/imgcodecs.hpp> 
   10 #include <rgbd_msgs/RGBD.h> 
   12 #include <ros/node_handle.h> 
   66     rgbd_msgs::RGBDPtr msg = boost::make_shared<rgbd_msgs::RGBD>();
 
   72     boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
 
   73     in.push(boost::iostreams::zstd_compressor(boost::iostreams::zstd::best_speed));
 
   75     boost::iostreams::copy(in, stream2);
 
   91     if (req.compression != rgbd_msgs::GetRGBDRequest::JPEG && req.compression != rgbd_msgs::GetRGBDRequest::PNG)
 
   93         ROS_ERROR_NAMED(
"ServerRGBD", 
"Invalid compression, only JPEG and PNG are supported (see ENUM in srv definition)");
 
   98     cv::Mat resized_rgb, resized_depth;
 
  100     double ratio_rgb = 
static_cast<double>(req.width) / 
static_cast<double>(image.
getRGBImage().cols);
 
  101     double ratio_depth = 
static_cast<double>(req.width) / 
static_cast<double>(image.
getDepthImage().cols);
 
  103     cv::resize(image.
getRGBImage(), resized_rgb, cv::Size(req.width, 
static_cast<int>(image.
getRGBImage().rows * ratio_rgb)));
 
  104     cv::resize(image.
getDepthImage(), resized_depth, cv::Size(req.width, 
static_cast<int>(image.
getDepthImage().rows * ratio_depth)));
 
  107     std::string compression_str = req.compression == rgbd_msgs::GetRGBDRequest::JPEG ? 
".jpeg" : 
".png";
 
  108     if (cv::imencode(compression_str, resized_rgb, resp.rgb_data) && cv::imencode(compression_str, resized_depth, resp.depth_data))
 
  111     ROS_ERROR_STREAM_NAMED(
"ServerRGBD", 
"cv::imencode with compression_str " << compression_str << 
" failed!");