fuse_images.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2017, Kentaro Wada and JSK Lab
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/o2r other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Kentaro Wada and JSK Lab nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef JSK_PCL_ROS_FUSE_DEPTH_IMAGES_H_
00036 #define JSK_PCL_ROS_FUSE_DEPTH_IMAGES_H_
00037 
00038 #include <vector>
00039 
00040 #include <jsk_topic_tools/diagnostic_nodelet.h>
00041 #include <message_filters/pass_through.h>
00042 #include <message_filters/subscriber.h>
00043 #include <message_filters/synchronizer.h>
00044 #include <message_filters/sync_policies/approximate_time.h>
00045 #include <message_filters/time_synchronizer.h>
00046 #include <sensor_msgs/Image.h>
00047 #include <sensor_msgs/image_encodings.h>
00048 
00049 namespace jsk_pcl_ros
00050 {
00051   class FuseImages: public jsk_topic_tools::DiagnosticNodelet
00052   {
00053   public:
00054     FuseImages(const std::string& name, const std::string& encoding):
00055       DiagnosticNodelet(name), encoding_(encoding) {}
00056   protected:
00057     virtual void onInit();
00058     virtual void subscribe();
00059     virtual void unsubscribe();
00060     virtual bool validateInput(const sensor_msgs::Image::ConstPtr& in,
00061                                const int height_expected, const int width_expected, std::vector<cv::Mat>& inputs);
00062 
00063     ros::Publisher pub_out_;
00064 
00065     bool approximate_sync_;
00066     int queue_size_;
00067     bool averaging_;
00068     std::string encoding_;
00069 
00072     message_filters::PassThrough<sensor_msgs::Image> nf_;
00073 
00075     std::vector<boost::shared_ptr<message_filters::Subscriber<sensor_msgs::Image> > > filters_;
00076 
00080     boost::shared_ptr<message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime<
00081       sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
00082       sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image> > > async_;
00083     boost::shared_ptr<message_filters::Synchronizer<message_filters::sync_policies::ExactTime<
00084       sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image,
00085       sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image> > > sync_;
00086 
00091     inline void
00092     input_callback (const sensor_msgs::Image::ConstPtr &input)
00093     {
00094       sensor_msgs::Image imgmsg;
00095       imgmsg.header.stamp = input->header.stamp;
00096       nf_.add(boost::make_shared<sensor_msgs::Image> (imgmsg));
00097     }
00098 
00099     virtual void inputCb(const sensor_msgs::Image::ConstPtr &in1, const sensor_msgs::Image::ConstPtr &in2,
00100                          const sensor_msgs::Image::ConstPtr &in3, const sensor_msgs::Image::ConstPtr &in4,
00101                          const sensor_msgs::Image::ConstPtr &in5, const sensor_msgs::Image::ConstPtr &in6,
00102                          const sensor_msgs::Image::ConstPtr &in7, const sensor_msgs::Image::ConstPtr &in8);
00103 
00104     virtual cv::Mat fuseInputs(std::vector<cv::Mat> inputs) {};
00105   private:
00106   };
00107 
00108   class FuseDepthImages: public FuseImages
00109   {
00110   public:
00111     FuseDepthImages(): FuseImages("FuseDepthImages", sensor_msgs::image_encodings::TYPE_32FC1) {};
00112   protected:
00113     virtual cv::Mat fuseInputs(std::vector<cv::Mat> inputs);
00114   };
00115 
00116   class FuseRGBImages: public FuseImages
00117   {
00118   public:
00119     FuseRGBImages(): FuseImages("FuseRGBImages", sensor_msgs::image_encodings::RGB8) {};
00120   protected:
00121     virtual cv::Mat fuseInputs(std::vector<cv::Mat> inputs);
00122   };
00123 
00124 } // namespace jsk_pcl_ros
00125 
00126 #endif // JSK_PCL_ROS_FUSE_DEPTH_IMAGES_H_


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jul 2 2019 19:41:43