callbacks.cpp
Go to the documentation of this file.
00001 #include <stdexcept>
00002 #include <boost/bind.hpp>
00003 #include <image_transport/image_transport.h>
00004 #include <sensor_msgs/Image.h>
00005 #include <visp/vpImage.h>
00006 
00007 #include "conversion.hh"
00008 
00009 #include "callbacks.hh"
00010 
00011 # include <visp/vpMbEdgeTracker.h>
00012 # include <visp/vpMbKltTracker.h>
00013 
00014 void imageCallback(vpImage<unsigned char>& image,
00015                    const sensor_msgs::Image::ConstPtr& msg,
00016                    const sensor_msgs::CameraInfoConstPtr& info)
00017 {
00018   try
00019     {
00020       rosImageToVisp(image, msg);
00021     }
00022   catch(std::exception& e)
00023     {
00024       ROS_ERROR_STREAM("dropping frame: " << e.what());
00025     }
00026 }
00027 
00028 void imageCallback(vpImage<unsigned char>& image,
00029                    std_msgs::Header& header,
00030                    sensor_msgs::CameraInfoConstPtr& info,
00031                    const sensor_msgs::Image::ConstPtr& msg,
00032                    const sensor_msgs::CameraInfoConstPtr& infoConst)
00033 {
00034   imageCallback(image, msg, info);
00035   header = msg->header;
00036   info = infoConst;
00037 }
00038 
00039 image_transport::CameraSubscriber::Callback
00040 bindImageCallback(vpImage<unsigned char>& image)
00041 {
00042   return boost::bind(imageCallback, boost::ref(image), _1, _2);
00043 }
00044 
00045 image_transport::CameraSubscriber::Callback
00046 bindImageCallback(vpImage<unsigned char>& image,
00047                   std_msgs::Header& header,
00048                   sensor_msgs::CameraInfoConstPtr& info)
00049 {
00050   return boost::bind
00051     (imageCallback,
00052      boost::ref(image), boost::ref(header), boost::ref(info), _1, _2);
00053 }
00054 
00055 void reconfigureCallback(vpMbTracker* tracker,
00056                          vpImage<unsigned char>& I,
00057                          vpMe& moving_edge,
00058        vpKltOpencv& kltTracker,
00059        const std::string &trackerType,
00060                          boost::recursive_mutex& mutex,
00061                          visp_tracker::ModelBasedSettingsConfig& config,
00062                          uint32_t level)
00063 {
00064   mutex.lock ();
00065   try
00066     {
00067       ROS_INFO("Reconfigure request received.");
00068       
00069       if(trackerType != "klt"){
00070         convertModelBasedSettingsConfigToVpMe(config, moving_edge, tracker);
00071 //         moving_edge.print();
00072       }
00073       
00074       if(trackerType != "mbt")
00075         convertModelBasedSettingsConfigToVpKltOpencv(config, kltTracker, tracker); 
00076       
00077       vpHomogeneousMatrix cMo;
00078       tracker->getPose(cMo);
00079       tracker->initFromPose(I, cMo);      
00080     }
00081   catch (...)
00082     {
00083       mutex.unlock ();
00084       throw;
00085     }
00086   mutex.unlock ();
00087 }


visp_tracker
Author(s): Thomas Moulard/thomas.moulard@gmail.com
autogenerated on Sat Dec 28 2013 17:46:03