imagesift.h
Go to the documentation of this file.
00001 // -*- mode: c++ -*-
00002 /*********************************************************************
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2015, JSK Lab
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/o2r other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of the JSK Lab nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *********************************************************************/
00035 
00036 
00037 #ifndef IMAGESIFT_SIFT_NODE_H_
00038 #define IMAGESIFT_SIFT_NODE_H_
00039 
00040 #include <jsk_topic_tools/diagnostic_nodelet.h>
00041 #include <ros/node_handle.h>
00042 #include <sensor_msgs/Image.h>
00043 #include <posedetection_msgs/ImageFeature0D.h>
00044 #include <posedetection_msgs/Feature0DDetect.h>
00045 #include <image_transport/image_transport.h>
00046 #include <image_transport/subscriber_filter.h>
00047 
00048 #include <boost/shared_ptr.hpp>
00049 #include <boost/thread/mutex.hpp>
00050 
00051 #include <cv_bridge/cv_bridge.h>
00052 #include <siftfast/siftfast.h>
00053 
00054 #include <message_filters/subscriber.h>
00055 #include <message_filters/synchronizer.h>
00056 #include <message_filters/sync_policies/exact_time.h>
00057 
00058 namespace imagesift
00059 {
00060   class SiftNode: public jsk_topic_tools::DiagnosticNodelet
00061   {
00062   public:
00063     typedef message_filters::sync_policies::ExactTime<
00064       sensor_msgs::Image,
00065       sensor_msgs::Image > SyncPolicy;
00066     ros::Time lasttime;
00067     SiftNode(): DiagnosticNodelet("SiftNode") {}
00068   protected:
00069     bool _bInfoInitialized;
00070     bool _useMask;
00071     boost::mutex _mutex;
00072     boost::shared_ptr<image_transport::ImageTransport> _it;
00073     image_transport::Subscriber _subImage;
00074     // for useMask
00075     message_filters::Subscriber<sensor_msgs::Image> _subImageWithMask;
00076     message_filters::Subscriber<sensor_msgs::Image> _subMask;
00077     boost::shared_ptr<message_filters::Synchronizer<SyncPolicy> > _sync;
00078     ros::ServiceServer _srvDetect;
00079     ros::Subscriber _subInfo;
00080     ros::Publisher _pubFeatures;
00081     ros::Publisher _pubSift;
00082     posedetection_msgs::ImageFeature0D _sift_msg;
00083 
00084     virtual void onInit();
00085     virtual void subscribe();
00086     virtual void unsubscribe();
00087     void infoCb(const sensor_msgs::CameraInfoConstPtr& msg_ptr);
00088     bool detectCb(posedetection_msgs::Feature0DDetect::Request& req,
00089                   posedetection_msgs::Feature0DDetect::Response& res);
00090     bool detect(posedetection_msgs::Feature0D& features,
00091                 const sensor_msgs::Image& imagemsg,
00092                 const sensor_msgs::Image::ConstPtr& mask_ptr);
00093     void imageCb(const sensor_msgs::ImageConstPtr& msg_ptr,
00094                  const sensor_msgs::ImageConstPtr& mask_ptr);
00095     void imageCb(const sensor_msgs::ImageConstPtr& msg_ptr);
00096   private:
00097   };
00098 }
00099 
00100 #endif


imagesift
Author(s): Rosen Diankov (rdiankov@cs.cmu.edu), Kei Okada
autogenerated on Wed Sep 16 2015 04:36:33